about summary refs log tree commit diff
path: root/src/state/models/navigation.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2022-12-08 15:34:22 -0600
committerPaul Frazee <pfrazee@gmail.com>2022-12-08 15:34:22 -0600
commite73c7cee3982b95ea0d323d2ddcdfa6145b8c3f6 (patch)
treed6718dba5f4510456a64bf5e91a366aad156231f /src/state/models/navigation.ts
parent53b8f0d040db703dd07a9432d10d2527ff46e3f1 (diff)
downloadvoidsky-e73c7cee3982b95ea0d323d2ddcdfa6145b8c3f6.tar.zst
Turn the main menu into a 'drawer' instead of a screen in the history
Diffstat (limited to 'src/state/models/navigation.ts')
-rw-r--r--src/state/models/navigation.ts30
1 files changed, 7 insertions, 23 deletions
diff --git a/src/state/models/navigation.ts b/src/state/models/navigation.ts
index 8ca44dc7f..8d69e5c04 100644
--- a/src/state/models/navigation.ts
+++ b/src/state/models/navigation.ts
@@ -12,7 +12,7 @@ function genId() {
 // until we're fully sure what that is, the tabs are being repurposed into a fixed topology
 // - Tab 0: The "Default" tab
 // - Tab 1: The "Notifications" tab
-// These tabs always retain the first 2 items in their history.
+// These tabs always retain the first item in their history.
 // The default tab is used for basically everything except notifications.
 // -prf
 export enum TabPurpose {
@@ -32,20 +32,14 @@ export type HistoryPtr = [number, number]
 export class NavigationTabModel {
   id = genId()
   history: HistoryItem[]
-  index = 1
+  index = 0
   isNewTab = false
 
   constructor(public fixedTabPurpose: TabPurpose) {
     if (fixedTabPurpose === TabPurpose.Notifs) {
-      this.history = [
-        {url: '/menu', ts: Date.now(), id: genId()},
-        {url: '/notifications', ts: Date.now(), id: genId()},
-      ]
+      this.history = [{url: '/notifications', ts: Date.now(), id: genId()}]
     } else {
-      this.history = [
-        {url: '/menu', ts: Date.now(), id: genId()},
-        {url: '/', ts: Date.now(), id: genId()},
-      ]
+      this.history = [{url: '/', ts: Date.now(), id: genId()}]
     }
     makeAutoObservable(this, {
       serialize: false,
@@ -85,7 +79,7 @@ export class NavigationTabModel {
 
   getForwardList(n: number) {
     const start = Math.min(this.index + 1, this.history.length)
-    const end = Math.min(this.index + n, this.history.length)
+    const end = Math.min(this.index + n + 1, this.history.length)
     return this.history.slice(start, end).map((item, i) => ({
       url: item.url,
       title: item.title,
@@ -109,7 +103,7 @@ export class NavigationTabModel {
         this.history.length = this.index + 1
       }
       // TEMP ensure the tab has its purpose's main view -prf
-      if (this.history.length < 2) {
+      if (this.history.length < 1) {
         const fixedUrl =
           this.fixedTabPurpose === TabPurpose.Notifs ? '/notifications' : '/'
         this.history.push({url: fixedUrl, ts: Date.now(), id: genId()})
@@ -142,17 +136,7 @@ export class NavigationTabModel {
   // a helper to bring the tab back to its base state
   // -prf
   fixedTabReset() {
-    if (this.index >= 1) {
-      // fall back in history to "main" view
-      if (this.index > 1) {
-        this.index = 1
-      }
-    } else {
-      const url =
-        this.fixedTabPurpose === TabPurpose.Notifs ? '/notifications' : '/'
-      this.history = [this.history[0], {url, ts: Date.now(), id: genId()}]
-      this.index = 1
-    }
+    this.index = 0
   }
 
   goForward() {