Skip to content

Commit

Permalink
show all sources as read when offline
Browse files Browse the repository at this point in the history
  • Loading branch information
Allie Crevier committed Oct 22, 2020
1 parent 06db93b commit b1d5609
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,9 @@ def on_source_changed(self):
self.source_conversations[source.uuid] = conversation_wrapper

self.set_conversation(conversation_wrapper)
self.source_list.mark_seen.emit(source.uuid)

if self.controller.authenticated:
self.source_list.mark_seen.emit(source.uuid)

def delete_conversation(self, source_uuid: str) -> None:
"""
Expand Down Expand Up @@ -1009,6 +1011,7 @@ def __init__(self, controller: Controller, source: Source, mark_seen_signal: pyq
self.controller = controller
self.controller.source_deleted.connect(self._on_source_deleted)
self.controller.source_deletion_failed.connect(self._on_source_deletion_failed)
self.controller.authentication_state.connect(self._on_authentication_changed)
mark_seen_signal.connect(self._on_mark_seen)

# Store source
Expand Down Expand Up @@ -1115,7 +1118,8 @@ def update(self):
self.paperclip.hide()
self.star.update(self.source.is_starred)

self.seen = self.source.seen
# When not authenticated we always show the source as having been seen
self.seen = True if not self.controller.is_authenticated else self.source.seen
self.update_styles()
except sqlalchemy.exc.InvalidRequestError as e:
logger.debug(f"Could not update SourceWidget for source {self.source_uuid}: {e}")
Expand Down Expand Up @@ -1162,6 +1166,15 @@ def update_styles(self) -> None:
self.preview.setObjectName("SourceWidget_preview_unread")
self.setStyleSheet(self.SOURCE_CSS)

@pyqtSlot(bool)
def _on_authentication_changed(self, authenticated: bool) -> None:
"""
When the user logs out, show source as seen.
"""
if not authenticated:
self.seen = True
self.update_styles()

@pyqtSlot(str)
def _on_mark_seen(self, source_uuid: str):
if self.source_uuid != source_uuid:
Expand Down

0 comments on commit b1d5609

Please sign in to comment.