mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Fix toot action for #638
This commit is contained in:
6
src/@types/mastodon.d.ts
vendored
6
src/@types/mastodon.d.ts
vendored
@ -31,6 +31,9 @@ declare namespace Mastodon {
|
||||
source?: Source
|
||||
suspended?: boolean
|
||||
role?: Role
|
||||
|
||||
// Internal
|
||||
_remote?: boolean
|
||||
}
|
||||
|
||||
type Announcement = {
|
||||
@ -389,6 +392,9 @@ declare namespace Mastodon {
|
||||
username: string
|
||||
acct: string
|
||||
url: string
|
||||
|
||||
// Internal
|
||||
_remote?: boolean
|
||||
}
|
||||
|
||||
type Notification =
|
||||
|
@ -11,7 +11,7 @@ import Icon from './Icon'
|
||||
import CustomText from './Text'
|
||||
|
||||
export interface Props {
|
||||
account: Partial<Mastodon.Account> & Pick<Mastodon.Account, 'id' | 'acct' | 'username'>
|
||||
account: Partial<Mastodon.Account> & Pick<Mastodon.Account, 'id' | 'acct' | 'username' | 'url'>
|
||||
props?: PressableProps
|
||||
}
|
||||
|
||||
|
@ -168,10 +168,7 @@ const ParseHTML: React.FC<Props> = ({
|
||||
matchedMention &&
|
||||
!disableDetails &&
|
||||
!sameAccount &&
|
||||
navigation.push('Tab-Shared-Account', {
|
||||
account: matchedMention,
|
||||
isRemote: status?._remote
|
||||
})
|
||||
navigation.push('Tab-Shared-Account', { account: matchedMention })
|
||||
}
|
||||
children={node.children.map(unwrapNode).join('')}
|
||||
/>
|
||||
|
@ -37,7 +37,6 @@ export interface Props {
|
||||
disableDetails?: boolean
|
||||
disableOnPress?: boolean
|
||||
isConversation?: boolean
|
||||
isRemote?: boolean
|
||||
}
|
||||
|
||||
// When the poll is long
|
||||
@ -48,8 +47,7 @@ const TimelineDefault: React.FC<Props> = ({
|
||||
highlighted = false,
|
||||
disableDetails = false,
|
||||
disableOnPress = false,
|
||||
isConversation = false,
|
||||
isRemote = false
|
||||
isConversation = false
|
||||
}) => {
|
||||
const status = item.reblog ? item.reblog : item
|
||||
const rawContent = useRef<string[]>([])
|
||||
@ -177,7 +175,7 @@ const TimelineDefault: React.FC<Props> = ({
|
||||
disableDetails,
|
||||
disableOnPress,
|
||||
isConversation,
|
||||
isRemote
|
||||
isRemote: item._remote
|
||||
}}
|
||||
>
|
||||
{disableOnPress ? (
|
||||
|
@ -38,7 +38,7 @@ const TimelineActioned: React.FC<Props> = ({ action, isNotification, ...rest })
|
||||
)
|
||||
|
||||
const onPress = () =>
|
||||
navigation.push('Tab-Shared-Account', { account, isRemote: status?._remote })
|
||||
navigation.push('Tab-Shared-Account', { account })
|
||||
|
||||
const children = () => {
|
||||
switch (action) {
|
||||
|
@ -114,7 +114,8 @@ const TimelineActions: React.FC = () => {
|
||||
status,
|
||||
payload: {
|
||||
type: 'reblogged',
|
||||
visibility: 'public'
|
||||
visibility: 'public',
|
||||
to: true
|
||||
}
|
||||
})
|
||||
break
|
||||
@ -126,7 +127,8 @@ const TimelineActions: React.FC = () => {
|
||||
status,
|
||||
payload: {
|
||||
type: 'reblogged',
|
||||
visibility: 'unlisted'
|
||||
visibility: 'unlisted',
|
||||
to: true
|
||||
}
|
||||
})
|
||||
break
|
||||
@ -141,7 +143,8 @@ const TimelineActions: React.FC = () => {
|
||||
status,
|
||||
payload: {
|
||||
type: 'reblogged',
|
||||
visibility: 'public'
|
||||
visibility: 'public',
|
||||
to: false
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -153,7 +156,8 @@ const TimelineActions: React.FC = () => {
|
||||
rootQueryKey,
|
||||
status,
|
||||
payload: {
|
||||
type: 'favourited'
|
||||
type: 'favourited',
|
||||
to: !status.favourited
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -164,7 +168,8 @@ const TimelineActions: React.FC = () => {
|
||||
rootQueryKey,
|
||||
status,
|
||||
payload: {
|
||||
type: 'bookmarked'
|
||||
type: 'bookmarked',
|
||||
to: !status.bookmarked
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ const TimelineAvatar: React.FC<Props> = ({ account }) => {
|
||||
})}
|
||||
onPress={() =>
|
||||
!disableOnPress &&
|
||||
navigation.push('Tab-Shared-Account', { account: actualAccount, isRemote: status?._remote })
|
||||
navigation.push('Tab-Shared-Account', { account: actualAccount })
|
||||
}
|
||||
uri={{ original: actualAccount.avatar, static: actualAccount.avatar_static }}
|
||||
dimension={
|
||||
|
@ -86,7 +86,8 @@ const TimelineCard: React.FC = () => {
|
||||
}, [])
|
||||
|
||||
const accountQuery = useAccountQuery({
|
||||
id: isAccount?.style === 'default' ? isAccount.id : '',
|
||||
account:
|
||||
isAccount?.style === 'default' ? { id: isAccount.id, url: status.card.url } : undefined,
|
||||
options: { enabled: false }
|
||||
})
|
||||
useEffect(() => {
|
||||
|
@ -30,7 +30,7 @@ const menuAccount = ({
|
||||
}: {
|
||||
type: 'status' | 'account' // Where the action is coming from
|
||||
openChange: boolean
|
||||
account?: Partial<Mastodon.Account> & Pick<Mastodon.Account, 'id' | 'username' | 'acct'>
|
||||
account?: Partial<Mastodon.Account> & Pick<Mastodon.Account, 'id' | 'username' | 'acct' | 'url'>
|
||||
status?: Mastodon.Status
|
||||
queryKey?: QueryKeyTimeline
|
||||
rootQueryKey?: QueryKeyTimeline
|
||||
@ -47,10 +47,7 @@ const menuAccount = ({
|
||||
setEnabled(true)
|
||||
}
|
||||
}, [openChange, enabled])
|
||||
const { data: fetchedAccount } = useAccountQuery({
|
||||
remoteUrl: account?.url,
|
||||
options: { enabled: !!status?._remote && enabled }
|
||||
})
|
||||
const { data: fetchedAccount } = useAccountQuery({ account, options: { enabled } })
|
||||
const actualAccount = status?._remote ? fetchedAccount : account
|
||||
const { data, isFetched } = useRelationshipQuery({
|
||||
id: actualAccount?.id,
|
||||
|
@ -197,7 +197,8 @@ const menuStatus = ({
|
||||
rootQueryKey,
|
||||
status,
|
||||
payload: {
|
||||
type: 'muted'
|
||||
type: 'muted',
|
||||
to: !status.muted
|
||||
}
|
||||
}),
|
||||
disabled: false,
|
||||
@ -221,7 +222,8 @@ const menuStatus = ({
|
||||
rootQueryKey,
|
||||
status,
|
||||
payload: {
|
||||
type: 'pinned'
|
||||
type: 'pinned',
|
||||
to: !status.pinned
|
||||
}
|
||||
}),
|
||||
disabled: status.visibility !== 'public' && status.visibility !== 'unlisted',
|
||||
|
@ -24,15 +24,30 @@ import AccountNav from './Nav'
|
||||
const TabSharedAccount: React.FC<TabSharedStackScreenProps<'Tab-Shared-Account'>> = ({
|
||||
navigation,
|
||||
route: {
|
||||
params: { account, isRemote }
|
||||
params: { account }
|
||||
}
|
||||
}) => {
|
||||
const { t } = useTranslation('screenTabs')
|
||||
const { colors, mode } = useTheme()
|
||||
|
||||
const { data, dataUpdatedAt } = useAccountQuery({
|
||||
id: account.id,
|
||||
...(isRemote && { remoteUrl: account.url })
|
||||
account,
|
||||
options: {
|
||||
onSuccess: a => {
|
||||
if (account._remote) {
|
||||
setQueryKey([
|
||||
queryKey[0],
|
||||
{
|
||||
...queryKey[1],
|
||||
page: 'Account',
|
||||
id: a.id,
|
||||
exclude_reblogs: true,
|
||||
only_media: false
|
||||
}
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const mShare = menuShare({ type: 'account', url: data?.url })
|
||||
@ -87,7 +102,12 @@ const TabSharedAccount: React.FC<TabSharedStackScreenProps<'Tab-Shared-Account'>
|
||||
const queryClient = useQueryClient()
|
||||
const [queryKey, setQueryKey] = useState<QueryKeyTimeline>([
|
||||
'Timeline',
|
||||
{ page: 'Account', id: data?.id, exclude_reblogs: true, only_media: false }
|
||||
{
|
||||
page: 'Account',
|
||||
id: account._remote ? data?.id : account.id,
|
||||
exclude_reblogs: true,
|
||||
only_media: false
|
||||
}
|
||||
])
|
||||
const page = queryKey[1]
|
||||
|
||||
@ -174,7 +194,7 @@ const TabSharedAccount: React.FC<TabSharedStackScreenProps<'Tab-Shared-Account'>
|
||||
<Timeline
|
||||
queryKey={queryKey}
|
||||
disableRefresh
|
||||
queryOptions={{ enabled: isRemote ? !!data?.id : true }}
|
||||
queryOptions={{ enabled: account._remote ? !!data?.id : true }}
|
||||
customProps={{
|
||||
renderItem: ({ item }) => <TimelineDefault item={item} queryKey={queryKey} />,
|
||||
onScroll: ({ nativeEvent }) => (scrollY.value = nativeEvent.contentOffset.y),
|
||||
|
@ -9,6 +9,7 @@ import apiInstance from '@utils/api/instance'
|
||||
import { getHost } from '@utils/helpers/urlMatcher'
|
||||
import { TabSharedStackScreenProps } from '@utils/navigation/navigators'
|
||||
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||
import { getAccountStorage } from '@utils/storage/actions'
|
||||
import { StyleConstants } from '@utils/styles/constants'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
@ -65,8 +66,8 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
||||
const flRef = useRef<FlatList>(null)
|
||||
const scrolled = useRef(false)
|
||||
|
||||
const finalData = useRef<Mastodon.Status[]>([
|
||||
{ ...toot, _level: 0, _remote: toot._remote }
|
||||
const finalData = useRef<(Mastodon.Status & { key?: string })[]>([
|
||||
{ ...toot, _level: 0, key: 'cached' }
|
||||
])
|
||||
const highlightIndex = useRef<number>(0)
|
||||
const queryKey: { local: QueryKeyTimeline; remote: QueryKeyTimeline } = {
|
||||
@ -86,7 +87,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
||||
|
||||
const statuses: (Mastodon.Status & { _level?: number })[] = [
|
||||
...context.body.ancestors,
|
||||
toot,
|
||||
{ ...toot },
|
||||
...context.body.descendants
|
||||
]
|
||||
|
||||
@ -115,8 +116,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
||||
return
|
||||
}
|
||||
|
||||
if (finalData.current.length < data.pages[0].body.length) {
|
||||
// if the remote has been loaded first
|
||||
if (finalData.current[0].key === 'cached') {
|
||||
finalData.current = data.pages[0].body
|
||||
|
||||
if (!scrolled.current) {
|
||||
@ -178,7 +178,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
||||
|
||||
const statuses: (Mastodon.Status & { _level?: number })[] = [
|
||||
...context.ancestors,
|
||||
toot,
|
||||
{ ...toot },
|
||||
...context.descendants
|
||||
]
|
||||
|
||||
@ -198,7 +198,9 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
||||
return { pages: [{ body: statuses }] }
|
||||
},
|
||||
{
|
||||
enabled: toot.account.acct !== toot.account.username, // When on the same instance, these two values are the same
|
||||
enabled:
|
||||
['public', 'unlisted'].includes(toot.visibility) &&
|
||||
getHost(toot.uri) !== getAccountStorage.string('auth.domain'),
|
||||
staleTime: 0,
|
||||
refetchOnMount: true,
|
||||
onSuccess: data => {
|
||||
@ -211,12 +213,25 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
||||
finalData.current = data.pages[0].body.map(remote => {
|
||||
const localMatch = finalData.current.find(local => local.uri === remote.uri)
|
||||
if (localMatch) {
|
||||
delete localMatch.key
|
||||
return localMatch
|
||||
} else {
|
||||
remote._remote = true
|
||||
|
||||
remote.account._remote = true
|
||||
remote.mentions = remote.mentions.map(mention => ({ ...mention, _remote: true }))
|
||||
if (remote.reblog) {
|
||||
remote.reblog.account._remote = true
|
||||
remote.reblog.mentions = remote.mentions.map(mention => ({
|
||||
...mention,
|
||||
_remote: true
|
||||
}))
|
||||
}
|
||||
|
||||
return remote
|
||||
}
|
||||
})
|
||||
|
||||
setHasRemoteContent(true)
|
||||
}
|
||||
|
||||
@ -274,9 +289,8 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
||||
item={item}
|
||||
queryKey={item._remote ? queryKey.remote : queryKey.local}
|
||||
rootQueryKey={rootQueryKey}
|
||||
highlighted={toot.id === item.id}
|
||||
isConversation={toot.id !== item.id}
|
||||
isRemote={item._remote}
|
||||
highlighted={toot.id === item.id || item.id === 'cached'}
|
||||
isConversation={toot.id !== item.id && item.id !== 'cached'}
|
||||
/>
|
||||
{curr > 1 || next > 1
|
||||
? [...new Array(curr)].map((_, i) => {
|
||||
|
@ -84,8 +84,7 @@ export type ScreenTabsScreenProps<T extends keyof ScreenTabsStackParamList> = Bo
|
||||
|
||||
export type TabSharedStackParamList = {
|
||||
'Tab-Shared-Account': {
|
||||
account: Partial<Mastodon.Account> & Pick<Mastodon.Account, 'id' | 'username' | 'acct'>
|
||||
isRemote?: boolean
|
||||
account: Pick<Mastodon.Account, 'id' | 'username' | 'acct' | 'url' | '_remote'>
|
||||
}
|
||||
'Tab-Shared-Account-In-Lists': {
|
||||
account: Pick<Mastodon.Account, 'id' | 'username'>
|
||||
@ -99,7 +98,7 @@ export type TabSharedStackParamList = {
|
||||
detectedLanguage: string
|
||||
}
|
||||
'Tab-Shared-Report': {
|
||||
account: Partial<Mastodon.Account> & Pick<Mastodon.Account, 'id' | 'acct' | 'username'>
|
||||
account: Pick<Mastodon.Account, 'id' | 'acct' | 'username' | 'url'>
|
||||
status?: Pick<Mastodon.Status, 'id' | '_remote' | 'uri'>
|
||||
}
|
||||
'Tab-Shared-Search': undefined
|
||||
|
@ -3,21 +3,24 @@ import apiInstance from '@utils/api/instance'
|
||||
import { AxiosError } from 'axios'
|
||||
import { SearchResult } from './search'
|
||||
|
||||
export type QueryKeyAccount = ['Account', { id?: Mastodon.Account['id']; remoteUrl?: string }]
|
||||
export type QueryKeyAccount = [
|
||||
'Account',
|
||||
Pick<Mastodon.Account, 'id' | 'url' | '_remote'> | undefined
|
||||
]
|
||||
|
||||
const accountQueryFunction = async ({ queryKey }: QueryFunctionContext<QueryKeyAccount>) => {
|
||||
const { id, remoteUrl } = queryKey[1]
|
||||
if (!id && !remoteUrl) return Promise.reject()
|
||||
const key = queryKey[1]
|
||||
if (!key) return Promise.reject()
|
||||
|
||||
let matchedId = id
|
||||
let matchedId = key.id
|
||||
|
||||
if (remoteUrl) {
|
||||
if (key._remote) {
|
||||
await apiInstance<SearchResult>({
|
||||
version: 'v2',
|
||||
method: 'get',
|
||||
url: 'search',
|
||||
params: {
|
||||
q: remoteUrl,
|
||||
q: key.url,
|
||||
type: 'accounts',
|
||||
limit: 1,
|
||||
resolve: true
|
||||
@ -25,7 +28,7 @@ const accountQueryFunction = async ({ queryKey }: QueryFunctionContext<QueryKeyA
|
||||
})
|
||||
.then(res => {
|
||||
const account = res.body.accounts[0]
|
||||
if (account.url !== remoteUrl) {
|
||||
if (account.url !== key.url) {
|
||||
return Promise.reject()
|
||||
} else {
|
||||
matchedId = account.id
|
||||
@ -44,11 +47,23 @@ const accountQueryFunction = async ({ queryKey }: QueryFunctionContext<QueryKeyA
|
||||
const useAccountQuery = ({
|
||||
options,
|
||||
...queryKeyParams
|
||||
}: QueryKeyAccount[1] & {
|
||||
}: { account?: QueryKeyAccount[1] } & {
|
||||
options?: UseQueryOptions<Mastodon.Account, AxiosError>
|
||||
}) => {
|
||||
const queryKey: QueryKeyAccount = ['Account', { ...queryKeyParams }]
|
||||
return useQuery(queryKey, accountQueryFunction, { ...options })
|
||||
const queryKey: QueryKeyAccount = [
|
||||
'Account',
|
||||
queryKeyParams.account
|
||||
? {
|
||||
id: queryKeyParams.account.id,
|
||||
url: queryKeyParams.account.url,
|
||||
_remote: queryKeyParams.account._remote
|
||||
}
|
||||
: undefined
|
||||
]
|
||||
return useQuery(queryKey, accountQueryFunction, {
|
||||
...options,
|
||||
enabled: (queryKeyParams.account?._remote ? !!queryKeyParams.account : true) && options?.enabled
|
||||
})
|
||||
}
|
||||
|
||||
/* ----- */
|
||||
|
@ -18,4 +18,9 @@ const queryClient = new QueryClient({
|
||||
}
|
||||
})
|
||||
|
||||
// @ts-ignore
|
||||
import('react-query-native-devtools').then(({ addPlugin }) => {
|
||||
addPlugin({ queryClient })
|
||||
})
|
||||
|
||||
export default queryClient
|
||||
|
@ -20,7 +20,7 @@ export type SearchResult = {
|
||||
const queryFunction = async ({ queryKey }: QueryFunctionContext<QueryKeySearch>) => {
|
||||
const { type, term, limit = 20 } = queryKey[1]
|
||||
if (!term?.length) {
|
||||
return Promise.reject()
|
||||
return Promise.reject('Empty search term')
|
||||
}
|
||||
const res = await apiInstance<SearchResult>({
|
||||
version: 'v2',
|
||||
@ -59,6 +59,6 @@ export const searchFetchToot = (uri: Mastodon.Status['uri']): Promise<Mastodon.S
|
||||
}
|
||||
})
|
||||
.then(res => res.body.statuses[0])
|
||||
.catch(() => {})
|
||||
.catch(err => console.warn(err))
|
||||
|
||||
export { useSearchQuery }
|
||||
|
@ -37,11 +37,11 @@ const useFollowedTagsQuery = (
|
||||
})
|
||||
},
|
||||
{
|
||||
enabled: canFollowTags,
|
||||
staleTime: Infinity,
|
||||
cacheTime: Infinity,
|
||||
...params?.options,
|
||||
...infinitePageParams,
|
||||
enabled: canFollowTags && params?.options?.enabled,
|
||||
onSuccess: data => {
|
||||
setAccountStorage([
|
||||
{
|
||||
|
@ -131,7 +131,7 @@ const queryFunction = async ({ queryKey, pageParam }: QueryFunctionContext<Query
|
||||
})
|
||||
|
||||
case 'Account':
|
||||
if (!page.id) return Promise.reject()
|
||||
if (!page.id) return Promise.reject('Timeline query account id not provided')
|
||||
|
||||
if (page.exclude_reblogs) {
|
||||
if (pageParam && pageParam.hasOwnProperty('max_id')) {
|
||||
@ -214,7 +214,7 @@ const queryFunction = async ({ queryKey, pageParam }: QueryFunctionContext<Query
|
||||
params
|
||||
})
|
||||
default:
|
||||
return Promise.reject()
|
||||
return Promise.reject('Timeline query no page matched')
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,11 +253,17 @@ export type MutationVarsTimelineUpdateStatusProperty = {
|
||||
status: Mastodon.Status
|
||||
payload:
|
||||
| {
|
||||
type: 'bookmarked' | 'muted' | 'pinned' | 'favourited'
|
||||
type: 'bookmarked' | 'muted' | 'pinned'
|
||||
to: boolean
|
||||
}
|
||||
| {
|
||||
type: 'favourited'
|
||||
to: boolean
|
||||
}
|
||||
| {
|
||||
type: 'reblogged'
|
||||
visibility: 'public' | 'unlisted'
|
||||
to: boolean
|
||||
}
|
||||
| {
|
||||
type: 'poll'
|
||||
@ -340,7 +346,7 @@ const mutationFunction = async (params: MutationVarsTimeline) => {
|
||||
if (fetched) {
|
||||
tootId = fetched.id
|
||||
} else {
|
||||
return Promise.reject()
|
||||
return Promise.reject('Fetching for remote toot failed')
|
||||
}
|
||||
}
|
||||
const body = new FormData()
|
||||
@ -349,7 +355,7 @@ const mutationFunction = async (params: MutationVarsTimeline) => {
|
||||
}
|
||||
return apiInstance<Mastodon.Status>({
|
||||
method: 'post',
|
||||
url: `statuses/${tootId}/${params.status[params.payload.type] ? '' : 'un'}${
|
||||
url: `statuses/${tootId}/${params.payload.to ? '' : 'un'}${
|
||||
MapPropertyToUrl[params.payload.type]
|
||||
}`,
|
||||
...(params.payload.type === 'reblogged' && { body })
|
||||
|
@ -9,10 +9,11 @@ const updateStatusProperty = ({
|
||||
payload,
|
||||
poll
|
||||
}: MutationVarsTimelineUpdateStatusProperty & { poll?: Mastodon.Poll }) => {
|
||||
for (const key of [queryKey, rootQueryKey]) {
|
||||
for (const key of [queryKey]) {
|
||||
if (!key) continue
|
||||
|
||||
queryClient.setQueryData<InfiniteData<TimelineData> | undefined>(key, old => {
|
||||
console.log('key', key)
|
||||
if (old) {
|
||||
let foundToot: Mastodon.Status | undefined = undefined
|
||||
old.pages = old.pages.map(page => {
|
||||
@ -25,7 +26,6 @@ const updateStatusProperty = ({
|
||||
? last_status.reblog.id === status.id
|
||||
: last_status?.id === status.id
|
||||
)?.last_status
|
||||
return page
|
||||
} else if (typeof (page.body as Mastodon.Notification[])[0].type === 'string') {
|
||||
foundToot = (page.body as Mastodon.Notification[]).find(no =>
|
||||
no.status?.reblog ? no.status.reblog.id === status.id : no.status?.id === status.id
|
||||
@ -41,6 +41,8 @@ const updateStatusProperty = ({
|
||||
})
|
||||
|
||||
if (foundToot) {
|
||||
const toot = foundToot as Mastodon.Status
|
||||
console.log('updating', toot.id)
|
||||
enum MapPropertyToCount {
|
||||
favourited = 'favourites_count',
|
||||
reblogged = 'reblogs_count'
|
||||
@ -48,18 +50,19 @@ const updateStatusProperty = ({
|
||||
|
||||
switch (payload.type) {
|
||||
case 'poll':
|
||||
status.poll = poll
|
||||
toot.poll = poll
|
||||
break
|
||||
default:
|
||||
status[payload.type] =
|
||||
typeof status[payload.type] === 'boolean' ? !status[payload.type] : true
|
||||
console.log('11', toot[payload.type])
|
||||
toot[payload.type] = payload.to
|
||||
console.log('22', toot[payload.type])
|
||||
switch (payload.type) {
|
||||
case 'favourited':
|
||||
case 'reblogged':
|
||||
if (typeof status[payload.type] === 'boolean' && status[payload.type]) {
|
||||
status[MapPropertyToCount[payload.type]]--
|
||||
if (payload.to) {
|
||||
toot[MapPropertyToCount[payload.type]]++
|
||||
} else {
|
||||
status[MapPropertyToCount[payload.type]]++
|
||||
toot[MapPropertyToCount[payload.type]]--
|
||||
}
|
||||
break
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ export const generateAccountKey = ({
|
||||
export const setAccount = async (account: string) => {
|
||||
storage.account = new MMKV({ id: account })
|
||||
setGlobalStorage('account.active', account)
|
||||
await queryClient.resetQueries()
|
||||
queryClient.clear()
|
||||
}
|
||||
|
||||
export const removeAccount = async (account: string) => {
|
||||
|
Reference in New Issue
Block a user