Skip to content

Commit 6ed37ba

Browse files
committed
fix: preserve filter URL for pointer links
1 parent 49cd9fc commit 6ed37ba

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

src/dashboard/Data/Views/Views.react.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { withRouter } from 'lib/withRouter';
1414
import subscribeTo from 'lib/subscribeTo';
1515
import { ActionTypes as SchemaActionTypes } from 'lib/stores/SchemaStore';
1616

17+
const BROWSER_LAST_LOCATION = 'brower_last_location';
18+
1719
export default
1820
@subscribeTo('Schema', 'schema')
1921
@withRouter
@@ -252,12 +254,29 @@ class Views extends TableView {
252254
const filters = JSON.stringify([
253255
{ field, constraint: 'eq', compareTo: id },
254256
]);
255-
this.props.navigate(
256-
generatePath(
257-
this.context,
258-
`browser/${className}?filters=${encodeURIComponent(filters)}`
259-
)
257+
const path = generatePath(
258+
this.context,
259+
`browser/${className}?filters=${encodeURIComponent(filters)}`
260260
);
261+
try {
262+
const existing = JSON.parse(
263+
window.localStorage.getItem(BROWSER_LAST_LOCATION)
264+
) || [];
265+
const updated = existing.filter(
266+
e => e.appId !== this.context.applicationId
267+
);
268+
updated.push({
269+
appId: this.context.applicationId,
270+
location: path,
271+
});
272+
window.localStorage.setItem(
273+
BROWSER_LAST_LOCATION,
274+
JSON.stringify(updated)
275+
);
276+
} catch {
277+
// ignore write errors
278+
}
279+
this.props.navigate(path);
261280
}
262281

263282
showNote(message, isError) {

0 commit comments

Comments
 (0)