From 71b8ab9b689d248ff5fe0b4baefc7011a0cd7161 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 15 Jan 2020 09:57:30 +0100 Subject: [PATCH] JS: Introuce Icinga.History.replaceCurrentState() Before, we only had pushCurrentState() to add a new URL to the history stack. But some actions, e.g. "load more" in history views require to replace the current state instead of pushing. This is what replaceCurrentState() supports now. --- public/js/icinga/history.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/public/js/icinga/history.js b/public/js/icinga/history.js index 0e17c46a3..30dd7d835 100644 --- a/public/js/icinga/history.js +++ b/public/js/icinga/history.js @@ -114,6 +114,26 @@ } }, + /** + * Replace the current history entry with the current state + */ + replaceCurrentState: function () { + if (! this.enabled) { + return; + } + + var state = this.getCurrentState(); + + if (state.url) { + this.icinga.logger.debug('Replacing current history state'); + window.history.replaceState( + this.getBehaviorState(), + null, + state.url + ); + } + }, + /** * Push the given url as the new history state, unless the history is disabled *