Make chat_app refresh its prepopulated UI messages on reload #71
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.
Before this commit:
chat_app(client)(orellmer::live_browser(client), which passes through tochat_app)The discussion you have disappears, but the state is still present in the client--the UI and server state have gotten out of sync.
If you Ctrl+C out of the app, and then call
chat_app(client)again, the existing messages are now displayed. But if you talk more, and then hit Reload, you'll be reverted back to the UI state that was correct at the timechat_app(client)was most recently called.This is fixed by calling
chat_uiat page load time, not atchat_app()invocation time.(Note that it's unsafe to use a
chat_app()from multiple browser windows simultaneously, since every chat will mutate the same client object. Might be worth putting in a tiny bit of code that closes existing sessions when a new session arrives.)