-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix unreasonable room user information status #27
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refresh action can send event
beforeunload
Why separate refresh and termination?
unload
event is Deprecated https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_eventThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see carefully.
Based on my testing results in the development mode on my local machine: The
beforeunload
event is sufficient for Chrome , meaning there's no need to add a keepalive request. However, Firefox behaves differently. When refreshing the page, it doesn't trigger the callback function of the beforeunload event, and when closing the window, it doesn't trigger the 'unload
' event. That's why I'm using both of them here.unload
event is Deprecated, but still work in Firefox.Most importantly, I tried the
keepalive
solution, but it seemed ineffective.By the way, I found these introductions to
beforeunload
on MDN Web Docs, and I think it may be related to Woom's SPA design.https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
So, in a word: Perhaps this is the simplest way to solve this problem:
or we can change
delStream()
by usingnavigator.sendBeacon
maybe? how do u think?Looking forward to your opinion.
The 'beforeunload' is used to perform callback BEFORE the page is unloaded, but it can prevent some asynchronous operations (like network requests) from completing within the event. This is why DELETE requests sometimes show as "canceled" in the console. That's why using the 'unload' event allows the request to trigger AFTER the interface is unloaded (or refreshed).
When close a browser window, the browser doesn't immediately interrupt all activities. Instead, it tries to complete asynchronous operations (like sending network requests) before the window is closed. That's why the 'beforeunload' event works when close the window.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OS: MacOS 15.1 (24B83) (M3 Pro)
Chrome: 130.0.6723.70
Friefox: 132.0.2 (aarch64)
Safari: 18.1 (20619.2.8.11.10)
beforeunload
unload
beforeunload
+keepalive
unload
+keepalive