Desktop: Fix frontend message response dispatch #3247
+24
−15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue:
When opening desktop app with auto saved documents menu bar would not update (export entry etc. disabled) until anything else triggered a menu bar update.
Debugging result:
After document select (triggered by document load) updated the menu another (outdated) menu bar update message arrived and put the menu bar in a outdated state.
The outdated message was send before Document load, but was handled after Document load.
Main issue was that desktop handles messages that are responses for frontend messages immediately. Therefore message execution order looked something like this on desktop:
Discovered that the editor handles frontend messages differently from other messages.
It requires all frontend messages to be fully processed before dispatching any resulting messages.
In the web frontend, this behavior happened implicitly because message dispatch is queued at the current end of the JavaScript execution queue.
For the desktop frontend, I added a vector to collect all responses until the entire batch of frontend messages is handled, and then dispatch them afterwards.
Also includes: