mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Continue refine remote logic #638
This commit is contained in:
@ -10,7 +10,7 @@ import { handleError } from '@utils/api/helpers'
|
||||
import { RootStackScreenProps } from '@utils/navigation/navigators'
|
||||
import { useInstanceQuery } from '@utils/queryHooks/instance'
|
||||
import { usePreferencesQuery } from '@utils/queryHooks/preferences'
|
||||
import { searchFetchToot, SearchResult } from '@utils/queryHooks/search'
|
||||
import { searchLocalStatus } from '@utils/queryHooks/search'
|
||||
import { useTimelineMutation } from '@utils/queryHooks/timeline'
|
||||
import {
|
||||
getAccountStorage,
|
||||
@ -156,7 +156,7 @@ const ScreenCompose: React.FC<RootStackScreenProps<'Screen-Compose'>> = ({
|
||||
content: params.accts.map(acct => `@${acct}`).join(' ') + ' ',
|
||||
disableDebounce: true
|
||||
})
|
||||
searchFetchToot(params.incomingStatus.uri).then(status => {
|
||||
searchLocalStatus(params.incomingStatus.uri).then(status => {
|
||||
if (status?.uri === params.incomingStatus.uri) {
|
||||
composeDispatch({ type: 'updateReply', payload: status })
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { emojis } from '@components/Emojis'
|
||||
import CustomText from '@components/Text'
|
||||
import queryClient from '@utils/queryHooks'
|
||||
import { queryClient } from '@utils/queryHooks'
|
||||
import { QueryKeyInstance } from '@utils/queryHooks/instance'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import LinkifyIt from 'linkify-it'
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { MenuContainer, MenuRow } from '@components/Menu'
|
||||
import { useActionSheet } from '@expo/react-native-action-sheet'
|
||||
import { androidActionSheetStyles } from '@utils/helpers/androidActionSheetStyles'
|
||||
import queryClient from '@utils/queryHooks'
|
||||
import { TabMeProfileStackScreenProps } from '@utils/navigation/navigators'
|
||||
import { queryClient } from '@utils/queryHooks'
|
||||
import { QueryKeyPreferences } from '@utils/queryHooks/preferences'
|
||||
import { useProfileMutation, useProfileQuery } from '@utils/queryHooks/profile'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
|
@ -4,11 +4,13 @@ import { displayMessage } from '@components/Message'
|
||||
import { useActionSheet } from '@expo/react-native-action-sheet'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
import { androidActionSheetStyles } from '@utils/helpers/androidActionSheetStyles'
|
||||
import { urlMatcher } from '@utils/helpers/urlMatcher'
|
||||
import { storage } from '@utils/storage'
|
||||
import { getGlobalStorage, useGlobalStorage } from '@utils/storage/actions'
|
||||
import { StyleConstants } from '@utils/styles/constants'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import React from 'react'
|
||||
import { Alert } from 'react-native'
|
||||
import { MMKV } from 'react-native-mmkv'
|
||||
|
||||
const SettingsDev: React.FC = () => {
|
||||
@ -37,6 +39,17 @@ const SettingsDev: React.FC = () => {
|
||||
)
|
||||
}
|
||||
/>
|
||||
<Button
|
||||
type='text'
|
||||
content={'Test link matcher'}
|
||||
style={{
|
||||
marginHorizontal: StyleConstants.Spacing.Global.PagePadding * 2,
|
||||
marginBottom: StyleConstants.Spacing.Global.PagePadding
|
||||
}}
|
||||
onPress={() =>
|
||||
Alert.prompt('URL', undefined, text => console.log(urlMatcher(text)), 'plain-text')
|
||||
}
|
||||
/>
|
||||
<Button
|
||||
type='text'
|
||||
content={'Test flash message'}
|
||||
|
@ -32,6 +32,7 @@ const TabSharedAccount: React.FC<TabSharedStackScreenProps<'Tab-Shared-Account'>
|
||||
|
||||
const { data, dataUpdatedAt } = useAccountQuery({
|
||||
account,
|
||||
_local: true,
|
||||
options: {
|
||||
onSuccess: a => {
|
||||
if (account._remote) {
|
||||
|
@ -111,11 +111,11 @@ const ContentView: React.FC<{
|
||||
const TabSharedHistory: React.FC<TabSharedStackScreenProps<'Tab-Shared-History'>> = ({
|
||||
navigation,
|
||||
route: {
|
||||
params: { id, detectedLanguage }
|
||||
params: { status, detectedLanguage }
|
||||
}
|
||||
}) => {
|
||||
const { t } = useTranslation('screenTabs')
|
||||
const { data } = useStatusHistory({ id })
|
||||
const { data } = useStatusHistory({ status })
|
||||
|
||||
useEffect(() => {
|
||||
navigation.setOptions({
|
||||
|
@ -5,7 +5,7 @@ import CustomText from '@components/Text'
|
||||
import apiInstance from '@utils/api/instance'
|
||||
import { TabSharedStackScreenProps } from '@utils/navigation/navigators'
|
||||
import { useRulesQuery } from '@utils/queryHooks/reports'
|
||||
import { searchFetchToot } from '@utils/queryHooks/search'
|
||||
import { searchLocalStatus } from '@utils/queryHooks/search'
|
||||
import { getAccountStorage } from '@utils/storage/actions'
|
||||
import { StyleConstants } from '@utils/styles/constants'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
@ -55,7 +55,7 @@ const TabSharedReport: React.FC<TabSharedStackScreenProps<'Tab-Shared-Report'>>
|
||||
const body = new FormData()
|
||||
if (status) {
|
||||
if (status._remote) {
|
||||
const fetchedStatus = await searchFetchToot(status.uri)
|
||||
const fetchedStatus = await searchLocalStatus(status.uri)
|
||||
if (fetchedStatus) {
|
||||
body.append('status_ids[]', fetchedStatus.id)
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import TimelineDefault from '@components/Timeline/Default'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import apiGeneral from '@utils/api/general'
|
||||
import apiInstance from '@utils/api/instance'
|
||||
import { getHost } from '@utils/helpers/urlMatcher'
|
||||
import { urlMatcher } from '@utils/helpers/urlMatcher'
|
||||
import { TabSharedStackScreenProps } from '@utils/navigation/navigators'
|
||||
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||
import { getAccountStorage } from '@utils/storage/actions'
|
||||
@ -66,6 +66,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
||||
const flRef = useRef<FlatList>(null)
|
||||
const scrolled = useRef(false)
|
||||
|
||||
const match = urlMatcher(toot.url || toot.uri)
|
||||
const finalData = useRef<(Mastodon.Status & { key?: string })[]>([
|
||||
{ ...toot, _level: 0, key: 'cached' }
|
||||
])
|
||||
@ -145,11 +146,11 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
||||
useQuery(
|
||||
queryKey.remote,
|
||||
async () => {
|
||||
const domain = getHost(toot.url || toot.uri)
|
||||
const domain = match?.domain
|
||||
if (!domain?.length) {
|
||||
return Promise.reject('Cannot parse remote doamin')
|
||||
}
|
||||
const id = (toot.url || toot.uri).match(new RegExp(/\/([0-9]+)$/))?.[1]
|
||||
const id = match?.status?.id
|
||||
if (!id?.length) {
|
||||
return Promise.reject('Cannot parse remote toot id')
|
||||
}
|
||||
@ -191,7 +192,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
||||
{
|
||||
enabled:
|
||||
['public', 'unlisted'].includes(toot.visibility) &&
|
||||
getHost(toot.uri) !== getAccountStorage.string('auth.domain'),
|
||||
match?.domain !== getAccountStorage.string('auth.domain'),
|
||||
staleTime: 0,
|
||||
refetchOnMount: true,
|
||||
onSuccess: data => {
|
||||
|
Reference in New Issue
Block a user