Skip to content

Commit ec7e0d6

Browse files
committed
model: Add footer notification for message.
This commit shows notifications in the footer if a message sent/edited by user is outside current narrow. This will give the user a pointer as to why the message disappeared from the screen. The code is hooked to the part where message request is sent to the server, hence preventing check for user_id and message sender_id being the same. Fixes #781.
1 parent 114ec0d commit ec7e0d6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

zulipterminal/model.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,17 @@ def send_stream_message(self, stream: str, topic: str,
357357
}
358358
response = self.client.send_message(request)
359359
display_error_if_present(response, self.controller)
360+
361+
curr_narrow = self.narrow
362+
view = self.controller.view
363+
if ((len(curr_narrow) == 1
364+
and curr_narrow[0][1] != request['to'])
365+
or (len(curr_narrow) == 2
366+
and (curr_narrow[0][1] != request['to']
367+
or curr_narrow[1][1] != request['subject']))):
368+
view.set_footer_text(
369+
'Message is sent outside of current narrow.', 3)
370+
360371
return response['result'] == 'success'
361372

362373
def update_private_message(self, msg_id: int, content: str) -> bool:
@@ -381,6 +392,13 @@ def update_stream_message(self, topic: str, message_id: int,
381392

382393
response = self.client.update_message(request)
383394
display_error_if_present(response, self.controller)
395+
396+
old_topic = self.index['messages'][message_id].get('subject', None)
397+
new_topic = request['topic']
398+
view = self.controller.view
399+
if old_topic != new_topic:
400+
view.set_footer_text('Topic changed', 3)
401+
384402
return response['result'] == 'success'
385403

386404
def fetch_custom_emojis(self) -> NamedEmojiData:

0 commit comments

Comments
 (0)