Repository: zulip/zulip

Issue:
Unread message clearing issue
I logged into zulip after years. The dialog box showed 50K unread messages with an option to clear the unread messages. After clicking on the option 'clear unread message' (i don't remember exact words), the dialog box didn't show any progress or count, as result, I was waiting for the box to disappear. 

Meanwhile, the unread count on the streams section kept changing in the left sidebar, after a while, the stream count change wasn't visible. Now I reloaded the page. The stream counts were gone, the home page was still showing the threads from a long back. There is no 'go the latest' link on the page. I'm scrolling for several minutes and unable to go to the latest thread by date.

What could be helpful?

1. While clearing the unread message, show how completion status.
2. Add a link to go the latest message after choosing the clear the unread message or anywhere from the UI.

[Edit]: Clicking on, one of the streams, on the left sidebar takes to the latest place and from there it's possible to go in reverse chronological order.



Discussion:
Hello @zulip/server-sidebars members, this issue was labeled with the "area: left-sidebar" label, so you may want to check it out!

<!-- areaLabelAddition -->
I think this is a duplicate issue, but I agree and thanks for reraising this.  

Resolving patch:
diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.py
--- a/zerver/tornado/event_queue.py
+++ b/zerver/tornado/event_queue.py
@@ -350,10 +350,28 @@ def push(self, orig_event: Mapping[str, Any]) -> None:
         event["id"] = self.next_event_id
         self.next_event_id += 1
         full_event_type = compute_full_event_type(event)
-        if full_event_type == "restart" or full_event_type.startswith("flags/"):
+        if full_event_type == "restart" or (
+            full_event_type.startswith("flags/")
+            and not full_event_type.startswith("flags/remove/read")
+        ):
+            # virtual_events are an optimization that allows certain
+            # simple events, such as update_message_flags events that
+            # simply contain a list of message IDs to operate on, to
+            # be compressed together. This is primarily useful for
+            # flags/add/read, where normal Zulip usage will result in
+            # many small flags/add/read events as users scroll.
+            #
+            # We need to exclude flags/remove/read, because it has an
+            # extra message_details field that cannot be compressed.
+            #
+            # BUG: This compression algorithm is incorrect in the
+            # presence of mark-as-unread, since it does not respect
+            # the ordering of "mark as read" and "mark as unread"
+            # updates for a given message.
             if full_event_type not in self.virtual_events:
                 self.virtual_events[full_event_type] = copy.deepcopy(event)
                 return
+
             # Update the virtual event with the values from the event
             virtual_event = self.virtual_events[full_event_type]
             virtual_event["id"] = event["id"]


Test patch:
diff --git a/frontend_tests/node_tests/popovers.js b/frontend_tests/node_tests/popovers.js
--- a/frontend_tests/node_tests/popovers.js
+++ b/frontend_tests/node_tests/popovers.js
@@ -27,11 +27,6 @@ const message_lists = mock_esm("../../static/js/message_lists", {
         view: {
             message_containers: {},
         },
-        data: {
-            fetch_status: {
-                has_found_newest: () => true,
-            },
-        },
     },
 });
 mock_esm("../../static/js/message_viewport", {