diff options
Diffstat (limited to 'src/state/queries')
-rw-r--r-- | src/state/queries/notifications/types.ts | 2 | ||||
-rw-r--r-- | src/state/queries/notifications/util.ts | 11 | ||||
-rw-r--r-- | src/state/queries/post.ts | 22 |
3 files changed, 24 insertions, 11 deletions
diff --git a/src/state/queries/notifications/types.ts b/src/state/queries/notifications/types.ts index b3a972394..e05715f77 100644 --- a/src/state/queries/notifications/types.ts +++ b/src/state/queries/notifications/types.ts @@ -46,6 +46,8 @@ type OtherNotificationType = | 'feedgen-like' | 'verified' | 'unverified' + | 'like-via-repost' + | 'repost-via-repost' | 'unknown' type FeedNotificationBase = { diff --git a/src/state/queries/notifications/util.ts b/src/state/queries/notifications/util.ts index 6bbf9b250..569fbbd0f 100644 --- a/src/state/queries/notifications/util.ts +++ b/src/state/queries/notifications/util.ts @@ -244,7 +244,9 @@ function toKnownType( notif.reason === 'follow' || notif.reason === 'starterpack-joined' || notif.reason === 'verified' || - notif.reason === 'unverified' + notif.reason === 'unverified' || + notif.reason === 'like-via-repost' || + notif.reason === 'repost-via-repost' ) { return notif.reason as NotificationType } @@ -257,7 +259,12 @@ function getSubjectUri( ): string | undefined { if (type === 'reply' || type === 'quote' || type === 'mention') { return notif.uri - } else if (type === 'post-like' || type === 'repost') { + } else if ( + type === 'post-like' || + type === 'repost' || + type === 'like-via-repost' || + type === 'repost-via-repost' + ) { if ( bsky.dangerousIsType<AppBskyFeedRepost.Record>( notif.record, diff --git a/src/state/queries/post.ts b/src/state/queries/post.ts index 7052590ca..4700a7fdc 100644 --- a/src/state/queries/post.ts +++ b/src/state/queries/post.ts @@ -1,11 +1,11 @@ import {useCallback} from 'react' -import {AppBskyActorDefs, AppBskyFeedDefs, AtUri} from '@atproto/api' +import {type AppBskyActorDefs, type AppBskyFeedDefs, AtUri} from '@atproto/api' import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query' import {useToggleMutationQueue} from '#/lib/hooks/useToggleMutationQueue' -import {logEvent, LogEvents, toClout} from '#/lib/statsig/statsig' +import {logEvent, type LogEvents, toClout} from '#/lib/statsig/statsig' import {updatePostShadow} from '#/state/cache/post-shadow' -import {Shadow} from '#/state/cache/types' +import {type Shadow} from '#/state/cache/types' import {useAgent, useSession} from '#/state/session' import * as userActionHistory from '#/state/userActionHistory' import {useIsThreadMuted, useSetThreadMute} from '../cache/thread-mutes' @@ -98,6 +98,7 @@ export function useGetPosts() { export function usePostLikeMutationQueue( post: Shadow<AppBskyFeedDefs.PostView>, + viaRepost: {uri: string; cid: string} | undefined, logContext: LogEvents['post:like']['logContext'] & LogEvents['post:unlike']['logContext'], ) { @@ -115,6 +116,7 @@ export function usePostLikeMutationQueue( const {uri: likeUri} = await likeMutation.mutateAsync({ uri: postUri, cid: postCid, + via: viaRepost, }) userActionHistory.like([postUri]) return likeUri @@ -167,9 +169,9 @@ function usePostLikeMutation( return useMutation< {uri: string}, // responds with the uri of the like Error, - {uri: string; cid: string} // the post's uri and cid + {uri: string; cid: string; via?: {uri: string; cid: string}} // the post's uri and cid, and the repost uri/cid if present >({ - mutationFn: ({uri, cid}) => { + mutationFn: ({uri, cid, via}) => { let ownProfile: AppBskyActorDefs.ProfileViewDetailed | undefined if (currentAccount) { ownProfile = findProfileQueryData(queryClient, currentAccount.did) @@ -190,7 +192,7 @@ function usePostLikeMutation( ? toClout(post.likeCount + post.repostCount + post.replyCount) : undefined, }) - return agent.like(uri, cid) + return agent.like(uri, cid, via) }, }) } @@ -209,6 +211,7 @@ function usePostUnlikeMutation( export function usePostRepostMutationQueue( post: Shadow<AppBskyFeedDefs.PostView>, + viaRepost: {uri: string; cid: string} | undefined, logContext: LogEvents['post:repost']['logContext'] & LogEvents['post:unrepost']['logContext'], ) { @@ -226,6 +229,7 @@ export function usePostRepostMutationQueue( const {uri: repostUri} = await repostMutation.mutateAsync({ uri: postUri, cid: postCid, + via: viaRepost, }) return repostUri } else { @@ -272,11 +276,11 @@ function usePostRepostMutation( return useMutation< {uri: string}, // responds with the uri of the repost Error, - {uri: string; cid: string} // the post's uri and cid + {uri: string; cid: string; via?: {uri: string; cid: string}} // the post's uri and cid, and the repost uri/cid if present >({ - mutationFn: post => { + mutationFn: ({uri, cid, via}) => { logEvent('post:repost', {logContext}) - return agent.repost(post.uri, post.cid) + return agent.repost(uri, cid, via) }, }) } |