mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Fixed #497
This commit is contained in:
@ -1,11 +1,7 @@
|
||||
import analytics from '@components/analytics'
|
||||
import Button from '@components/Button'
|
||||
import haptics from '@components/haptics'
|
||||
import { displayMessage } from '@components/Message'
|
||||
import {
|
||||
QueryKeyRelationship,
|
||||
useRelationshipMutation
|
||||
} from '@utils/queryHooks/relationship'
|
||||
import { QueryKeyRelationship, useRelationshipMutation } from '@utils/queryHooks/relationship'
|
||||
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||
import { StyleConstants } from '@utils/styles/constants'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
@ -23,17 +19,12 @@ const RelationshipIncoming: React.FC<Props> = ({ id }) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const queryKeyRelationship: QueryKeyRelationship = ['Relationship', { id }]
|
||||
const queryKeyNotification: QueryKeyTimeline = [
|
||||
'Timeline',
|
||||
{ page: 'Notifications' }
|
||||
]
|
||||
const queryKeyNotification: QueryKeyTimeline = ['Timeline', { page: 'Notifications' }]
|
||||
const queryClient = useQueryClient()
|
||||
const mutation = useRelationshipMutation({
|
||||
onSuccess: res => {
|
||||
haptics('Success')
|
||||
queryClient.setQueryData<Mastodon.Relationship[]>(queryKeyRelationship, [
|
||||
res
|
||||
])
|
||||
queryClient.setQueryData<Mastodon.Relationship[]>(queryKeyRelationship, [res])
|
||||
queryClient.refetchQueries(queryKeyNotification)
|
||||
},
|
||||
onError: (err: any, { type }) => {
|
||||
@ -62,28 +53,26 @@ const RelationshipIncoming: React.FC<Props> = ({ id }) => {
|
||||
type='icon'
|
||||
content='X'
|
||||
loading={mutation.isLoading}
|
||||
onPress={() => {
|
||||
analytics('relationship_incoming_press_reject')
|
||||
onPress={() =>
|
||||
mutation.mutate({
|
||||
id,
|
||||
type: 'incoming',
|
||||
payload: { action: 'reject' }
|
||||
})
|
||||
}}
|
||||
}
|
||||
/>
|
||||
<Button
|
||||
round
|
||||
type='icon'
|
||||
content='Check'
|
||||
loading={mutation.isLoading}
|
||||
onPress={() => {
|
||||
analytics('relationship_incoming_press_authorize')
|
||||
onPress={() =>
|
||||
mutation.mutate({
|
||||
id,
|
||||
type: 'incoming',
|
||||
payload: { action: 'authorize' }
|
||||
})
|
||||
}}
|
||||
}
|
||||
style={styles.approve}
|
||||
/>
|
||||
</View>
|
||||
|
@ -1,4 +1,3 @@
|
||||
import analytics from '@components/analytics'
|
||||
import Button from '@components/Button'
|
||||
import haptics from '@components/haptics'
|
||||
import { displayMessage } from '@components/Message'
|
||||
@ -29,10 +28,7 @@ const RelationshipOutgoing = React.memo(
|
||||
const mutation = useRelationshipMutation({
|
||||
onSuccess: (res, { payload: { action } }) => {
|
||||
haptics('Success')
|
||||
queryClient.setQueryData<Mastodon.Relationship[]>(
|
||||
queryKeyRelationship,
|
||||
[res]
|
||||
)
|
||||
queryClient.setQueryData<Mastodon.Relationship[]>(queryKeyRelationship, [res])
|
||||
if (action === 'block') {
|
||||
const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Following' }]
|
||||
queryClient.invalidateQueries(queryKey)
|
||||
@ -64,17 +60,12 @@ const RelationshipOutgoing = React.memo(
|
||||
onPress = () => {}
|
||||
} else {
|
||||
if (query.data?.blocked_by) {
|
||||
analytics('relationship_outgoing_blocked_by')
|
||||
content = t('button.blocked_by')
|
||||
onPress = () => {
|
||||
analytics('relationship_outgoing_blocked_by_press')
|
||||
}
|
||||
onPress = () => {}
|
||||
} else {
|
||||
if (query.data?.blocking) {
|
||||
analytics('relationship_outgoing_blocking')
|
||||
content = t('button.blocking')
|
||||
onPress = () => {
|
||||
analytics('relationship_outgoing_blocking_press')
|
||||
mutation.mutate({
|
||||
id,
|
||||
type: 'outgoing',
|
||||
@ -86,10 +77,8 @@ const RelationshipOutgoing = React.memo(
|
||||
}
|
||||
} else {
|
||||
if (query.data?.following) {
|
||||
analytics('relationship_outgoing_following')
|
||||
content = t('button.following')
|
||||
onPress = () => {
|
||||
analytics('relationship_outgoing_following_press')
|
||||
mutation.mutate({
|
||||
id,
|
||||
type: 'outgoing',
|
||||
@ -101,10 +90,8 @@ const RelationshipOutgoing = React.memo(
|
||||
}
|
||||
} else {
|
||||
if (query.data?.requested) {
|
||||
analytics('relationship_outgoing_requested')
|
||||
content = t('button.requested')
|
||||
onPress = () => {
|
||||
analytics('relationship_outgoing_requested_press')
|
||||
mutation.mutate({
|
||||
id,
|
||||
type: 'outgoing',
|
||||
@ -115,10 +102,8 @@ const RelationshipOutgoing = React.memo(
|
||||
})
|
||||
}
|
||||
} else {
|
||||
analytics('relationship_outgoing_default')
|
||||
content = t('button.default')
|
||||
onPress = () => {
|
||||
analytics('relationship_outgoing_default_press')
|
||||
mutation.mutate({
|
||||
id,
|
||||
type: 'outgoing',
|
||||
|
Reference in New Issue
Block a user