Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
muted_stream_ids: Use set for O(1) search operation.
Prakhar Pratyusha18a526427dc
diff --git a/zerver/lib/message.py b/zerver/lib/message.pyindex bd1a3b8f8e8..cd109c95ee5 100644--- a/zerver/lib/message.py+++ b/zerver/lib/message.py@@ -110,7 +110,7 @@ class RawUnreadMessagesResult(TypedDict):stream_dict: Dict[int, RawUnreadStreamDict]huddle_dict: Dict[int, RawUnreadHuddleDict]mentions: Set[int]- muted_stream_ids: List[int]+ muted_stream_ids: Set[int]unmuted_stream_msgs: Set[int]old_unreads_missing: bool@@ -1014,7 +1014,7 @@ def get_inactive_recipient_ids(user_profile: UserProfile) -> List[int]:return inactive_recipient_ids-def get_muted_stream_ids(user_profile: UserProfile) -> List[int]:+def get_muted_stream_ids(user_profile: UserProfile) -> Set[int]:rows = (get_stream_subscriptions_for_user(user_profile).filter(@@ -1025,7 +1025,7 @@ def get_muted_stream_ids(user_profile: UserProfile) -> List[int]:"recipient__type_id",))- muted_stream_ids = [row["recipient__type_id"] for row in rows]+ muted_stream_ids = {row["recipient__type_id"] for row in rows}return muted_stream_ids@@ -1090,6 +1090,7 @@ def extract_unread_data_from_um_rows() -> RawUnreadMessagesResult:pm_dict: Dict[int, RawUnreadDirectMessageDict] = {}stream_dict: Dict[int, RawUnreadStreamDict] = {}+ muted_stream_ids: Set[int] = set()unmuted_stream_msgs: Set[int] = set()huddle_dict: Dict[int, RawUnreadHuddleDict] = {}mentions: Set[int] = set()@@ -1098,7 +1099,7 @@ def extract_unread_data_from_um_rows(raw_unread_messages: RawUnreadMessagesResult = dict(pm_dict=pm_dict,stream_dict=stream_dict,- muted_stream_ids=[],+ muted_stream_ids=muted_stream_ids,unmuted_stream_msgs=unmuted_stream_msgs,huddle_dict=huddle_dict,mentions=mentions,@@ -1109,7 +1110,6 @@ def extract_unread_data_from_um_rows(return raw_unread_messagesmuted_stream_ids = get_muted_stream_ids(user_profile)- raw_unread_messages["muted_stream_ids"] = muted_stream_idsget_topic_visibility_policy = build_get_topic_visibility_policy(user_profile)diff --git a/zerver/tests/test_message_flags.py b/zerver/tests/test_message_flags.pyindex 2706f4edae6..d517d55de7f 100644--- a/zerver/tests/test_message_flags.py+++ b/zerver/tests/test_message_flags.py@@ -1611,7 +1611,7 @@ class MarkUnreadTest(ZulipTestCase):stream_dict={},huddle_dict={},mentions=set(),- muted_stream_ids=[],+ muted_stream_ids=set(),unmuted_stream_msgs=set(),old_unreads_missing=False,)@@ -1633,7 +1633,7 @@ class MarkUnreadTest(ZulipTestCase):stream_dict={},huddle_dict={},mentions=set(),- muted_stream_ids=[],+ muted_stream_ids=set(),unmuted_stream_msgs=set(),old_unreads_missing=False,)