in client/securedrop_client/gui/widgets.py [0:0]
def on_source_changed(self) -> None:
"""
Show conversation for the selected source, or, if multiple sources are selected,
show multi select view.
"""
selected = len(self.source_list.selectedItems())
if selected == 1:
# One source selected; prepare the conversation widget
try:
source = self.source_list.get_selected_source()
# Avoid race between user selection and remote deletion
if not source:
return
self.controller.session.refresh(source)
# Immediately show the selected source as seen in the UI and then make a
# request to mark source as seen.
self.source_list.source_selected.emit(source.uuid)
self.controller.mark_seen(source)
# Get or create the SourceConversationWrapper
if source.uuid in self.source_conversations:
conversation_wrapper = self.source_conversations[source.uuid]
conversation_wrapper.conversation_view.update_conversation( # type: ignore[has-type]
source.collection
)
else:
conversation_wrapper = SourceConversationWrapper(
source, self.controller, self._state
)
self.source_conversations[source.uuid] = conversation_wrapper
# Put this widget into the QStackedLayout at the correct position
self.set_conversation(conversation_wrapper)
logger.debug(f"Set conversation to the selected source with uuid: {source.uuid}")
except sqlalchemy.exc.InvalidRequestError as e:
logger.debug(e)
# Now show the right widget depending on the selection
self._on_update_conversation_context()