From 55f4097e72995200f6574ba104134c2a966841e3 Mon Sep 17 00:00:00 2001 From: zee-bit Date: Fri, 13 Nov 2020 17:31:13 +0530 Subject: [PATCH] model: Add footer notification for messages. This will set a footer text notifying the user everytime he sends or edits a message that is outside the current narrow. This will give the user a pointer as to why the message disappeared from the screen. Fixes #781. --- zulipterminal/model.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/zulipterminal/model.py b/zulipterminal/model.py index 0cc1ce62e01..1a141668b23 100644 --- a/zulipterminal/model.py +++ b/zulipterminal/model.py @@ -230,6 +230,7 @@ def unset_search_narrow(self) -> None: def get_message_ids_in_current_narrow(self) -> Set[int]: narrow = self.narrow index = self.index + print(narrow, flush=True) if narrow == []: ids = index['all_msg_ids'] elif self.is_search_narrow(): # Check searches first @@ -879,6 +880,7 @@ def _handle_message_event(self, event: Event) -> None: Handle new messages (eg. add message to the end of the view) """ message = event['message'] + print(event, flush=True) # sometimes `flags` are missing in `event` so initialize # an empty list of flags in that case. message['flags'] = event.get('flags', []) @@ -966,6 +968,10 @@ def _handle_message_event(self, event: Event) -> None: and self.narrow[1][1] == message['subject']))): msg_log.append(msg_w) + if not append_to_stream: + self.controller.view.set_footer_text( + 'Message sent outside of current narrow', 3) + elif (message['type'] == 'private' and len(self.narrow) == 1 and self.narrow[0][0] == "pm_with"): narrow_recipients = self.recipients @@ -1001,6 +1007,7 @@ def _handle_update_message_event(self, event: Event) -> None: # If the message is indexed if self.index['messages'].get(message_id): message = self.index['messages'][message_id] + print("message =>", message, flush=True) self.index['edited_messages'].add(message_id) if 'rendered_content' in event: @@ -1011,11 +1018,21 @@ def _handle_update_message_event(self, event: Event) -> None: # 'subject' is not present in update event if # the event didn't have a 'subject' update. if 'subject' in event: + old_subject = self.index['messages'][message_id]['subject'] new_subject = event['subject'] + print("old subject =>", old_subject, flush=True) + print("new subject =>", new_subject, flush=True) for msg_id in event['message_ids']: self.index['messages'][msg_id]['subject'] = new_subject self._update_rendered_view(msg_id) + view = self.controller.view + print("event=>", event, flush=True) + if (len(self.narrow) == 2 + and self.narrow[1][0] == 'topic' + and old_subject != new_subject): + view.set_footer_text("Subject changed", 3) + def _handle_reaction_event(self, event: Event) -> None: """ Handle change to reactions on a message