Skip to content

Commit

Permalink
Make sure that uncertain connection state always shows error statusbar (
Browse files Browse the repository at this point in the history
  • Loading branch information
podliashanyk authored Jul 5, 2024
1 parent 7429696 commit 906f0c6
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/howitz/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,20 +582,16 @@ def refresh_events():
def test_conn():
is_connection_ok = test_zino_connection()
caller_id = request.headers.get('HX-Target', None)
if is_connection_ok is False:
if not is_connection_ok:
current_app.logger.debug('Connection test failed showing error appbar')
if is_connection_ok is None: # Uncertain connection state
try: # Attempt a quiet reconnect
reconnect_to_zino()
except:
pass
return render_template('components/feedback/connection-status-bar/error-appbar-content.html',
error_message="Connection to Zino server is lost")

if is_connection_ok is None: # Uncertain connection state
try: # Attempt a quiet reconnect
reconnect_to_zino()
except:
pass
response = make_response()
response.headers['HX-Reswap'] = 'none'
return response

if caller_id == 'connection-error-content': # If connection should be restored after error
reconnect_to_zino()
current_app.logger.debug('Connection test OK, caller ID %s', caller_id)
Expand Down

0 comments on commit 906f0c6

Please sign in to comment.