mirror of https://github.com/tooot-app/app
Fixed #427
This commit is contained in:
parent
fa0d28acd1
commit
cc3d5b14e5
|
@ -2,6 +2,7 @@ import analytics from '@components/analytics'
|
||||||
import Icon from '@components/Icon'
|
import Icon from '@components/Icon'
|
||||||
import { displayMessage } from '@components/Message'
|
import { displayMessage } from '@components/Message'
|
||||||
import CustomText from '@components/Text'
|
import CustomText from '@components/Text'
|
||||||
|
import { useActionSheet } from '@expo/react-native-action-sheet'
|
||||||
import { useNavigation } from '@react-navigation/native'
|
import { useNavigation } from '@react-navigation/native'
|
||||||
import { StackNavigationProp } from '@react-navigation/stack'
|
import { StackNavigationProp } from '@react-navigation/stack'
|
||||||
import { RootStackParamList } from '@utils/navigation/navigators'
|
import { RootStackParamList } from '@utils/navigation/navigators'
|
||||||
|
@ -95,25 +96,87 @@ const TimelineActions: React.FC<Props> = ({
|
||||||
queryKey
|
queryKey
|
||||||
})
|
})
|
||||||
}, [status.replies_count])
|
}, [status.replies_count])
|
||||||
|
const { showActionSheetWithOptions } = useActionSheet()
|
||||||
const onPressReblog = useCallback(() => {
|
const onPressReblog = useCallback(() => {
|
||||||
analytics('timeline_shared_actions_reblog_press', {
|
if (!status.reblogged) {
|
||||||
page: queryKey[1].page,
|
showActionSheetWithOptions(
|
||||||
count: status.reblogs_count,
|
{
|
||||||
current: status.reblogged
|
title: t('shared.actions.reblogged.options.title'),
|
||||||
})
|
options: [
|
||||||
mutation.mutate({
|
t('shared.actions.reblogged.options.public'),
|
||||||
type: 'updateStatusProperty',
|
t('shared.actions.reblogged.options.unlisted'),
|
||||||
queryKey,
|
t('common:buttons.cancel')
|
||||||
rootQueryKey,
|
],
|
||||||
id: status.id,
|
cancelButtonIndex: 2
|
||||||
reblog,
|
},
|
||||||
payload: {
|
(selectedIndex: number) => {
|
||||||
property: 'reblogged',
|
switch (selectedIndex) {
|
||||||
currentValue: status.reblogged,
|
case 0:
|
||||||
propertyCount: 'reblogs_count',
|
analytics('timeline_shared_actions_reblog_public_press', {
|
||||||
countValue: status.reblogs_count
|
page: queryKey[1].page,
|
||||||
}
|
count: status.reblogs_count,
|
||||||
})
|
current: status.reblogged
|
||||||
|
})
|
||||||
|
mutation.mutate({
|
||||||
|
type: 'updateStatusProperty',
|
||||||
|
queryKey,
|
||||||
|
rootQueryKey,
|
||||||
|
id: status.id,
|
||||||
|
reblog,
|
||||||
|
payload: {
|
||||||
|
property: 'reblogged',
|
||||||
|
currentValue: status.reblogged,
|
||||||
|
propertyCount: 'reblogs_count',
|
||||||
|
countValue: status.reblogs_count,
|
||||||
|
visibility: 'public'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
break
|
||||||
|
case 1:
|
||||||
|
analytics('timeline_shared_actions_reblog_unlisted_press', {
|
||||||
|
page: queryKey[1].page,
|
||||||
|
count: status.reblogs_count,
|
||||||
|
current: status.reblogged
|
||||||
|
})
|
||||||
|
mutation.mutate({
|
||||||
|
type: 'updateStatusProperty',
|
||||||
|
queryKey,
|
||||||
|
rootQueryKey,
|
||||||
|
id: status.id,
|
||||||
|
reblog,
|
||||||
|
payload: {
|
||||||
|
property: 'reblogged',
|
||||||
|
currentValue: status.reblogged,
|
||||||
|
propertyCount: 'reblogs_count',
|
||||||
|
countValue: status.reblogs_count,
|
||||||
|
visibility: 'unlisted'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
analytics('timeline_shared_actions_reblog_press', {
|
||||||
|
page: queryKey[1].page,
|
||||||
|
count: status.reblogs_count,
|
||||||
|
current: status.reblogged
|
||||||
|
})
|
||||||
|
mutation.mutate({
|
||||||
|
type: 'updateStatusProperty',
|
||||||
|
queryKey,
|
||||||
|
rootQueryKey,
|
||||||
|
id: status.id,
|
||||||
|
reblog,
|
||||||
|
payload: {
|
||||||
|
property: 'reblogged',
|
||||||
|
currentValue: status.reblogged,
|
||||||
|
propertyCount: 'reblogs_count',
|
||||||
|
countValue: status.reblogs_count,
|
||||||
|
visibility: 'public'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}, [status.reblogged, status.reblogs_count])
|
}, [status.reblogged, status.reblogs_count])
|
||||||
const onPressFavourite = useCallback(() => {
|
const onPressFavourite = useCallback(() => {
|
||||||
analytics('timeline_shared_actions_favourite_press', {
|
analytics('timeline_shared_actions_favourite_press', {
|
||||||
|
|
|
@ -38,7 +38,12 @@
|
||||||
},
|
},
|
||||||
"reblogged": {
|
"reblogged": {
|
||||||
"accessibilityLabel": "Boost this toot",
|
"accessibilityLabel": "Boost this toot",
|
||||||
"function": "Boost toot"
|
"function": "Boost toot",
|
||||||
|
"options": {
|
||||||
|
"title": "Choose boost visibility",
|
||||||
|
"public": "Public boost",
|
||||||
|
"unlisted": "Unlist boost"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"favourited": {
|
"favourited": {
|
||||||
"accessibilityLabel": "Add this toot to favourites",
|
"accessibilityLabel": "Add this toot to favourites",
|
||||||
|
|
|
@ -293,11 +293,18 @@ export type MutationVarsTimelineUpdateStatusProperty = {
|
||||||
countValue: undefined
|
countValue: undefined
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
property: 'favourited' | 'reblogged'
|
property: 'favourited'
|
||||||
currentValue: boolean
|
currentValue: boolean
|
||||||
propertyCount: 'favourites_count' | 'reblogs_count'
|
propertyCount: 'favourites_count' | 'reblogs_count'
|
||||||
countValue: number
|
countValue: number
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
property: 'reblogged'
|
||||||
|
currentValue: boolean
|
||||||
|
propertyCount: 'favourites_count' | 'reblogs_count'
|
||||||
|
countValue: number
|
||||||
|
visibility: 'public' | 'unlisted'
|
||||||
|
}
|
||||||
| {
|
| {
|
||||||
property: 'poll'
|
property: 'poll'
|
||||||
id: Mastodon.Poll['id']
|
id: Mastodon.Poll['id']
|
||||||
|
@ -371,11 +378,16 @@ const mutationFunction = async (params: MutationVarsTimeline) => {
|
||||||
...(params.payload.type === 'vote' && { body: formData })
|
...(params.payload.type === 'vote' && { body: formData })
|
||||||
})
|
})
|
||||||
default:
|
default:
|
||||||
|
const body = new FormData()
|
||||||
|
if (params.payload.property === 'reblogged') {
|
||||||
|
body.append('visibility', params.payload.visibility)
|
||||||
|
}
|
||||||
return apiInstance<Mastodon.Status>({
|
return apiInstance<Mastodon.Status>({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
url: `statuses/${params.id}/${
|
url: `statuses/${params.id}/${
|
||||||
params.payload.currentValue ? 'un' : ''
|
params.payload.currentValue ? 'un' : ''
|
||||||
}${MapPropertyToUrl[params.payload.property]}`
|
}${MapPropertyToUrl[params.payload.property]}`,
|
||||||
|
body
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
case 'updateAccountProperty':
|
case 'updateAccountProperty':
|
||||||
|
|
Loading…
Reference in New Issue