Skip to content

Commit 47b451d

Browse files
Subhasish-Beheraneiljp
authored andcommitted
model: update _handle_update_messages_event.
Uses the analyse_edit_history funciton from helper.py The parameters passed to analyse_edit_history is slightly diffrent from earlier as it gets the required values from event information. Tests adapted.
1 parent 39cc8cb commit 47b451d

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

tests/model/test_model.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,7 +2150,8 @@ def test_notify_users_hides_PM_content_based_on_user_setting(
21502150
"topic_msg_ids": {
21512151
10: {"new subject": {1}, "old subject": {2}},
21522152
},
2153-
"edited_messages": {1},
2153+
"edited_messages": set(),
2154+
"moved_messages": {1},
21542155
"topics": {10: []},
21552156
},
21562157
False,
@@ -2186,7 +2187,8 @@ def test_notify_users_hides_PM_content_based_on_user_setting(
21862187
"topic_msg_ids": {
21872188
10: {"new subject": {1, 2}, "old subject": set()},
21882189
},
2189-
"edited_messages": {1},
2190+
"edited_messages": set(),
2191+
"moved_messages": {1},
21902192
"topics": {10: []},
21912193
},
21922194
False,
@@ -2292,6 +2294,7 @@ def test_notify_users_hides_PM_content_based_on_user_setting(
22922294
10: {"new subject": set(), "old subject": {1, 2}},
22932295
},
22942296
"edited_messages": {1},
2297+
"moved_messages": set(),
22952298
"topics": {10: ["new subject", "old subject"]},
22962299
},
22972300
False,
@@ -2329,7 +2332,8 @@ def test_notify_users_hides_PM_content_based_on_user_setting(
23292332
"topic_msg_ids": {
23302333
10: {"new subject": {1}, "old subject": {2}},
23312334
},
2332-
"edited_messages": {1},
2335+
"edited_messages": set(),
2336+
"moved_messages": {1},
23332337
"topics": {10: []},
23342338
},
23352339
False,
@@ -2363,6 +2367,7 @@ def test_notify_users_hides_PM_content_based_on_user_setting(
23632367
10: {"new subject": set(), "old subject": {1, 2}},
23642368
},
23652369
"edited_messages": {1},
2370+
"moved_messages": set(),
23662371
"topics": {10: ["new subject", "old subject"]},
23672372
},
23682373
False,
@@ -2401,6 +2406,7 @@ def test_notify_users_hides_PM_content_based_on_user_setting(
24012406
10: {"new subject": {3}, "old subject": {1, 2}},
24022407
},
24032408
"edited_messages": set(),
2409+
"moved_messages": set(),
24042410
"topics": {10: []}, # This resets the cache
24052411
},
24062412
False,
@@ -2439,6 +2445,7 @@ def test_notify_users_hides_PM_content_based_on_user_setting(
24392445
10: {"new subject": {3}, "old subject": {1, 2}},
24402446
},
24412447
"edited_messages": set(),
2448+
"moved_messages": set(),
24422449
"topics": {10: ["new subject", "old subject"]},
24432450
},
24442451
True,
@@ -2476,7 +2483,8 @@ def test_notify_users_hides_PM_content_based_on_user_setting(
24762483
"topic_msg_ids": {
24772484
10: {"new subject": {1}, "old subject": {2}},
24782485
},
2479-
"edited_messages": {1},
2486+
"edited_messages": set(),
2487+
"moved_messages": {1},
24802488
"topics": {10: ["new subject", "old subject"]},
24812489
},
24822490
True,
@@ -2512,6 +2520,7 @@ def test__handle_update_message_event(
25122520
10: {"new subject": set(), "old subject": {1, 2}},
25132521
},
25142522
"edited_messages": set(),
2523+
"moved_messages": set(),
25152524
"topics": {10: ["new subject", "old subject"]},
25162525
}
25172526
mocker.patch(MODEL + "._update_rendered_view")

zulipterminal/model.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
StreamData,
6565
TidiedUserInfo,
6666
UserStatus,
67+
analyse_edit_history,
6768
asynch,
6869
canonicalize_color,
6970
classify_unread_counts,
@@ -1709,9 +1710,29 @@ def _handle_update_message_event(self, event: Event) -> None:
17091710
# they are not all marked as edited, as per server optimization
17101711
message_id = event["message_id"]
17111712
indexed_message = self.index["messages"].get(message_id, None)
1712-
1713+
current_topic = None
1714+
old_topic = None
17131715
if indexed_message:
1714-
self.index["edited_messages"].add(message_id)
1716+
if "prev_content" in event:
1717+
content_changed = True
1718+
else:
1719+
content_changed = False
1720+
if "prev_stream" in event:
1721+
stream_changed = True
1722+
else:
1723+
stream_changed = False
1724+
if "subject" in event:
1725+
current_topic = event["subject"]
1726+
old_topic = event["orig_subject"]
1727+
1728+
analyse_edit_history(
1729+
message_id,
1730+
self.index,
1731+
content_changed,
1732+
stream_changed,
1733+
current_topic,
1734+
old_topic,
1735+
)
17151736

17161737
# Update the rendered content, if the message is indexed
17171738
if "rendered_content" in event and indexed_message:

0 commit comments

Comments
 (0)