From f86a40a4f825a37d0f65acf8e632021ceffc4b4b Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Mon, 10 Jul 2023 19:17:26 +0200 Subject: [PATCH] =?UTF-8?q?account=20switch=20=E2=80=93=20only=20refresh?= =?UTF-8?q?=20other=20tabs=20when=20focused?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/default.vue | 11 +++++++++++ 1 file changed, 11 insertions(+) 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(); } }