feedDescriptor
This commit is contained in:
@@ -69,16 +69,17 @@ let PostControls = ({
|
|||||||
const {_, i18n} = useLingui()
|
const {_, i18n} = useLingui()
|
||||||
const {gtMobile} = useBreakpoints()
|
const {gtMobile} = useBreakpoints()
|
||||||
const {openComposer} = useOpenComposer()
|
const {openComposer} = useOpenComposer()
|
||||||
|
const {feedDescriptor} = useFeedFeedbackContext()
|
||||||
const [queueLike, queueUnlike] = usePostLikeMutationQueue(
|
const [queueLike, queueUnlike] = usePostLikeMutationQueue(
|
||||||
post,
|
post,
|
||||||
viaRepost,
|
viaRepost,
|
||||||
feedContext,
|
feedDescriptor,
|
||||||
logContext,
|
logContext,
|
||||||
)
|
)
|
||||||
const [queueRepost, queueUnrepost] = usePostRepostMutationQueue(
|
const [queueRepost, queueUnrepost] = usePostRepostMutationQueue(
|
||||||
post,
|
post,
|
||||||
viaRepost,
|
viaRepost,
|
||||||
feedContext,
|
feedDescriptor,
|
||||||
logContext,
|
logContext,
|
||||||
)
|
)
|
||||||
const requireAuth = useRequireAuth()
|
const requireAuth = useRequireAuth()
|
||||||
|
|||||||
@@ -196,19 +196,19 @@ export type MetricEvents = {
|
|||||||
likerClout: number | undefined
|
likerClout: number | undefined
|
||||||
postClout: number | undefined
|
postClout: number | undefined
|
||||||
logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo'
|
logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo'
|
||||||
feedContext?: string
|
feedDescriptor?: string
|
||||||
}
|
}
|
||||||
'post:repost': {
|
'post:repost': {
|
||||||
logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo'
|
logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo'
|
||||||
feedContext?: string
|
feedDescriptor?: string
|
||||||
}
|
}
|
||||||
'post:unlike': {
|
'post:unlike': {
|
||||||
logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo'
|
logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo'
|
||||||
feedContext?: string
|
feedDescriptor?: string
|
||||||
}
|
}
|
||||||
'post:unrepost': {
|
'post:unrepost': {
|
||||||
logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo'
|
logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo'
|
||||||
feedContext?: string
|
feedDescriptor?: string
|
||||||
}
|
}
|
||||||
'post:mute': {}
|
'post:mute': {}
|
||||||
'post:unmute': {}
|
'post:unmute': {}
|
||||||
|
|||||||
+14
-14
@@ -100,7 +100,7 @@ export function useGetPosts() {
|
|||||||
export function usePostLikeMutationQueue(
|
export function usePostLikeMutationQueue(
|
||||||
post: Shadow<AppBskyFeedDefs.PostView>,
|
post: Shadow<AppBskyFeedDefs.PostView>,
|
||||||
viaRepost: {uri: string; cid: string} | undefined,
|
viaRepost: {uri: string; cid: string} | undefined,
|
||||||
feedContext: string | undefined,
|
feedDescriptor: string | undefined,
|
||||||
logContext: LogEvents['post:like']['logContext'] &
|
logContext: LogEvents['post:like']['logContext'] &
|
||||||
LogEvents['post:unlike']['logContext'],
|
LogEvents['post:unlike']['logContext'],
|
||||||
) {
|
) {
|
||||||
@@ -108,8 +108,8 @@ export function usePostLikeMutationQueue(
|
|||||||
const postUri = post.uri
|
const postUri = post.uri
|
||||||
const postCid = post.cid
|
const postCid = post.cid
|
||||||
const initialLikeUri = post.viewer?.like
|
const initialLikeUri = post.viewer?.like
|
||||||
const likeMutation = usePostLikeMutation(feedContext, logContext, post)
|
const likeMutation = usePostLikeMutation(feedDescriptor, logContext, post)
|
||||||
const unlikeMutation = usePostUnlikeMutation(feedContext, logContext)
|
const unlikeMutation = usePostUnlikeMutation(feedDescriptor, logContext)
|
||||||
|
|
||||||
const queueToggle = useToggleMutationQueue({
|
const queueToggle = useToggleMutationQueue({
|
||||||
initialState: initialLikeUri,
|
initialState: initialLikeUri,
|
||||||
@@ -161,7 +161,7 @@ export function usePostLikeMutationQueue(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function usePostLikeMutation(
|
function usePostLikeMutation(
|
||||||
feedContext: string | undefined,
|
feedDescriptor: string | undefined,
|
||||||
logContext: LogEvents['post:like']['logContext'],
|
logContext: LogEvents['post:like']['logContext'],
|
||||||
post: Shadow<AppBskyFeedDefs.PostView>,
|
post: Shadow<AppBskyFeedDefs.PostView>,
|
||||||
) {
|
) {
|
||||||
@@ -194,7 +194,7 @@ function usePostLikeMutation(
|
|||||||
post.replyCount != null
|
post.replyCount != null
|
||||||
? toClout(post.likeCount + post.repostCount + post.replyCount)
|
? toClout(post.likeCount + post.repostCount + post.replyCount)
|
||||||
: undefined,
|
: undefined,
|
||||||
feedContext: feedContext,
|
feedDescriptor: feedDescriptor,
|
||||||
})
|
})
|
||||||
return agent.like(uri, cid, via)
|
return agent.like(uri, cid, via)
|
||||||
},
|
},
|
||||||
@@ -202,13 +202,13 @@ function usePostLikeMutation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function usePostUnlikeMutation(
|
function usePostUnlikeMutation(
|
||||||
feedContext: string | undefined,
|
feedDescriptor: string | undefined,
|
||||||
logContext: LogEvents['post:unlike']['logContext'],
|
logContext: LogEvents['post:unlike']['logContext'],
|
||||||
) {
|
) {
|
||||||
const agent = useAgent()
|
const agent = useAgent()
|
||||||
return useMutation<void, Error, {postUri: string; likeUri: string}>({
|
return useMutation<void, Error, {postUri: string; likeUri: string}>({
|
||||||
mutationFn: ({likeUri}) => {
|
mutationFn: ({likeUri}) => {
|
||||||
logger.metric('post:unlike', {logContext, feedContext: feedContext})
|
logger.metric('post:unlike', {logContext, feedDescriptor})
|
||||||
return agent.deleteLike(likeUri)
|
return agent.deleteLike(likeUri)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -217,7 +217,7 @@ function usePostUnlikeMutation(
|
|||||||
export function usePostRepostMutationQueue(
|
export function usePostRepostMutationQueue(
|
||||||
post: Shadow<AppBskyFeedDefs.PostView>,
|
post: Shadow<AppBskyFeedDefs.PostView>,
|
||||||
viaRepost: {uri: string; cid: string} | undefined,
|
viaRepost: {uri: string; cid: string} | undefined,
|
||||||
feedContext: string | undefined,
|
feedDescriptor: string | undefined,
|
||||||
logContext: LogEvents['post:repost']['logContext'] &
|
logContext: LogEvents['post:repost']['logContext'] &
|
||||||
LogEvents['post:unrepost']['logContext'],
|
LogEvents['post:unrepost']['logContext'],
|
||||||
) {
|
) {
|
||||||
@@ -225,8 +225,8 @@ export function usePostRepostMutationQueue(
|
|||||||
const postUri = post.uri
|
const postUri = post.uri
|
||||||
const postCid = post.cid
|
const postCid = post.cid
|
||||||
const initialRepostUri = post.viewer?.repost
|
const initialRepostUri = post.viewer?.repost
|
||||||
const repostMutation = usePostRepostMutation(feedContext, logContext)
|
const repostMutation = usePostRepostMutation(feedDescriptor, logContext)
|
||||||
const unrepostMutation = usePostUnrepostMutation(feedContext, logContext)
|
const unrepostMutation = usePostUnrepostMutation(feedDescriptor, logContext)
|
||||||
|
|
||||||
const queueToggle = useToggleMutationQueue({
|
const queueToggle = useToggleMutationQueue({
|
||||||
initialState: initialRepostUri,
|
initialState: initialRepostUri,
|
||||||
@@ -276,7 +276,7 @@ export function usePostRepostMutationQueue(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function usePostRepostMutation(
|
function usePostRepostMutation(
|
||||||
feedContext: string | undefined,
|
feedDescriptor: string | undefined,
|
||||||
logContext: LogEvents['post:repost']['logContext'],
|
logContext: LogEvents['post:repost']['logContext'],
|
||||||
) {
|
) {
|
||||||
const agent = useAgent()
|
const agent = useAgent()
|
||||||
@@ -286,20 +286,20 @@ function usePostRepostMutation(
|
|||||||
{uri: string; cid: string; via?: {uri: string; cid: string}} // the post's uri and cid, and the repost uri/cid if present
|
{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, via}) => {
|
mutationFn: ({uri, cid, via}) => {
|
||||||
logger.metric('post:repost', {logContext, feedContext: feedContext})
|
logger.metric('post:repost', {logContext, feedDescriptor})
|
||||||
return agent.repost(uri, cid, via)
|
return agent.repost(uri, cid, via)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function usePostUnrepostMutation(
|
function usePostUnrepostMutation(
|
||||||
feedContext: string | undefined,
|
feedDescriptor: string | undefined,
|
||||||
logContext: LogEvents['post:unrepost']['logContext'],
|
logContext: LogEvents['post:unrepost']['logContext'],
|
||||||
) {
|
) {
|
||||||
const agent = useAgent()
|
const agent = useAgent()
|
||||||
return useMutation<void, Error, {postUri: string; repostUri: string}>({
|
return useMutation<void, Error, {postUri: string; repostUri: string}>({
|
||||||
mutationFn: ({repostUri}) => {
|
mutationFn: ({repostUri}) => {
|
||||||
logger.metric('post:unrepost', {logContext, feedContext: feedContext})
|
logger.metric('post:unrepost', {logContext, feedDescriptor})
|
||||||
return agent.deleteRepost(repostUri)
|
return agent.deleteRepost(repostUri)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user