-
Notifications
You must be signed in to change notification settings - Fork 4
fix: Save channel_name to localStorage from URL parameters #86
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -40,7 +40,11 @@ function loadSettings() { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| const storedChannel = urlParams.get('channel_name') || localStorage.getItem('channel_name'); | ||||||
| const urlChannel = urlParams.get('channel_name'); | ||||||
| if (urlChannel) { | ||||||
| localStorage.setItem('channel_name', urlChannel); | ||||||
| } | ||||||
| const storedChannel = urlChannel || localStorage.getItem('channel_name'); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While the logic is correct, this line is a bit redundant. Since you've just updated
Suggested change
|
||||||
| const storedRestartTime = urlParams.get('restart_time') || localStorage.getItem('restart_time'); | ||||||
| const storedAvatarInput = urlParams.get('win_avatar_enable') || localStorage.getItem('win_avatar_enable'); | ||||||
| const storedSoundInput = urlParams.get('sound_enable') || localStorage.getItem('sound_enable'); | ||||||
|
|
||||||
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.
Persisting
channel_namedirectly from query params stores malformed values (for example%20fooor trailing spaces) intolocalStorage, andloadSettings()then treats that value as ready on future visits, which can repeatedly initialize chat with an invalid channel even when the bad URL is no longer present. This regression is introduced by the new persistence path; unlike the manual save flow, this branch does not trim/normalize before saving.Useful? React with 👍 / 👎.