Skip to content

Commit

Permalink
model: Add footer notification for messages.
Browse files Browse the repository at this point in the history
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 zulip#781.
  • Loading branch information
zee-bit committed Nov 14, 2020
1 parent c7674a0 commit 55f4097
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions zulipterminal/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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', [])
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit 55f4097

Please sign in to comment.