diff options
Diffstat (limited to 'src/view')
-rw-r--r-- | src/view/com/modals/ComposePost.tsx | 3 | ||||
-rw-r--r-- | src/view/com/notifications/FeedItem.tsx | 10 | ||||
-rw-r--r-- | src/view/com/post-thread/PostThreadItem.tsx | 19 | ||||
-rw-r--r-- | src/view/com/post/Post.tsx | 14 | ||||
-rw-r--r-- | src/view/com/posts/FeedItem.tsx | 16 | ||||
-rw-r--r-- | src/view/lib/strings.ts | 8 | ||||
-rw-r--r-- | src/view/routes.ts | 6 | ||||
-rw-r--r-- | src/view/screens/PostLikedBy.tsx | 4 | ||||
-rw-r--r-- | src/view/screens/PostRepostedBy.tsx | 4 | ||||
-rw-r--r-- | src/view/screens/PostThread.tsx | 4 |
10 files changed, 48 insertions, 40 deletions
diff --git a/src/view/com/modals/ComposePost.tsx b/src/view/com/modals/ComposePost.tsx index 6e634ed65..0032fbe7c 100644 --- a/src/view/com/modals/ComposePost.tsx +++ b/src/view/com/modals/ComposePost.tsx @@ -4,6 +4,7 @@ import {BottomSheetTextInput} from '@gorhom/bottom-sheet' import LinearGradient from 'react-native-linear-gradient' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import * as GetUserFollows from '../../../third-party/api/src/types/app/bsky/getUserFollows' +import * as Post from '../../../third-party/api/src/types/app/bsky/post' import {Autocomplete} from './composer/Autocomplete' import Toast from '../util/Toast' import ProgressCircle from '../util/ProgressCircle' @@ -20,7 +21,7 @@ export function Component({ replyTo, onPost, }: { - replyTo?: string + replyTo?: Post.PostRef onPost?: () => void }) { const store = useStores() diff --git a/src/view/com/notifications/FeedItem.tsx b/src/view/com/notifications/FeedItem.tsx index e76056067..c498dd607 100644 --- a/src/view/com/notifications/FeedItem.tsx +++ b/src/view/com/notifications/FeedItem.tsx @@ -1,7 +1,7 @@ import React, {useMemo} from 'react' import {observer} from 'mobx-react-lite' import {Image, StyleSheet, Text, View} from 'react-native' -import {AdxUri} from '../../../third-party/uri' +import {AtUri} from '../../../third-party/uri' import {FontAwesomeIcon, Props} from '@fortawesome/react-native-fontawesome' import {NotificationsViewItemModel} from '../../../state/models/notifications-view' import {s, colors} from '../../lib/styles' @@ -20,13 +20,13 @@ export const FeedItem = observer(function FeedItem({ }) { const itemHref = useMemo(() => { if (item.isLike || item.isRepost) { - const urip = new AdxUri(item.subjectUri) - return `/profile/${urip.host}/post/${urip.recordKey}` + const urip = new AtUri(item.subjectUri) + return `/profile/${urip.host}/post/${urip.rkey}` } else if (item.isFollow) { return `/profile/${item.author.name}` } else if (item.isReply) { - const urip = new AdxUri(item.uri) - return `/profile/${urip.host}/post/${urip.recordKey}` + const urip = new AtUri(item.uri) + return `/profile/${urip.host}/post/${urip.rkey}` } return '' }, [item]) diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index 6f84aff10..e8fdd91af 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -2,7 +2,7 @@ import React, {useMemo} from 'react' import {observer} from 'mobx-react-lite' import {Image, StyleSheet, Text, TouchableOpacity, View} from 'react-native' import Svg, {Line} from 'react-native-svg' -import {AdxUri} from '../../../third-party/uri' +import {AtUri} from '../../../third-party/uri' import * as PostType from '../../../third-party/api/src/types/app/bsky/post' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {PostThreadViewPostModel} from '../../../state/models/post-thread-view' @@ -31,26 +31,29 @@ export const PostThreadItem = observer(function PostThreadItem({ const hasEngagement = item.likeCount || item.repostCount const itemHref = useMemo(() => { - const urip = new AdxUri(item.uri) - return `/profile/${item.author.name}/post/${urip.recordKey}` + const urip = new AtUri(item.uri) + return `/profile/${item.author.name}/post/${urip.rkey}` }, [item.uri, item.author.name]) const itemTitle = `Post by ${item.author.name}` const authorHref = `/profile/${item.author.name}` const authorTitle = item.author.name const likesHref = useMemo(() => { - const urip = new AdxUri(item.uri) - return `/profile/${item.author.name}/post/${urip.recordKey}/liked-by` + const urip = new AtUri(item.uri) + return `/profile/${item.author.name}/post/${urip.rkey}/liked-by` }, [item.uri, item.author.name]) const likesTitle = 'Likes on this post' const repostsHref = useMemo(() => { - const urip = new AdxUri(item.uri) - return `/profile/${item.author.name}/post/${urip.recordKey}/reposted-by` + const urip = new AtUri(item.uri) + return `/profile/${item.author.name}/post/${urip.rkey}/reposted-by` }, [item.uri, item.author.name]) const repostsTitle = 'Reposts of this post' const onPressReply = () => { store.shell.openModal( - new ComposePostModel({replyTo: item.uri, onPost: onPostReply}), + new ComposePostModel({ + replyTo: {uri: item.uri, cid: item.cid}, + onPost: onPostReply, + }), ) } const onPressToggleRepost = () => { diff --git a/src/view/com/post/Post.tsx b/src/view/com/post/Post.tsx index 04cc5cdd6..42611a39a 100644 --- a/src/view/com/post/Post.tsx +++ b/src/view/com/post/Post.tsx @@ -1,6 +1,6 @@ import React, {useState, useEffect, useMemo} from 'react' import {observer} from 'mobx-react-lite' -import {AdxUri} from '../../../third-party/uri' +import {AtUri} from '../../../third-party/uri' import * as PostType from '../../../third-party/api/src/types/app/bsky/post' import { ActivityIndicator, @@ -59,20 +59,22 @@ export const Post = observer(function Post({uri}: {uri: string}) { const item = view.thread const record = view.thread?.record as unknown as PostType.Record - const itemUrip = new AdxUri(item.uri) - const itemHref = `/profile/${item.author.name}/post/${itemUrip.recordKey}` + const itemUrip = new AtUri(item.uri) + const itemHref = `/profile/${item.author.name}/post/${itemUrip.rkey}` const itemTitle = `Post by ${item.author.name}` const authorHref = `/profile/${item.author.name}` const authorTitle = item.author.name let replyAuthorDid = '' let replyHref = '' if (record.reply) { - const urip = new AdxUri(record.reply.parent || record.reply.root) + const urip = new AtUri(record.reply.parent?.uri || record.reply.root.uri) replyAuthorDid = urip.hostname - replyHref = `/profile/${urip.hostname}/post/${urip.recordKey}` + replyHref = `/profile/${urip.hostname}/post/${urip.rkey}` } const onPressReply = () => { - store.shell.openModal(new ComposePostModel({replyTo: item.uri})) + store.shell.openModal( + new ComposePostModel({replyTo: {uri: item.uri, cid: item.cid}}), + ) } const onPressToggleRepost = () => { item diff --git a/src/view/com/posts/FeedItem.tsx b/src/view/com/posts/FeedItem.tsx index 9bb94ad05..6eb2b38fb 100644 --- a/src/view/com/posts/FeedItem.tsx +++ b/src/view/com/posts/FeedItem.tsx @@ -1,7 +1,7 @@ import React, {useMemo} from 'react' import {observer} from 'mobx-react-lite' import {Image, StyleSheet, Text, TouchableOpacity, View} from 'react-native' -import {AdxUri} from '../../../third-party/uri' +import {AtUri} from '../../../third-party/uri' import * as PostType from '../../../third-party/api/src/types/app/bsky/post' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {FeedViewItemModel} from '../../../state/models/feed-view' @@ -23,24 +23,26 @@ export const FeedItem = observer(function FeedItem({ const store = useStores() const record = item.record as unknown as PostType.Record const itemHref = useMemo(() => { - const urip = new AdxUri(item.uri) - return `/profile/${item.author.name}/post/${urip.recordKey}` + const urip = new AtUri(item.uri) + return `/profile/${item.author.name}/post/${urip.rkey}` }, [item.uri, item.author.name]) const itemTitle = `Post by ${item.author.name}` const authorHref = `/profile/${item.author.name}` const replyAuthorDid = useMemo(() => { if (!record.reply) return '' - const urip = new AdxUri(record.reply.parent || record.reply.root) + const urip = new AtUri(record.reply.parent?.uri || record.reply.root.uri) return urip.hostname }, [record.reply]) const replyHref = useMemo(() => { if (!record.reply) return '' - const urip = new AdxUri(record.reply.parent || record.reply.root) - return `/profile/${urip.hostname}/post/${urip.recordKey}` + const urip = new AtUri(record.reply.parent?.uri || record.reply.root.uri) + return `/profile/${urip.hostname}/post/${urip.rkey}` }, [record.reply]) const onPressReply = () => { - store.shell.openModal(new ComposePostModel({replyTo: item.uri})) + store.shell.openModal( + new ComposePostModel({replyTo: {uri: item.uri, cid: item.cid}}), + ) } const onPressToggleRepost = () => { item diff --git a/src/view/lib/strings.ts b/src/view/lib/strings.ts index 89764546b..b30a3c08b 100644 --- a/src/view/lib/strings.ts +++ b/src/view/lib/strings.ts @@ -1,4 +1,4 @@ -import {AdxUri} from '../../third-party/uri' +import {AtUri} from '../../third-party/uri' import {Entity as Entities} from '../../third-party/api/src/types/app/bsky/post' type Entity = Entities[0] @@ -16,12 +16,12 @@ export function pluralize(n: number, base: string, plural?: string): string { export function makeRecordUri( didOrName: string, collection: string, - recordKey: string, + rkey: string, ) { - const urip = new AdxUri(`adx://host/`) + const urip = new AtUri(`at://host/`) urip.host = didOrName urip.collection = collection - urip.recordKey = recordKey + urip.rkey = rkey return urip.toString() } diff --git a/src/view/routes.ts b/src/view/routes.ts index d75280d14..d458813ec 100644 --- a/src/view/routes.ts +++ b/src/view/routes.ts @@ -39,17 +39,17 @@ export const routes: Route[] = [ [ PostThread, ['far', 'message'], - r('/profile/(?<name>[^/]+)/post/(?<recordKey>[^/]+)'), + r('/profile/(?<name>[^/]+)/post/(?<rkey>[^/]+)'), ], [ PostLikedBy, 'heart', - r('/profile/(?<name>[^/]+)/post/(?<recordKey>[^/]+)/liked-by'), + r('/profile/(?<name>[^/]+)/post/(?<rkey>[^/]+)/liked-by'), ], [ PostRepostedBy, 'retweet', - r('/profile/(?<name>[^/]+)/post/(?<recordKey>[^/]+)/reposted-by'), + r('/profile/(?<name>[^/]+)/post/(?<rkey>[^/]+)/reposted-by'), ], ] diff --git a/src/view/screens/PostLikedBy.tsx b/src/view/screens/PostLikedBy.tsx index 8ec0ca5a5..75eeea4a9 100644 --- a/src/view/screens/PostLikedBy.tsx +++ b/src/view/screens/PostLikedBy.tsx @@ -6,8 +6,8 @@ import {useStores} from '../../state' export const PostLikedBy = ({visible, params}: ScreenParams) => { const store = useStores() - const {name, recordKey} = params - const uri = makeRecordUri(name, 'app.bsky.post', recordKey) + const {name, rkey} = params + const uri = makeRecordUri(name, 'app.bsky.post', rkey) useEffect(() => { if (visible) { diff --git a/src/view/screens/PostRepostedBy.tsx b/src/view/screens/PostRepostedBy.tsx index 6cc84809d..875cc978c 100644 --- a/src/view/screens/PostRepostedBy.tsx +++ b/src/view/screens/PostRepostedBy.tsx @@ -6,8 +6,8 @@ import {useStores} from '../../state' export const PostRepostedBy = ({visible, params}: ScreenParams) => { const store = useStores() - const {name, recordKey} = params - const uri = makeRecordUri(name, 'app.bsky.post', recordKey) + const {name, rkey} = params + const uri = makeRecordUri(name, 'app.bsky.post', rkey) useEffect(() => { if (visible) { diff --git a/src/view/screens/PostThread.tsx b/src/view/screens/PostThread.tsx index 2c66e5e38..1f2deb312 100644 --- a/src/view/screens/PostThread.tsx +++ b/src/view/screens/PostThread.tsx @@ -6,8 +6,8 @@ import {useStores} from '../../state' export const PostThread = ({visible, params}: ScreenParams) => { const store = useStores() - const {name, recordKey} = params - const uri = makeRecordUri(name, 'app.bsky.post', recordKey) + const {name, rkey} = params + const uri = makeRecordUri(name, 'app.bsky.post', rkey) useEffect(() => { if (visible) { |