mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-24 05:05:20 -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.loadAds();
|
||||||
this.loadGTM();
|
this.loadGTM();
|
||||||
|
|
||||||
|
let needsRefresh = false;
|
||||||
const bc = new BroadcastChannel('account_switch');
|
const bc = new BroadcastChannel('account_switch');
|
||||||
bc.onmessage = (ev) => {
|
bc.onmessage = (ev) => {
|
||||||
if (ev.data !== this.$user()?.username) {
|
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();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user