mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	Fix pruning of event queues that only had virtual events.
(imported from commit 7b43d2164df6e95a6feb073b8f90c0862245d629)
This commit is contained in:
		@@ -194,14 +194,18 @@ class EventQueue(object):
 | 
			
		||||
        else:
 | 
			
		||||
            self.queue.append(event)
 | 
			
		||||
 | 
			
		||||
    # Note that pop ignores virtual events.  This is fine in our
 | 
			
		||||
    # current usage since virtual events should always be resolved to
 | 
			
		||||
    # a real event before being given to users.
 | 
			
		||||
    def pop(self):
 | 
			
		||||
        return self.queue.popleft()
 | 
			
		||||
 | 
			
		||||
    def empty(self):
 | 
			
		||||
        return len(self.queue) == 0 and len(self.virtual_events) == 0
 | 
			
		||||
 | 
			
		||||
    # See the comment on pop; that applies here as well
 | 
			
		||||
    def prune(self, through_id):
 | 
			
		||||
        while not self.empty() and self.queue[0]['id'] <= through_id:
 | 
			
		||||
        while len(self.queue) != 0 and self.queue[0]['id'] <= through_id:
 | 
			
		||||
            self.pop()
 | 
			
		||||
 | 
			
		||||
    def contents(self):
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user