diff --git a/layouts/default.vue b/layouts/default.vue index 8efcc2ffb..c5947475f 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -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(); } }