New Queue System for ChatMain #2556
Labels
App:Frontend
Kind:Enhancement
Improvements, new features, performance upgrades, etc.
Level:Advanced
Note:UI/UX
Priority:High
Problem
The design of
ChatMain.vue
is very problematic. It is currently causing tests to fail because of its very async natural and the way it handles switching chatrooms.Because of its poor design in handling switching chatrooms, all over the code are lines like this after almost every
await
:And this from bd0d0d1:
We are checking
this.summary.chatroomID
,this.ephemeral.renderingChatRoomId
,this.currentChatRoomId
all over the place. This is wrong. We should be using only a singlerenderingChatRoomId
for the component, and nothing else.Solution
Redesign how ChatMain handles switching chatrooms.
Make it so that ChatMain only cares about a single "chatroomID" variable, e.g.
renderingChatRoomId
or whatever.Every time a switch in chatroomID is detected, do not mess with any of ChatMain's variables. Do not update anything. Instead, create a request to ChatMain for ChatMain to process in its own time, on a queue. This request will say, "Please update your
renderingChatRoomId
to this new value", and ChatMain will in the meantime ignore all new messages that come in on other chatroomID contracts.In other words, ChatMain will process requests from a queue to update the current chatroomID in its
ephemeral
data. And these requests can stack up. So for example, Cypress can rapidly switch from chatroom to chatroom but ChatMain will only render and show chatroom for its own internalephemeral.chatroomID
(renderingChatRoomId
, whatever). It will process any requests to update this variable in sequence, one at a time.*Note: when pulling events off of this internal queue, ChatMain can also check this size of the queue. For example, it can decide that if there are more than 1 request on the queue, it can
pop()
and ignore the old ones and just process the most recent one, to speed things up.With these changes made, you should be able to greatly clean up ChatMain and remove all paranoid and DRY-violating calls to
checkEventSourceConsistency
etc.One last note: PR #2555 should probably be merged first as it makes a few changes to ChatMain in an attempt to fix the Cypress tests.
The text was updated successfully, but these errors were encountered: