feat: handle discover last path properly

This commit is contained in:
Paul Makles
2022-01-10 18:43:27 +00:00
parent 1d26beee10
commit 450b404ec5
2 changed files with 24 additions and 8 deletions

View File

@@ -34,6 +34,11 @@ export default class Layout implements Store, Persistent<Data> {
*/
private lastHomePath: string;
/**
* Volatile last discover path.
*/
private lastDiscoverPath: string;
/**
* Map of last channels viewed in servers.
*/
@@ -50,6 +55,7 @@ export default class Layout implements Store, Persistent<Data> {
constructor() {
this.lastSection = "home";
this.lastHomePath = "/";
this.lastDiscoverPath = "/discover/servers";
this.lastOpened = new ObservableMap();
this.openSections = new ObservableMap();
makeAutoObservable(this);
@@ -144,9 +150,9 @@ export default class Layout implements Store, Persistent<Data> {
*/
@computed getLastPath() {
return this.lastSection === "discover"
? "/discover"
? this.lastDiscoverPath
: this.lastSection === "home"
? this.lastHomePath!
? this.lastHomePath
: this.getLastOpened(this.lastSection)!;
}
@@ -167,6 +173,15 @@ export default class Layout implements Store, Persistent<Data> {
this.lastSection = "home";
}
/**
* Set the last discover path.
* @param path Pathname
*/
@action setLastDiscoverPath(path: string) {
this.lastDiscoverPath = path;
this.lastSection = "discover";
}
/**
*
* @param id Section ID