mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 01:15:28 +00:00
feat: handle discover last path properly
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user