From 9c0098b13067d0eeebf3150de3d0ab48b2b422ee Mon Sep 17 00:00:00 2001 From: Ashish Baravaliya Date: Mon, 19 Jun 2023 14:58:35 -0400 Subject: [PATCH] feat: saving last location of browser --- src/dashboard/Data/Browser/Browser.react.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/dashboard/Data/Browser/Browser.react.js b/src/dashboard/Data/Browser/Browser.react.js index 09bacbca65..a99cac7c18 100644 --- a/src/dashboard/Data/Browser/Browser.react.js +++ b/src/dashboard/Data/Browser/Browser.react.js @@ -42,6 +42,7 @@ import { withRouter } from 'lib/withRouter'; // The initial and max amount of rows fetched by lazy loading const MAX_ROWS_FETCHED = 200; +const BROWSER_LAST_LOCATION = 'brower_last_location'; @subscribeTo('Schema', 'schema') @withRouter @@ -178,6 +179,22 @@ class Browser extends DashboardView { } } + componentDidMount() { + if (window.localStorage) { + const pathname = window.localStorage.getItem(BROWSER_LAST_LOCATION); + window.localStorage.removeItem(BROWSER_LAST_LOCATION) + if(pathname) { + setTimeout(function() { this.props.navigate(pathname) }.bind(this)) + } + } + } + + componentWillUnmount() { + if (window.localStorage) { + window.localStorage.setItem(BROWSER_LAST_LOCATION, this.props.location.pathname + this.props.location.search); + } + } + componentWillReceiveProps(nextProps, nextContext) { if (this.props.params.appId !== nextProps.params.appId || this.props.params.className !== nextProps.params.className || this.props.location.search !== nextProps.location.search || this.props.params?.relationName !== nextProps.params?.relationName) { if (this.props.params.appId !== nextProps.params.appId || !this.props.params.className) {