mirror of
https://github.com/tooot-app/app
synced 2025-04-16 19:27:29 +02:00
commit
f776b477f0
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@ -29,6 +29,7 @@ jobs:
|
|||||||
- name: -- Step 4 -- Install node dependencies
|
- name: -- Step 4 -- Install node dependencies
|
||||||
run: yarn install
|
run: yarn install
|
||||||
- name: -- Step 5 -- Install native dependencies
|
- name: -- Step 5 -- Install native dependencies
|
||||||
|
if: github.ref != 'refs/heads/main'
|
||||||
run: npx pod-install
|
run: npx pod-install
|
||||||
- name: -- Step 6 -- Install ruby dependencies
|
- name: -- Step 6 -- Install ruby dependencies
|
||||||
run: bundle install
|
run: bundle install
|
||||||
|
@ -56,7 +56,8 @@ private_lane :github_release do |options|
|
|||||||
tag_name: GITHUB_RELEASE,
|
tag_name: GITHUB_RELEASE,
|
||||||
description: "No changelog provided",
|
description: "No changelog provided",
|
||||||
commitish: git_branch,
|
commitish: git_branch,
|
||||||
is_prerelease: options[:prerelease]
|
is_prerelease: options[:prerelease],
|
||||||
|
upload_assets: ["#{File.expand_path('..', Dir.pwd)}/tooot-#{GITHUB_RELEASE}.apk"]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -125,6 +126,22 @@ private_lane :build_android do
|
|||||||
skip_upload_images: true,
|
skip_upload_images: true,
|
||||||
skip_upload_screenshots: true
|
skip_upload_screenshots: true
|
||||||
)
|
)
|
||||||
|
build_android_app(
|
||||||
|
task: 'assemble',
|
||||||
|
build_type: 'release',
|
||||||
|
project_dir: "./android",
|
||||||
|
print_command: false,
|
||||||
|
print_command_output: false,
|
||||||
|
properties: {
|
||||||
|
"expoSDK" => VERSIONS[:expo],
|
||||||
|
"releaseChannel" => RELEASE_CHANNEL,
|
||||||
|
"android.injected.signing.store.file" => "#{File.expand_path('..', Dir.pwd)}/android/tooot.jks",
|
||||||
|
"android.injected.signing.store.password" => ENV["ANDROID_KEYSTORE_PASSWORD"],
|
||||||
|
"android.injected.signing.key.alias" => ENV["ANDROID_KEYSTORE_ALIAS"],
|
||||||
|
"android.injected.signing.key.password" => ENV["ANDROID_KEYSTORE_KEY_PASSWORD"],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
sh "mv #{lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]} #{File.expand_path('..', Dir.pwd)}/tooot-#{GITHUB_RELEASE}.apk"
|
||||||
when "release"
|
when "release"
|
||||||
else
|
else
|
||||||
if !is_ci
|
if !is_ci
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"native": "210317",
|
"native": "210317",
|
||||||
"major": 0,
|
"major": 0,
|
||||||
"minor": 7,
|
"minor": 7,
|
||||||
"patch": 0,
|
"patch": 1,
|
||||||
"expo": "40.0.0"
|
"expo": "40.0.0"
|
||||||
},
|
},
|
||||||
"description": "tooot app for Mastodon",
|
"description": "tooot app for Mastodon",
|
||||||
|
@ -29,7 +29,7 @@ audio()
|
|||||||
push()
|
push()
|
||||||
|
|
||||||
log('log', 'react-query', 'initializing')
|
log('log', 'react-query', 'initializing')
|
||||||
const queryClient = new QueryClient()
|
export const queryClient = new QueryClient()
|
||||||
|
|
||||||
log('log', 'react-native-screens', 'initializing')
|
log('log', 'react-native-screens', 'initializing')
|
||||||
enableScreens()
|
enableScreens()
|
||||||
|
@ -128,6 +128,7 @@ const Timeline: React.FC<Props> = ({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TimelineRefresh
|
<TimelineRefresh
|
||||||
|
flRef={flRef}
|
||||||
queryKey={queryKey}
|
queryKey={queryKey}
|
||||||
scrollY={scrollY}
|
scrollY={scrollY}
|
||||||
fetchingType={fetchingType}
|
fetchingType={fetchingType}
|
||||||
|
@ -7,9 +7,9 @@ import {
|
|||||||
} from '@utils/queryHooks/timeline'
|
} from '@utils/queryHooks/timeline'
|
||||||
import { StyleConstants } from '@utils/styles/constants'
|
import { StyleConstants } from '@utils/styles/constants'
|
||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import React, { useCallback, useRef, useState } from 'react'
|
import React, { RefObject, useCallback, useRef, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Platform, StyleSheet, Text, View } from 'react-native'
|
import { FlatList, Platform, StyleSheet, Text, View } from 'react-native'
|
||||||
import { Circle } from 'react-native-animated-spinkit'
|
import { Circle } from 'react-native-animated-spinkit'
|
||||||
import Animated, {
|
import Animated, {
|
||||||
Extrapolate,
|
Extrapolate,
|
||||||
@ -23,6 +23,7 @@ import Animated, {
|
|||||||
import { InfiniteData, useQueryClient } from 'react-query'
|
import { InfiniteData, useQueryClient } from 'react-query'
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
|
flRef: RefObject<FlatList<any>>
|
||||||
queryKey: QueryKeyTimeline
|
queryKey: QueryKeyTimeline
|
||||||
scrollY: Animated.SharedValue<number>
|
scrollY: Animated.SharedValue<number>
|
||||||
fetchingType: Animated.SharedValue<0 | 1 | 2>
|
fetchingType: Animated.SharedValue<0 | 1 | 2>
|
||||||
@ -40,6 +41,7 @@ export const SEPARATION_Y_2 = -(
|
|||||||
)
|
)
|
||||||
|
|
||||||
const TimelineRefresh: React.FC<Props> = ({
|
const TimelineRefresh: React.FC<Props> = ({
|
||||||
|
flRef,
|
||||||
queryKey,
|
queryKey,
|
||||||
scrollY,
|
scrollY,
|
||||||
fetchingType,
|
fetchingType,
|
||||||
@ -137,6 +139,10 @@ const TimelineRefresh: React.FC<Props> = ({
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
const callRefetch = async () => {
|
||||||
|
await refetch()
|
||||||
|
setTimeout(() => flRef.current?.scrollToOffset({ offset: 1 }), 50)
|
||||||
|
}
|
||||||
|
|
||||||
const [textRight, setTextRight] = useState(0)
|
const [textRight, setTextRight] = useState(0)
|
||||||
const arrowY = useAnimatedStyle(() => ({
|
const arrowY = useAnimatedStyle(() => ({
|
||||||
@ -225,7 +231,7 @@ const TimelineRefresh: React.FC<Props> = ({
|
|||||||
break
|
break
|
||||||
case 2:
|
case 2:
|
||||||
runOnJS(prepareRefetch)()
|
runOnJS(prepareRefetch)()
|
||||||
runOnJS(refetch)()
|
runOnJS(callRefetch)()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -23,280 +23,281 @@ export interface Props {
|
|||||||
reblog: boolean
|
reblog: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const TimelineActions = React.memo(
|
const TimelineActions: React.FC<Props> = ({
|
||||||
({ queryKey, rootQueryKey, highlighted, status, accts, reblog }: Props) => {
|
queryKey,
|
||||||
const navigation = useNavigation()
|
rootQueryKey,
|
||||||
const { t } = useTranslation('componentTimeline')
|
highlighted,
|
||||||
const { mode, theme } = useTheme()
|
status,
|
||||||
const iconColor = theme.secondary
|
accts,
|
||||||
const iconColorAction = (state: boolean) =>
|
reblog
|
||||||
state ? theme.primaryDefault : theme.secondary
|
}) => {
|
||||||
|
const navigation = useNavigation()
|
||||||
|
const { t } = useTranslation('componentTimeline')
|
||||||
|
const { mode, theme } = useTheme()
|
||||||
|
const iconColor = theme.secondary
|
||||||
|
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const mutation = useTimelineMutation({
|
const mutation = useTimelineMutation({
|
||||||
queryClient,
|
onMutate: true,
|
||||||
onMutate: true,
|
onSuccess: (_, params) => {
|
||||||
onSuccess: (_, params) => {
|
const theParams = params as MutationVarsTimelineUpdateStatusProperty
|
||||||
const theParams = params as MutationVarsTimelineUpdateStatusProperty
|
if (
|
||||||
if (
|
// Un-bookmark from bookmarks page
|
||||||
// Un-bookmark from bookmarks page
|
(queryKey[1].page === 'Bookmarks' &&
|
||||||
(queryKey[1].page === 'Bookmarks' &&
|
theParams.payload.property === 'bookmarked') ||
|
||||||
theParams.payload.property === 'bookmarked') ||
|
// Un-favourite from favourites page
|
||||||
// Un-favourite from favourites page
|
(queryKey[1].page === 'Favourites' &&
|
||||||
(queryKey[1].page === 'Favourites' &&
|
theParams.payload.property === 'favourited') ||
|
||||||
theParams.payload.property === 'favourited') ||
|
// Un-reblog from following page
|
||||||
// Un-reblog from following page
|
(queryKey[1].page === 'Following' &&
|
||||||
(queryKey[1].page === 'Following' &&
|
|
||||||
theParams.payload.property === 'reblogged' &&
|
|
||||||
theParams.payload.currentValue === true)
|
|
||||||
) {
|
|
||||||
queryClient.invalidateQueries(queryKey)
|
|
||||||
} else if (
|
|
||||||
theParams.payload.property === 'reblogged' &&
|
theParams.payload.property === 'reblogged' &&
|
||||||
queryKey[1].page !== 'Following'
|
theParams.payload.currentValue === true)
|
||||||
) {
|
) {
|
||||||
// When reblogged, update cache of following page
|
|
||||||
const tempQueryKey: QueryKeyTimeline = [
|
|
||||||
'Timeline',
|
|
||||||
{ page: 'Following' }
|
|
||||||
]
|
|
||||||
queryClient.invalidateQueries(tempQueryKey)
|
|
||||||
} else if (theParams.payload.property === 'favourited') {
|
|
||||||
// When favourited, update favourited page
|
|
||||||
const tempQueryKey: QueryKeyTimeline = [
|
|
||||||
'Timeline',
|
|
||||||
{ page: 'Favourites' }
|
|
||||||
]
|
|
||||||
queryClient.invalidateQueries(tempQueryKey)
|
|
||||||
} else if (theParams.payload.property === 'bookmarked') {
|
|
||||||
// When bookmarked, update bookmark page
|
|
||||||
const tempQueryKey: QueryKeyTimeline = [
|
|
||||||
'Timeline',
|
|
||||||
{ page: 'Bookmarks' }
|
|
||||||
]
|
|
||||||
queryClient.invalidateQueries(tempQueryKey)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onError: (err: any, params, oldData) => {
|
|
||||||
const correctParam = params as MutationVarsTimelineUpdateStatusProperty
|
|
||||||
displayMessage({
|
|
||||||
mode,
|
|
||||||
type: 'error',
|
|
||||||
message: t('common:toastMessage.error.message', {
|
|
||||||
function: t(
|
|
||||||
`shared.actions.${correctParam.payload.property}.function`
|
|
||||||
)
|
|
||||||
}),
|
|
||||||
...(err.status &&
|
|
||||||
typeof err.status === 'number' &&
|
|
||||||
err.data &&
|
|
||||||
err.data.error &&
|
|
||||||
typeof err.data.error === 'string' && {
|
|
||||||
description: err.data.error
|
|
||||||
})
|
|
||||||
})
|
|
||||||
queryClient.invalidateQueries(queryKey)
|
queryClient.invalidateQueries(queryKey)
|
||||||
|
} else if (
|
||||||
|
theParams.payload.property === 'reblogged' &&
|
||||||
|
queryKey[1].page !== 'Following'
|
||||||
|
) {
|
||||||
|
// When reblogged, update cache of following page
|
||||||
|
const tempQueryKey: QueryKeyTimeline = [
|
||||||
|
'Timeline',
|
||||||
|
{ page: 'Following' }
|
||||||
|
]
|
||||||
|
queryClient.invalidateQueries(tempQueryKey)
|
||||||
|
} else if (theParams.payload.property === 'favourited') {
|
||||||
|
// When favourited, update favourited page
|
||||||
|
const tempQueryKey: QueryKeyTimeline = [
|
||||||
|
'Timeline',
|
||||||
|
{ page: 'Favourites' }
|
||||||
|
]
|
||||||
|
queryClient.invalidateQueries(tempQueryKey)
|
||||||
|
} else if (theParams.payload.property === 'bookmarked') {
|
||||||
|
// When bookmarked, update bookmark page
|
||||||
|
const tempQueryKey: QueryKeyTimeline = [
|
||||||
|
'Timeline',
|
||||||
|
{ page: 'Bookmarks' }
|
||||||
|
]
|
||||||
|
queryClient.invalidateQueries(tempQueryKey)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onError: (err: any, params, oldData) => {
|
||||||
|
const correctParam = params as MutationVarsTimelineUpdateStatusProperty
|
||||||
|
displayMessage({
|
||||||
|
mode,
|
||||||
|
type: 'error',
|
||||||
|
message: t('common:toastMessage.error.message', {
|
||||||
|
function: t(
|
||||||
|
`shared.actions.${correctParam.payload.property}.function`
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
...(err.status &&
|
||||||
|
typeof err.status === 'number' &&
|
||||||
|
err.data &&
|
||||||
|
err.data.error &&
|
||||||
|
typeof err.data.error === 'string' && {
|
||||||
|
description: err.data.error
|
||||||
|
})
|
||||||
|
})
|
||||||
|
queryClient.invalidateQueries(queryKey)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const onPressReply = useCallback(() => {
|
||||||
|
analytics('timeline_shared_actions_reply_press', {
|
||||||
|
page: queryKey[1].page,
|
||||||
|
count: status.replies_count
|
||||||
|
})
|
||||||
|
navigation.navigate('Screen-Compose', {
|
||||||
|
type: 'reply',
|
||||||
|
incomingStatus: status,
|
||||||
|
accts,
|
||||||
|
queryKey
|
||||||
|
})
|
||||||
|
}, [status.replies_count])
|
||||||
|
const onPressReblog = useCallback(() => {
|
||||||
|
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
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}, [status.reblogged, status.reblogs_count])
|
||||||
|
const onPressFavourite = useCallback(() => {
|
||||||
|
analytics('timeline_shared_actions_favourite_press', {
|
||||||
|
page: queryKey[1].page,
|
||||||
|
count: status.favourites_count,
|
||||||
|
current: status.favourited
|
||||||
|
})
|
||||||
|
mutation.mutate({
|
||||||
|
type: 'updateStatusProperty',
|
||||||
|
queryKey,
|
||||||
|
rootQueryKey,
|
||||||
|
id: status.id,
|
||||||
|
reblog,
|
||||||
|
payload: {
|
||||||
|
property: 'favourited',
|
||||||
|
currentValue: status.favourited,
|
||||||
|
propertyCount: 'favourites_count',
|
||||||
|
countValue: status.favourites_count
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, [status.favourited, status.favourites_count])
|
||||||
|
const onPressBookmark = useCallback(() => {
|
||||||
|
analytics('timeline_shared_actions_bookmark_press', {
|
||||||
|
page: queryKey[1].page,
|
||||||
|
current: status.bookmarked
|
||||||
|
})
|
||||||
|
mutation.mutate({
|
||||||
|
type: 'updateStatusProperty',
|
||||||
|
queryKey,
|
||||||
|
rootQueryKey,
|
||||||
|
id: status.id,
|
||||||
|
reblog,
|
||||||
|
payload: {
|
||||||
|
property: 'bookmarked',
|
||||||
|
currentValue: status.bookmarked,
|
||||||
|
propertyCount: undefined,
|
||||||
|
countValue: undefined
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, [status.bookmarked])
|
||||||
|
|
||||||
const onPressReply = useCallback(() => {
|
const childrenReply = useMemo(
|
||||||
analytics('timeline_shared_actions_reply_press', {
|
() => (
|
||||||
page: queryKey[1].page,
|
<>
|
||||||
count: status.replies_count
|
|
||||||
})
|
|
||||||
navigation.navigate('Screen-Compose', {
|
|
||||||
type: 'reply',
|
|
||||||
incomingStatus: status,
|
|
||||||
accts,
|
|
||||||
queryKey
|
|
||||||
})
|
|
||||||
}, [status.replies_count])
|
|
||||||
const onPressReblog = useCallback(() => {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}, [status.reblogged, status.reblogs_count])
|
|
||||||
const onPressFavourite = useCallback(() => {
|
|
||||||
analytics('timeline_shared_actions_favourite_press', {
|
|
||||||
page: queryKey[1].page,
|
|
||||||
count: status.favourites_count,
|
|
||||||
current: status.favourited
|
|
||||||
})
|
|
||||||
mutation.mutate({
|
|
||||||
type: 'updateStatusProperty',
|
|
||||||
queryKey,
|
|
||||||
rootQueryKey,
|
|
||||||
id: status.id,
|
|
||||||
reblog,
|
|
||||||
payload: {
|
|
||||||
property: 'favourited',
|
|
||||||
currentValue: status.favourited,
|
|
||||||
propertyCount: 'favourites_count',
|
|
||||||
countValue: status.favourites_count
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}, [status.favourited, status.favourites_count])
|
|
||||||
const onPressBookmark = useCallback(() => {
|
|
||||||
analytics('timeline_shared_actions_bookmark_press', {
|
|
||||||
page: queryKey[1].page,
|
|
||||||
current: status.bookmarked
|
|
||||||
})
|
|
||||||
mutation.mutate({
|
|
||||||
type: 'updateStatusProperty',
|
|
||||||
queryKey,
|
|
||||||
rootQueryKey,
|
|
||||||
id: status.id,
|
|
||||||
reblog,
|
|
||||||
payload: {
|
|
||||||
property: 'bookmarked',
|
|
||||||
currentValue: status.bookmarked,
|
|
||||||
propertyCount: undefined,
|
|
||||||
countValue: undefined
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}, [status.bookmarked])
|
|
||||||
|
|
||||||
const childrenReply = useMemo(
|
|
||||||
() => (
|
|
||||||
<>
|
|
||||||
<Icon
|
|
||||||
name='MessageCircle'
|
|
||||||
color={iconColor}
|
|
||||||
size={StyleConstants.Font.Size.L}
|
|
||||||
/>
|
|
||||||
{status.replies_count > 0 && (
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
color: theme.secondary,
|
|
||||||
fontSize: StyleConstants.Font.Size.M,
|
|
||||||
marginLeft: StyleConstants.Spacing.XS
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{status.replies_count}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
),
|
|
||||||
[status.replies_count]
|
|
||||||
)
|
|
||||||
const childrenReblog = useMemo(() => {
|
|
||||||
const color = (state: boolean) => (state ? theme.green : theme.secondary)
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Icon
|
|
||||||
name='Repeat'
|
|
||||||
color={
|
|
||||||
status.visibility === 'private' || status.visibility === 'direct'
|
|
||||||
? theme.disabled
|
|
||||||
: color(status.reblogged)
|
|
||||||
}
|
|
||||||
size={StyleConstants.Font.Size.L}
|
|
||||||
/>
|
|
||||||
{status.reblogs_count > 0 && (
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
color: color(status.reblogged),
|
|
||||||
fontSize: StyleConstants.Font.Size.M,
|
|
||||||
marginLeft: StyleConstants.Spacing.XS
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{status.reblogs_count}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}, [status.reblogged, status.reblogs_count])
|
|
||||||
const childrenFavourite = useMemo(() => {
|
|
||||||
const color = (state: boolean) => (state ? theme.red : theme.secondary)
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Icon
|
|
||||||
name='Heart'
|
|
||||||
color={color(status.favourited)}
|
|
||||||
size={StyleConstants.Font.Size.L}
|
|
||||||
/>
|
|
||||||
{status.favourites_count > 0 && (
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
color: color(status.favourited),
|
|
||||||
fontSize: StyleConstants.Font.Size.M,
|
|
||||||
marginLeft: StyleConstants.Spacing.XS,
|
|
||||||
marginTop: 0
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{status.favourites_count}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}, [status.favourited, status.favourites_count])
|
|
||||||
const childrenBookmark = useMemo(() => {
|
|
||||||
const color = (state: boolean) => (state ? theme.yellow : theme.secondary)
|
|
||||||
return (
|
|
||||||
<Icon
|
<Icon
|
||||||
name='Bookmark'
|
name='MessageCircle'
|
||||||
color={color(status.bookmarked)}
|
color={iconColor}
|
||||||
size={StyleConstants.Font.Size.L}
|
size={StyleConstants.Font.Size.L}
|
||||||
/>
|
/>
|
||||||
)
|
{status.replies_count > 0 && (
|
||||||
}, [status.bookmarked])
|
<Text
|
||||||
|
style={{
|
||||||
|
color: theme.secondary,
|
||||||
|
fontSize: StyleConstants.Font.Size.M,
|
||||||
|
marginLeft: StyleConstants.Spacing.XS
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{status.replies_count}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
[status.replies_count]
|
||||||
|
)
|
||||||
|
const childrenReblog = useMemo(() => {
|
||||||
|
const color = (state: boolean) => (state ? theme.green : theme.secondary)
|
||||||
return (
|
return (
|
||||||
<View
|
<>
|
||||||
style={{
|
<Icon
|
||||||
paddingLeft: highlighted
|
name='Repeat'
|
||||||
? 0
|
color={
|
||||||
: StyleConstants.Avatar.M + StyleConstants.Spacing.S
|
status.visibility === 'private' || status.visibility === 'direct'
|
||||||
}}
|
? theme.disabled
|
||||||
>
|
: color(status.reblogged)
|
||||||
<View style={styles.actions}>
|
}
|
||||||
<Pressable
|
size={StyleConstants.Font.Size.L}
|
||||||
style={styles.action}
|
/>
|
||||||
onPress={onPressReply}
|
{status.reblogs_count > 0 && (
|
||||||
children={childrenReply}
|
<Text
|
||||||
/>
|
style={{
|
||||||
|
color: color(status.reblogged),
|
||||||
<Pressable
|
fontSize: StyleConstants.Font.Size.M,
|
||||||
style={styles.action}
|
marginLeft: StyleConstants.Spacing.XS
|
||||||
onPress={onPressReblog}
|
}}
|
||||||
children={childrenReblog}
|
>
|
||||||
disabled={
|
{status.reblogs_count}
|
||||||
status.visibility === 'private' || status.visibility === 'direct'
|
</Text>
|
||||||
}
|
)}
|
||||||
/>
|
</>
|
||||||
|
|
||||||
<Pressable
|
|
||||||
style={styles.action}
|
|
||||||
onPress={onPressFavourite}
|
|
||||||
children={childrenFavourite}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Pressable
|
|
||||||
style={styles.action}
|
|
||||||
onPress={onPressBookmark}
|
|
||||||
children={childrenBookmark}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
)
|
)
|
||||||
},
|
}, [status.reblogged, status.reblogs_count])
|
||||||
() => true
|
const childrenFavourite = useMemo(() => {
|
||||||
)
|
const color = (state: boolean) => (state ? theme.red : theme.secondary)
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Icon
|
||||||
|
name='Heart'
|
||||||
|
color={color(status.favourited)}
|
||||||
|
size={StyleConstants.Font.Size.L}
|
||||||
|
/>
|
||||||
|
{status.favourites_count > 0 && (
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
color: color(status.favourited),
|
||||||
|
fontSize: StyleConstants.Font.Size.M,
|
||||||
|
marginLeft: StyleConstants.Spacing.XS,
|
||||||
|
marginTop: 0
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{status.favourites_count}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}, [status.favourited, status.favourites_count])
|
||||||
|
const childrenBookmark = useMemo(() => {
|
||||||
|
const color = (state: boolean) => (state ? theme.yellow : theme.secondary)
|
||||||
|
return (
|
||||||
|
<Icon
|
||||||
|
name='Bookmark'
|
||||||
|
color={color(status.bookmarked)}
|
||||||
|
size={StyleConstants.Font.Size.L}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}, [status.bookmarked])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
paddingLeft: highlighted
|
||||||
|
? 0
|
||||||
|
: StyleConstants.Avatar.M + StyleConstants.Spacing.S
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<View style={styles.actions}>
|
||||||
|
<Pressable
|
||||||
|
style={styles.action}
|
||||||
|
onPress={onPressReply}
|
||||||
|
children={childrenReply}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Pressable
|
||||||
|
style={styles.action}
|
||||||
|
onPress={onPressReblog}
|
||||||
|
children={childrenReblog}
|
||||||
|
disabled={
|
||||||
|
status.visibility === 'private' || status.visibility === 'direct'
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Pressable
|
||||||
|
style={styles.action}
|
||||||
|
onPress={onPressFavourite}
|
||||||
|
children={childrenFavourite}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Pressable
|
||||||
|
style={styles.action}
|
||||||
|
onPress={onPressBookmark}
|
||||||
|
children={childrenBookmark}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -54,7 +54,6 @@ const HeaderConversation = React.memo(
|
|||||||
|
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const mutation = useTimelineMutation({
|
const mutation = useTimelineMutation({
|
||||||
queryClient,
|
|
||||||
onMutate: true,
|
onMutate: true,
|
||||||
onError: (err: any, _, oldData) => {
|
onError: (err: any, _, oldData) => {
|
||||||
displayMessage({
|
displayMessage({
|
||||||
|
@ -45,7 +45,6 @@ const TimelinePoll: React.FC<Props> = ({
|
|||||||
|
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const mutation = useTimelineMutation({
|
const mutation = useTimelineMutation({
|
||||||
queryClient,
|
|
||||||
onSuccess: ({ body }, params) => {
|
onSuccess: ({ body }, params) => {
|
||||||
const theParams = params as MutationVarsTimelineUpdateStatusProperty
|
const theParams = params as MutationVarsTimelineUpdateStatusProperty
|
||||||
queryClient.cancelQueries(queryKey)
|
queryClient.cancelQueries(queryKey)
|
||||||
@ -55,7 +54,7 @@ const TimelinePoll: React.FC<Props> = ({
|
|||||||
switch (theParams.payload.property) {
|
switch (theParams.payload.property) {
|
||||||
case 'poll':
|
case 'poll':
|
||||||
theParams.payload.data = (body as unknown) as Mastodon.Poll
|
theParams.payload.data = (body as unknown) as Mastodon.Poll
|
||||||
updateStatusProperty({ queryClient, ...theParams })
|
updateStatusProperty(theParams)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -29,7 +29,6 @@ const ActionsAccount: React.FC<Props> = ({
|
|||||||
|
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const mutateion = useTimelineMutation({
|
const mutateion = useTimelineMutation({
|
||||||
queryClient,
|
|
||||||
onSuccess: (_, params) => {
|
onSuccess: (_, params) => {
|
||||||
const theParams = params as MutationVarsTimelineUpdateAccountProperty
|
const theParams = params as MutationVarsTimelineUpdateAccountProperty
|
||||||
displayMessage({
|
displayMessage({
|
||||||
|
@ -30,7 +30,6 @@ const ActionsDomain: React.FC<Props> = ({
|
|||||||
const { t } = useTranslation('componentTimeline')
|
const { t } = useTranslation('componentTimeline')
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const mutation = useTimelineMutation({
|
const mutation = useTimelineMutation({
|
||||||
queryClient,
|
|
||||||
onSettled: () => {
|
onSettled: () => {
|
||||||
displayMessage({
|
displayMessage({
|
||||||
mode,
|
mode,
|
||||||
|
@ -34,7 +34,6 @@ const ActionsStatus: React.FC<Props> = ({
|
|||||||
|
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const mutation = useTimelineMutation({
|
const mutation = useTimelineMutation({
|
||||||
queryClient,
|
|
||||||
onMutate: true,
|
onMutate: true,
|
||||||
onError: (err: any, params, oldData) => {
|
onError: (err: any, params, oldData) => {
|
||||||
const theFunction = (params as MutationVarsTimelineUpdateStatusProperty)
|
const theFunction = (params as MutationVarsTimelineUpdateStatusProperty)
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
import apiInstance from '@api/instance'
|
import apiInstance from '@api/instance'
|
||||||
import haptics from '@components/haptics'
|
import haptics from '@components/haptics'
|
||||||
|
import { queryClient } from '@root/App'
|
||||||
import { store } from '@root/store'
|
import { store } from '@root/store'
|
||||||
import {
|
import { getInstanceNotificationsFilter } from '@utils/slices/instancesSlice'
|
||||||
getInstanceActive,
|
|
||||||
getInstanceNotificationsFilter
|
|
||||||
} from '@utils/slices/instancesSlice'
|
|
||||||
import { AxiosError } from 'axios'
|
import { AxiosError } from 'axios'
|
||||||
import { uniqBy } from 'lodash'
|
import { uniqBy } from 'lodash'
|
||||||
import {
|
import {
|
||||||
MutationOptions,
|
MutationOptions,
|
||||||
QueryClient,
|
|
||||||
useInfiniteQuery,
|
useInfiniteQuery,
|
||||||
UseInfiniteQueryOptions,
|
UseInfiniteQueryOptions,
|
||||||
useMutation
|
useMutation
|
||||||
@ -356,13 +353,11 @@ type MutationOptionsTimeline = MutationOptions<
|
|||||||
>
|
>
|
||||||
|
|
||||||
const useTimelineMutation = ({
|
const useTimelineMutation = ({
|
||||||
queryClient,
|
|
||||||
onError,
|
onError,
|
||||||
onMutate,
|
onMutate,
|
||||||
onSettled,
|
onSettled,
|
||||||
onSuccess
|
onSuccess
|
||||||
}: {
|
}: {
|
||||||
queryClient: QueryClient
|
|
||||||
onError?: MutationOptionsTimeline['onError']
|
onError?: MutationOptionsTimeline['onError']
|
||||||
onMutate?: boolean
|
onMutate?: boolean
|
||||||
onSettled?: MutationOptionsTimeline['onSettled']
|
onSettled?: MutationOptionsTimeline['onSettled']
|
||||||
@ -385,10 +380,10 @@ const useTimelineMutation = ({
|
|||||||
haptics('Light')
|
haptics('Light')
|
||||||
switch (params.type) {
|
switch (params.type) {
|
||||||
case 'updateStatusProperty':
|
case 'updateStatusProperty':
|
||||||
updateStatusProperty({ queryClient, ...params })
|
updateStatusProperty(params)
|
||||||
break
|
break
|
||||||
case 'deleteItem':
|
case 'deleteItem':
|
||||||
deleteItem({ queryClient, ...params })
|
deleteItem(params)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
return oldData
|
return oldData
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
import { InfiniteData, QueryClient } from 'react-query'
|
import { queryClient } from '@root/App'
|
||||||
|
import { InfiniteData } from 'react-query'
|
||||||
import { MutationVarsTimelineDeleteItem } from '../timeline'
|
import { MutationVarsTimelineDeleteItem } from '../timeline'
|
||||||
|
|
||||||
const deleteItem = ({
|
const deleteItem = ({
|
||||||
queryClient,
|
|
||||||
queryKey,
|
queryKey,
|
||||||
rootQueryKey,
|
rootQueryKey,
|
||||||
id
|
id
|
||||||
}: {
|
}: {
|
||||||
queryClient: QueryClient
|
|
||||||
queryKey?: MutationVarsTimelineDeleteItem['queryKey']
|
queryKey?: MutationVarsTimelineDeleteItem['queryKey']
|
||||||
rootQueryKey?: MutationVarsTimelineDeleteItem['rootQueryKey']
|
rootQueryKey?: MutationVarsTimelineDeleteItem['rootQueryKey']
|
||||||
id: MutationVarsTimelineDeleteItem['id']
|
id: MutationVarsTimelineDeleteItem['id']
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
import { queryClient } from '@root/App'
|
||||||
import { findIndex } from 'lodash'
|
import { findIndex } from 'lodash'
|
||||||
import { InfiniteData, QueryClient } from 'react-query'
|
import { InfiniteData } from 'react-query'
|
||||||
import {
|
import {
|
||||||
MutationVarsTimelineUpdateStatusProperty,
|
MutationVarsTimelineUpdateStatusProperty,
|
||||||
TimelineData
|
TimelineData
|
||||||
@ -9,14 +10,12 @@ import updateNotification from './update/notification'
|
|||||||
import updateStatus from './update/status'
|
import updateStatus from './update/status'
|
||||||
|
|
||||||
const updateStatusProperty = ({
|
const updateStatusProperty = ({
|
||||||
queryClient,
|
|
||||||
queryKey,
|
queryKey,
|
||||||
rootQueryKey,
|
rootQueryKey,
|
||||||
id,
|
id,
|
||||||
reblog,
|
reblog,
|
||||||
payload
|
payload
|
||||||
}: {
|
}: {
|
||||||
queryClient: QueryClient
|
|
||||||
queryKey: MutationVarsTimelineUpdateStatusProperty['queryKey']
|
queryKey: MutationVarsTimelineUpdateStatusProperty['queryKey']
|
||||||
rootQueryKey?: MutationVarsTimelineUpdateStatusProperty['rootQueryKey']
|
rootQueryKey?: MutationVarsTimelineUpdateStatusProperty['rootQueryKey']
|
||||||
id: MutationVarsTimelineUpdateStatusProperty['id']
|
id: MutationVarsTimelineUpdateStatusProperty['id']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user