From cc396f085d5c706d8d2ddc26af5d551a2d5b9526 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Wed, 23 May 2018 14:17:05 +0200 Subject: Use history.state to decide whether we should goBack() or go to / (fixes #247) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So far, glitch-soc used history.length to decide whether to call `goBack()` or go to / in order to not leave the webUI. This made clicking the “Back” button go to the “Getting started” column instead of going back in the browser's history when such an action would leave the web UI, but also when: - The WebUI is refreshed (F5) - A tab is restored - The history length reaches its maximum (e.g., 50 in Firefox) This commit fixes these shortcomings by checking `window.history.state`. Indeed, we only want to go back in the browser's history when the current location has been reached from within the WebUI, which only happens via `pushState` as far as I know. Since browser store the serialized state in the browser history, this also survives page reload and session restoration. --- app/javascript/flavours/glitch/util/main.js | 5 ----- 1 file changed, 5 deletions(-) (limited to 'app/javascript/flavours/glitch/util') diff --git a/app/javascript/flavours/glitch/util/main.js b/app/javascript/flavours/glitch/util/main.js index c00210677..b76826481 100644 --- a/app/javascript/flavours/glitch/util/main.js +++ b/app/javascript/flavours/glitch/util/main.js @@ -28,11 +28,6 @@ function main() { store.dispatch(registerPushNotifications.register()); } perf.stop('main()'); - - // remember the initial URL - if (window.history && typeof window._mastoInitialHistoryLen === 'undefined') { - window._mastoInitialHistoryLen = window.history.length; - } }); } -- cgit