mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
Revert "Upgrade event flag collapsing to support all flag changes."
This reverts commit dadf3852f2ca7aaa85fb97b3d265c990b4e5a38a. (imported from commit de5a95572aa955b4a9419b80a99d2446c51730e7)
This commit is contained in:
@@ -148,10 +148,13 @@ def compute_full_event_type(event):
|
||||
if event["type"] == "update_message_flags":
|
||||
if event["all"]:
|
||||
# Put the "all" case in its own category
|
||||
return "all_flags/%s/%s" % (event["flag"], event["operation"])
|
||||
return "flags/%s/%s" % (event["operation"], event["flag"])
|
||||
return "%s/%s/all" % (event["flag"], event["operation"])
|
||||
return "%s/%s" % (event["flag"], event["operation"])
|
||||
return event["type"]
|
||||
|
||||
# Virtual events are a mechanism for storing pointer changes and other
|
||||
# easily collapsed event types efficiently.
|
||||
VIRTUAL_EVENT_TYPES = ["pointer", "read/add", "restart"]
|
||||
class EventQueue(object):
|
||||
def __init__(self, id):
|
||||
self.queue = deque()
|
||||
@@ -177,8 +180,7 @@ class EventQueue(object):
|
||||
event['id'] = self.next_event_id
|
||||
self.next_event_id += 1
|
||||
full_event_type = compute_full_event_type(event)
|
||||
if (full_event_type in ["pointer", "restart"] or
|
||||
full_event_type.startswith("flags/")):
|
||||
if full_event_type in VIRTUAL_EVENT_TYPES:
|
||||
if full_event_type not in self.virtual_events:
|
||||
self.virtual_events[full_event_type] = copy.deepcopy(event)
|
||||
return
|
||||
@@ -189,10 +191,10 @@ class EventQueue(object):
|
||||
virtual_event["timestamp"] = event["timestamp"]
|
||||
if full_event_type == "pointer":
|
||||
virtual_event["pointer"] = event["pointer"]
|
||||
elif full_event_type == "read/add":
|
||||
virtual_event["messages"] += event["messages"]
|
||||
elif full_event_type == "restart":
|
||||
virtual_event["server_generation"] = event["server_generation"]
|
||||
elif full_event_type.startswith("flags/"):
|
||||
virtual_event["messages"] += event["messages"]
|
||||
else:
|
||||
self.queue.append(event)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user