This repository was archived by the owner on Jun 30, 2022. It is now read-only.
Reset hook to clear internal state and go back to a first loaded state#628
Open
hanoii wants to merge 2 commits intoRocketChat:developfrom
Open
Reset hook to clear internal state and go back to a first loaded state#628hanoii wants to merge 2 commits intoRocketChat:developfrom
hanoii wants to merge 2 commits intoRocketChat:developfrom
Conversation
It was hard to really reset state, so I am simply clearing the localstorage and redirecting the iframe. Also provide a way to reset it on initialization through a querystring
Contributor
Author
|
now that #640 got merged I wonder if this one can also be looked at? |
murtaza98
reviewed
Dec 13, 2021
| } | ||
|
|
||
| this._state = { ...initialState, ...storedState }; | ||
| this._initialState = initialState; |
Contributor
There was a problem hiding this comment.
Any reason for this new variable assignment?
Contributor
|
Hi @hanoii Thanks for the contribution 😄 We recently introduced a similar feature that automatically resets the local storage when a chat gets closed #666. There instead of clearing the local storage (which you're proposing to do on the reset() method), we instead create a new visitor. So I was wondering if we could do something similar here as well... WDYT? |
murtaza98
reviewed
Dec 13, 2021
|
|
||
| window.addEventListener('visibilitychange', () => { | ||
| !this._state.minimized && !this._state.triggered && parentCall('openWidget'); | ||
| !this._state.minimized && parentCall('openWidget'); |
Contributor
There was a problem hiding this comment.
Sorry I didn't get this change. Why are we not checking for the triggered property now? Could you please elaborate on the logic here?
Contributor
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This attempts to add support for #625.
This one was rather hard, as resetting it when the page was loaded caused a lot of different issues, so I provide two ways fo resetting the state, a query string so that it. can be reset that takes an approach of redirecting so everything is loaded again. Depending on the usecase both will work but the latter might have an undesired flicker, that's why I added the query string way.
Fixes #625