about summary refs log tree commit diff
path: root/src/state/models/lists
diff options
context:
space:
mode:
authorFoysal Ahamed <foysal@blueskyweb.xyz>2023-07-28 18:04:27 +0200
committerGitHub <noreply@github.com>2023-07-28 11:04:27 -0500
commiteec300d77241925e6b42e5e7e51894f2cba50e18 (patch)
tree0fb74f898687a6331cba3a3f0cffe3354596f4ab /src/state/models/lists
parent38d78e16bffc9a25a45a4ad41caeef2c075daa26 (diff)
downloadvoidsky-eec300d77241925e6b42e5e7e51894f2cba50e18.tar.zst
List cleanup on remove (#1069)
* :lipstick: Hide Add to List option on own profile

* :sparkles: Remove Lists tab when last list is removed

* :sparkles: Add listener to list delete on profile screen

* :sparkles: Only show save changes in list modal when changes are made
Diffstat (limited to 'src/state/models/lists')
-rw-r--r--src/state/models/lists/lists-list.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/state/models/lists/lists-list.ts b/src/state/models/lists/lists-list.ts
index 6618c3bf6..54e2f5fde 100644
--- a/src/state/models/lists/lists-list.ts
+++ b/src/state/models/lists/lists-list.ts
@@ -48,9 +48,24 @@ export class ListsListModel {
     return this.hasLoaded && !this.hasContent
   }
 
+  /**
+   * Removes posts from the feed upon deletion.
+   */
+  onListDeleted(uri: string) {
+    this.lists = this.lists.filter(l => l.uri !== uri)
+  }
+
   // public api
   // =
 
+  /**
+   * Register any event listeners. Returns a cleanup function.
+   */
+  registerListeners() {
+    const sub = this.rootStore.onListDeleted(this.onListDeleted.bind(this))
+    return () => sub.remove()
+  }
+
   async refresh() {
     return this.loadMore(true)
   }