1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00
This commit is contained in:
xmflsct
2023-02-12 19:47:28 +01:00
parent d3cf0edbc9
commit e37a95408c
7 changed files with 161 additions and 27 deletions

View File

@ -29,20 +29,20 @@ const RelationshipOutgoing: React.FC<Props> = ({ id }: Props) => {
const queryKeyRelationship: QueryKeyRelationship = ['Relationship', { id }]
const queryClient = useQueryClient()
const mutation = useRelationshipMutation({
onSuccess: (res, { payload: { action } }) => {
onSuccess: (res, vars) => {
haptics('Success')
queryClient.setQueryData<Mastodon.Relationship[]>(queryKeyRelationship, [res])
if (action === 'block') {
if (vars.type === 'outgoing' && vars.payload.action === 'block') {
const queryKey = ['Timeline', { page: 'Following' }]
queryClient.invalidateQueries({ queryKey, exact: false })
}
},
onError: (err: any, { payload: { action } }) => {
onError: (err: any, vars) => {
displayMessage({
theme,
type: 'error',
message: t('common:message.error.message', {
function: t(`componentRelationship:${action}.function` as any)
function: t(`componentRelationship:${(vars.payload as any).action}.function` as any)
}),
...(err.status &&
typeof err.status === 'number' &&

View File

@ -105,21 +105,21 @@ const menuAccount = ({
})
const queryKeyRelationship: QueryKeyRelationship = ['Relationship', { id: actualAccount?.id }]
const relationshipMutation = useRelationshipMutation({
onSuccess: (res, { payload: { action } }) => {
onSuccess: (res, vars) => {
haptics('Success')
queryClient.setQueryData<Mastodon.Relationship[]>(queryKeyRelationship, [res])
if (action === 'block') {
if (vars.type === 'outgoing' && vars.payload.action === 'block') {
queryClient.invalidateQueries({
queryKey: ['Timeline', { page: 'Following' }],
exact: false
})
}
},
onError: (err: any, { payload: { action } }) => {
onError: (err: any, vars) => {
displayMessage({
type: 'danger',
message: t('common:message.error.message', {
function: t(`componentContextMenu:${action}.function` as any)
function: t(`componentContextMenu:${(vars.payload as any).action}.function` as any)
}),
...(err.status &&
typeof err.status === 'number' &&