-
Notifications
You must be signed in to change notification settings - Fork 13
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
Persist state of lock store between tabs #531
base: main
Are you sure you want to change the base?
Conversation
Your demo site is ready! 🚀 Visit it here: https://ramp4-pcar4.github.io/storylines-editor/issue-520 |
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.
I think we don't need the BrodcastChannel
in the refresh case because we treat that as a "user loaded preview independently" of the main tab and hence it should not track activity in the main editor tab.
However, this does reopen the case of the language switch and what to do there.
One option to really simplify things is to remove the activity tracker in the preview tab. While this makes it somewhat inconvenient if a user times out while they're looking at their glorious preview, because we now autosave on timeout, they'd just have to lock the storyline again and they'd be able to continue.
Another option is to investigate what causes the toast to trigger when switching languages and stop it there.
Yet a third option is to overrule the idea of a refresh being a new load, and also track activity there, in which case your code is perfect.
Will tag on the meeting topic to this one and see what people think.
Reviewed 7 of 7 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @IshavSohal)
src/components/metadata-editor.vue
line 840 at r1 (raw file):
const msg = e.data; if (msg.action === 'extend') { console.log('metadata - received extend message from preview');
Blocker for console logs before merging
src/components/preview.vue
line 207 at r1 (raw file):
} // This broadcast channel will be used to communicate regarding sessions with the main editor tab
So if we put this code block here, it'll also trigger a broadcast channel in the case that someone loads the preview page independently (i.e. without the main editor tab) and in that case there are no sessions to extend or handle.
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.
I think we don't need the
BroadcastChannel
in the refresh case because we treat that as a "user loaded preview independently" of the main tab and hence it should not track activity in the main editor tab.
Ah I see now, considered a refresh as an independent load makes sense. If we want to keep this the way it is, I can move the BroadcastChannel back to the window.props
case. Also, we won't need the plugin anymore, since we can just pass the secret to the window in changeLang()
.
Another option is to investigate what causes the toast to trigger when switching languages and stop it there.
The reason why the Session Extended
toast appears on mouse move is because, upon switching languages, window.props
doesn't contain the secret
(see the changeLang()
method). So, the name provided for the BroadcastChannel defined in the preview
(undefined
) would be different from the name of the one defined in the lockStore
, and thus would not be connected to one another.
In addition, BroadcastChannels defined in the preview
are not being closed upon a lang change. So, once two lang changes occur, there will be two BroadcastChannels with a name of undefined
, and these begin to communicate with each other.
We can fix the toast issue by closing the BroadcastChannel in changeLang()
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @IshavSohal)
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.
Ah I see, either removing the toast or making the channel persist on language change seem like good suggestions. I'm in favour of the latter as a user I would still want my session to persist if I'm just previewing the other language.
Having said all of that, I still think its worth holding off on implementing anything now and instead discussing below/in the next meeting whether to remove the broadcasts/activity tracking in the preview tab as it simplifies the code greatly and only takes away what is a very niche benefit. If people are in favour of keeping the activity tracking, then we should probably keep hagglin' on what makes sense to do in a language change.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @IshavSohal)
Related Item(s)
#520
Changes
Notes
window.props
is not defined (which occurs upon reloading the tab), the BroadcastChannel was not being created. Was this intentional? Currently I'm creating the BroadcastChannel in both cases (hence the plugin), but I can revert this if necessaryTesting
Steps:
This change is