Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,17 @@ def serve_layout():
# Define callbacks for the app
# ==============================================================

@app.callback(Output('session-id', 'data'),
@app.callback([Output('session-id', 'data'),
Output('url', 'pathname')],
[Input({'type': 'clear-storage-button', 'index': ALL}, 'n_clicks')])
def start_new_session(n_clicks):
trigger = dash.callback_context.triggered[0]
if not callback_utils.ensure_triggered(trigger):
return no_update
return no_update, no_update
else:
cache = keydb.KeyDB(connection_pool=keydb_pool)
new_session_id = session_utils.initiate_session(cache, app.logger)
return new_session_id
return new_session_id, UrlIndex.HOME.value


@app.callback([Output('contact-alert-div', 'children'),
Expand Down
6 changes: 2 additions & 4 deletions components/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@


def StartNewSessionLink():
return dbc.NavLink(
dbc.Button(
"Start new session", block=True, color='danger', id={'type': 'clear-storage-button', 'index': '1'}
), href=UrlIndex.ROOT.value, style={"text-decoration": "none"})
return dbc.Button("Start new session", block=True, color='danger',
id={'type': 'clear-storage-button', 'index': '1'})


def GitHubLink():
Expand Down
2 changes: 1 addition & 1 deletion components/modals.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def SessionTimedOutModal():
return dbc.Modal([
ModalHeader("Session timed-out"),
dbc.ModalBody([
html.P("""More than 15 minutes have passed since you last interacted with the website and your session has
html.P("""More than 60 minutes have passed since you last interacted with the website and your session has
timed-out.""", style={'text-align': "justify"}),
components.StartNewSessionLink()
]),
Expand Down
4 changes: 2 additions & 2 deletions utils/session_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def decompress_session(session):
return session


def is_expired_session(session_id, cache, logger, expire_time=900):
def is_expired_session(session_id, cache, logger, expire_time=3600):
if not cache.exists(session_id):
logger.info('Session {} has expired'.format(session_id))
return True
Expand All @@ -95,7 +95,7 @@ def is_expired_session(session_id, cache, logger, expire_time=900):
return False


def initiate_session(cache, logger, expire_time=900):
def initiate_session(cache, logger, expire_time=3600):
session_id = str(uuid.uuid4())
logger.info('New session initiated {}'.format(session_id))
cache.hset(session_id, cache_utils.CacheKeys.ID.value, compress_data(session_id))
Expand Down