From c49730c1e051b4a4ab0f547eacd66ed88e962560 Mon Sep 17 00:00:00 2001 From: Manoj Vivek Date: Sat, 30 May 2020 11:24:16 +0530 Subject: [PATCH] Prevent reloading for same page URL hash change, Fixes #100 --- desktop-app/app/actions/browser.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/desktop-app/app/actions/browser.js b/desktop-app/app/actions/browser.js index 76445878..d638e669 100644 --- a/desktop-app/app/actions/browser.js +++ b/desktop-app/app/actions/browser.js @@ -116,10 +116,28 @@ export function onAddressChange(newURL, force) { return; } + const isHashDiff = isHashOnlyChange(newURL, address); + + if (isHashDiff) { + return; + } + dispatch(newAddress(newURL)); }; } +function isHashOnlyChange(newURL, oldURL) { + if (!newURL || !oldURL) { + return false; + } + let diff = newURL.replace(oldURL, '').trim(); + if (diff.startsWith('/')) { + diff = diff.substring(1); + } + + return diff.startsWith('#'); +} + export function onZoomChange(newLevel) { return (dispatch: Dispatch, getState: RootStateType) => { const {