about summary refs log tree commit diff
path: root/src/state/models/content/list.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-07-27 10:50:12 -0500
committerGitHub <noreply@github.com>2023-07-27 10:50:12 -0500
commit49356700c31a1cb34c252e3aecf18561114916b9 (patch)
tree60361702f37480e9af1b830030d8c283321e8775 /src/state/models/content/list.ts
parent5a0899b989769dc3417096ae2d040cd768f4524c (diff)
downloadvoidsky-49356700c31a1cb34c252e3aecf18561114916b9.tar.zst
[APP-782] Support invalid handles correctly (#1049)
* Update profile link construction to support handle.invalid

* Update list links  to support using handles

* Use did for isMe check to ensure invalid handles dont distort the check

* Shift the red (error) colors away from the pink spectrum

* Add ThemedText helper component

* Add sanitizedHandle() helper to render invalid handles well

* Fix regression: only show avatar in PostMeta when needed

* Restore the color of likes

* Remove users with invalid handles from default autosuggests
Diffstat (limited to 'src/state/models/content/list.ts')
-rw-r--r--src/state/models/content/list.ts23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/state/models/content/list.ts b/src/state/models/content/list.ts
index d5c9e649e..c5ac72e49 100644
--- a/src/state/models/content/list.ts
+++ b/src/state/models/content/list.ts
@@ -1,4 +1,4 @@
-import {makeAutoObservable} from 'mobx'
+import {makeAutoObservable, runInAction} from 'mobx'
 import {
   AtUri,
   AppBskyGraphGetList as GetList,
@@ -115,6 +115,7 @@ export class ListModel {
     }
     this._xLoading(replace)
     try {
+      await this._resolveUri()
       const res = await this.rootStore.agent.app.bsky.graph.getList({
         list: this.uri,
         limit: PAGE_SIZE,
@@ -146,6 +147,7 @@ export class ListModel {
     if (!this.isOwner) {
       throw new Error('Cannot edit this list')
     }
+    await this._resolveUri()
 
     // get the current record
     const {rkey} = new AtUri(this.uri)
@@ -179,6 +181,7 @@ export class ListModel {
     if (!this.list) {
       return
     }
+    await this._resolveUri()
 
     // fetch all the listitem records that belong to this list
     let cursor
@@ -220,6 +223,7 @@ export class ListModel {
     if (!this.list) {
       return
     }
+    await this._resolveUri()
     await this.rootStore.agent.app.bsky.graph.muteActorList({
       list: this.list.uri,
     })
@@ -231,6 +235,7 @@ export class ListModel {
     if (!this.list) {
       return
     }
+    await this._resolveUri()
     await this.rootStore.agent.app.bsky.graph.unmuteActorList({
       list: this.list.uri,
     })
@@ -273,6 +278,22 @@ export class ListModel {
   // helper functions
   // =
 
+  async _resolveUri() {
+    const urip = new AtUri(this.uri)
+    if (!urip.host.startsWith('did:')) {
+      try {
+        urip.host = await apilib.resolveName(this.rootStore, urip.host)
+      } catch (e: any) {
+        runInAction(() => {
+          this.error = e.toString()
+        })
+      }
+    }
+    runInAction(() => {
+      this.uri = urip.toString()
+    })
+  }
+
   _replaceAll(res: GetList.Response) {
     this.items = []
     this._appendAll(res)