Skip to content

Commit

Permalink
bugfix: populate source list immediately upon login (#577)
Browse files Browse the repository at this point in the history
the controller's update_sources() method is used to display in the
source list whatever is contained in local storage. If we wait until
after sync_api is called before calling it, there will be a delay
of potentially several seconds until the round-trip to the SecureDrop
server completes.

in this commit we call the update_sources() method immediately
upon login.
  • Loading branch information
redshiftzero committed Nov 19, 2019
1 parent cf9d499 commit 07713fc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions securedrop_client/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def on_authenticate_success(self, result):
self.api.journalist_last_name,
self.session)
self.gui.show_main_window(user)
self.update_sources()
self.sync_api()
self.api_job_queue.login(self.api)
self.is_authenticated = True
Expand Down
2 changes: 2 additions & 0 deletions tests/test_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def test_Controller_on_authenticate_success(homedir, config, mocker, session_mak
mock_api_job_queue = mocker.patch("securedrop_client.logic.ApiJobQueue")
co = Controller('http://localhost', mock_gui, session_maker, homedir)
co.sync_api = mocker.MagicMock()
co.update_sources = mocker.MagicMock()
co.session.add(user)
co.session.commit()
co.api = mocker.MagicMock()
Expand All @@ -211,6 +212,7 @@ def test_Controller_on_authenticate_success(homedir, config, mocker, session_mak
co.sync_api.assert_called_once_with()
assert co.is_authenticated
assert mock_api_job_queue.called
co.update_sources.assert_called_once_with()
login.assert_called_with(co.api)
co.resume_queues.assert_called_once_with()

Expand Down

0 comments on commit 07713fc

Please sign in to comment.