mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-22 20:24:18 -04:00
account switch – only refresh other tabs when focused
This commit is contained in:
parent
1a207284f6
commit
f86a40a4f8
@ -104,9 +104,20 @@
|
||||
this.loadAds();
|
||||
this.loadGTM();
|
||||
|
||||
let needsRefresh = false;
|
||||
const bc = new BroadcastChannel('account_switch');
|
||||
bc.onmessage = (ev) => {
|
||||
if (ev.data !== this.$user()?.username) {
|
||||
needsRefresh = true;
|
||||
if (document.hasFocus()) {
|
||||
needsRefresh = false;
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
window.onfocus = () => {
|
||||
if (needsRefresh) {
|
||||
needsRefresh = false;
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user