From 2e352f383ec50cb45f39ed7b53c85fb6ea991bda Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Mon, 26 Sep 2022 13:38:37 -0500 Subject: [PATCH] A few client fixes --- src/state/models/notifications-view.ts | 10 ++++------ src/state/models/root-store.ts | 16 ++++++++++------ src/view/screens/PostLikedBy.tsx | 2 +- src/view/screens/PostRepostedBy.tsx | 2 +- src/view/screens/PostThread.tsx | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/state/models/notifications-view.ts b/src/state/models/notifications-view.ts index dc372ab5..0ee5fd81 100644 --- a/src/state/models/notifications-view.ts +++ b/src/state/models/notifications-view.ts @@ -40,29 +40,27 @@ export class NotificationsViewItemModel get isLike() { return ( - hasProp(this.record, '$type') && - this.record.$type === 'blueskyweb.xyz:Like' + hasProp(this.record, '$type') && this.record.$type === 'todo.social.like' ) } get isRepost() { return ( hasProp(this.record, '$type') && - this.record.$type === 'blueskyweb.xyz:Repost' + this.record.$type === 'todo.social.repost' ) } get isReply() { return ( - hasProp(this.record, '$type') && - this.record.$type === 'blueskyweb.xyz:Post' + hasProp(this.record, '$type') && this.record.$type === 'todo.social.post' ) } get isFollow() { return ( hasProp(this.record, '$type') && - this.record.$type === 'blueskyweb.xyz:Follow' + this.record.$type === 'todo.social.follow' ) } diff --git a/src/state/models/root-store.ts b/src/state/models/root-store.ts index adbcb238..ea3da185 100644 --- a/src/state/models/root-store.ts +++ b/src/state/models/root-store.ts @@ -3,7 +3,8 @@ */ import {makeAutoObservable} from 'mobx' -import AdxApi, {ServiceClient} from '../../third-party/api' +import AdxApi from '../../third-party/api' +import {ServiceClient} from '../../third-party/api/src/index' import {createContext, useContext} from 'react' import {isObj, hasProp} from '../lib/type-guards' import {SessionModel} from './session' @@ -27,11 +28,14 @@ export class RootStoreModel { } async resolveName(didOrName: string) { - throw new Error('TODO') - return '' - // const userDb = this.api.mockDb.getUser(didOrName) - // if (!userDb) throw new Error(`User not found: ${didOrName}`) - // return userDb.did + if (!didOrName) { + throw new Error('Invalid name: ""') + } + if (didOrName.startsWith('did:')) { + return didOrName + } + const res = await this.api.todo.adx.resolveName({name: didOrName}) + return res.data.did } serialize(): unknown { diff --git a/src/view/screens/PostLikedBy.tsx b/src/view/screens/PostLikedBy.tsx index 54038276..003859b8 100644 --- a/src/view/screens/PostLikedBy.tsx +++ b/src/view/screens/PostLikedBy.tsx @@ -7,7 +7,7 @@ import {useStores} from '../../state' export const PostLikedBy = ({visible, params}: ScreenParams) => { const store = useStores() const {name, recordKey} = params - const uri = makeRecordUri(name, 'blueskyweb.xyz:Posts', recordKey) + const uri = makeRecordUri(name, 'todo.social.post', recordKey) useEffect(() => { if (visible) { diff --git a/src/view/screens/PostRepostedBy.tsx b/src/view/screens/PostRepostedBy.tsx index 60950139..e8f0f772 100644 --- a/src/view/screens/PostRepostedBy.tsx +++ b/src/view/screens/PostRepostedBy.tsx @@ -7,7 +7,7 @@ import {useStores} from '../../state' export const PostRepostedBy = ({visible, params}: ScreenParams) => { const store = useStores() const {name, recordKey} = params - const uri = makeRecordUri(name, 'blueskyweb.xyz:Posts', recordKey) + const uri = makeRecordUri(name, 'todo.social.post', recordKey) useEffect(() => { if (visible) { diff --git a/src/view/screens/PostThread.tsx b/src/view/screens/PostThread.tsx index 8da40302..819bf487 100644 --- a/src/view/screens/PostThread.tsx +++ b/src/view/screens/PostThread.tsx @@ -7,7 +7,7 @@ import {useStores} from '../../state' export const PostThread = ({visible, params}: ScreenParams) => { const store = useStores() const {name, recordKey} = params - const uri = makeRecordUri(name, 'blueskyweb.xyz:Posts', recordKey) + const uri = makeRecordUri(name, 'todo.social.post', recordKey) useEffect(() => { if (visible) {