From d0987719ce76ac8d8174d81cc93463aee7a6f394 Mon Sep 17 00:00:00 2001 From: Alistair McKinlay Date: Mon, 24 Apr 2017 12:20:48 +0100 Subject: [PATCH] Replace the state on init rather than adding a new entry Fixes #1042 --- client/js/lounge.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client/js/lounge.js b/client/js/lounge.js index 40a52b34..e9b78f2f 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -132,7 +132,9 @@ $(function() { $("#sign-in").remove(); var id = data.active; - var target = sidebar.find("[data-id='" + id + "']").trigger("click"); + var target = sidebar.find("[data-id='" + id + "']").trigger("click", { + replaceHistory: true + }); if (target.length === 0) { var first = sidebar.find(".chan") .eq(0) @@ -820,7 +822,11 @@ $(function() { } if (history && history.pushState) { - history.pushState(state, null, null); + if (data && data.replaceHistory && history.replaceState) { + history.replaceState(state, null, null); + } else { + history.pushState(state, null, null); + } } });