fix mute-reposts hook
This commit is contained in:
@@ -432,7 +432,7 @@ export function useProfileMuteMutationQueue(
|
|||||||
) {
|
) {
|
||||||
const ax = useAnalytics()
|
const ax = useAnalytics()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const did = profile.did
|
const did = profile.did as DidString
|
||||||
const initialMuted = profile.viewer?.muted
|
const initialMuted = profile.viewer?.muted
|
||||||
const muteMutation = useProfileMuteMutation()
|
const muteMutation = useProfileMuteMutation()
|
||||||
const unmuteMutation = useProfileUnmuteMutation()
|
const unmuteMutation = useProfileUnmuteMutation()
|
||||||
@@ -441,15 +441,11 @@ export function useProfileMuteMutationQueue(
|
|||||||
initialState: initialMuted,
|
initialState: initialMuted,
|
||||||
runMutation: async (_prevMuted, shouldMute) => {
|
runMutation: async (_prevMuted, shouldMute) => {
|
||||||
if (shouldMute) {
|
if (shouldMute) {
|
||||||
await muteMutation.mutateAsync({
|
await muteMutation.mutateAsync({did})
|
||||||
did,
|
|
||||||
})
|
|
||||||
ax.metric('profile:mute', {})
|
ax.metric('profile:mute', {})
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
await unmuteMutation.mutateAsync({
|
await unmuteMutation.mutateAsync({did})
|
||||||
did,
|
|
||||||
})
|
|
||||||
ax.metric('profile:unmute', {})
|
ax.metric('profile:unmute', {})
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -494,7 +490,7 @@ export function useProfileMuteRepostsMutationQueue(
|
|||||||
) {
|
) {
|
||||||
const ax = useAnalytics()
|
const ax = useAnalytics()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const did = profile.did
|
const did = profile.did as DidString
|
||||||
const initialMutedOnlyReposts = !!profile.viewer?.mutedOnlyReposts
|
const initialMutedOnlyReposts = !!profile.viewer?.mutedOnlyReposts
|
||||||
const muteRepostsMutation = useProfileMuteRepostsMutation()
|
const muteRepostsMutation = useProfileMuteRepostsMutation()
|
||||||
const unmuteMutation = useProfileUnmuteMutation()
|
const unmuteMutation = useProfileUnmuteMutation()
|
||||||
@@ -503,15 +499,11 @@ export function useProfileMuteRepostsMutationQueue(
|
|||||||
initialState: initialMutedOnlyReposts,
|
initialState: initialMutedOnlyReposts,
|
||||||
runMutation: async (_prevMutedOnlyReposts, shouldMute) => {
|
runMutation: async (_prevMutedOnlyReposts, shouldMute) => {
|
||||||
if (shouldMute) {
|
if (shouldMute) {
|
||||||
await muteRepostsMutation.mutateAsync({
|
await muteRepostsMutation.mutateAsync({did})
|
||||||
did,
|
|
||||||
})
|
|
||||||
ax.metric('profile:muteReposts', {})
|
ax.metric('profile:muteReposts', {})
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
await unmuteMutation.mutateAsync({
|
await unmuteMutation.mutateAsync({did})
|
||||||
did,
|
|
||||||
})
|
|
||||||
ax.metric('profile:unmuteReposts', {})
|
ax.metric('profile:unmuteReposts', {})
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -546,9 +538,9 @@ export function useProfileMuteRepostsMutationQueue(
|
|||||||
function useProfileMuteMutation() {
|
function useProfileMuteMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const appviewClient = useAppviewClient()
|
const appviewClient = useAppviewClient()
|
||||||
return useMutation<void, Error, {did: string}>({
|
return useMutation({
|
||||||
mutationFn: async ({did}) => {
|
mutationFn: async ({did}: {did: DidString}) => {
|
||||||
await appviewClient.call(muteActor, {actor: did as AtIdentifierString})
|
await appviewClient.call(muteActor, {actor: did})
|
||||||
},
|
},
|
||||||
onSuccess() {
|
onSuccess() {
|
||||||
void queryClient.invalidateQueries({queryKey: RQKEY_MY_MUTED()})
|
void queryClient.invalidateQueries({queryKey: RQKEY_MY_MUTED()})
|
||||||
@@ -558,10 +550,14 @@ function useProfileMuteMutation() {
|
|||||||
|
|
||||||
function useProfileMuteRepostsMutation() {
|
function useProfileMuteRepostsMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const agent = useAgent()
|
const appviewClient = useAppviewClient()
|
||||||
return useMutation<void, Error, {did: string}>({
|
return useMutation({
|
||||||
mutationFn: async ({did}) => {
|
mutationFn: async ({did}: {did: DidString}) => {
|
||||||
await agent.mute(did, {onlyReposts: true})
|
await appviewClient.call(muteActor, {
|
||||||
|
actor: did,
|
||||||
|
// @ts-expect-error missing from this SDK version, remove this
|
||||||
|
onlyReposts: true,
|
||||||
|
})
|
||||||
},
|
},
|
||||||
onSuccess() {
|
onSuccess() {
|
||||||
void queryClient.invalidateQueries({queryKey: RQKEY_MY_MUTED()})
|
void queryClient.invalidateQueries({queryKey: RQKEY_MY_MUTED()})
|
||||||
@@ -572,9 +568,9 @@ function useProfileMuteRepostsMutation() {
|
|||||||
function useProfileUnmuteMutation() {
|
function useProfileUnmuteMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const appviewClient = useAppviewClient()
|
const appviewClient = useAppviewClient()
|
||||||
return useMutation<void, Error, {did: string}>({
|
return useMutation({
|
||||||
mutationFn: async ({did}) => {
|
mutationFn: async ({did}: {did: DidString}) => {
|
||||||
await appviewClient.call(unmuteActor, {actor: did as AtIdentifierString})
|
await appviewClient.call(unmuteActor, {actor: did})
|
||||||
},
|
},
|
||||||
onSuccess() {
|
onSuccess() {
|
||||||
void queryClient.invalidateQueries({queryKey: RQKEY_MY_MUTED()})
|
void queryClient.invalidateQueries({queryKey: RQKEY_MY_MUTED()})
|
||||||
|
|||||||
Reference in New Issue
Block a user