mirror of
https://github.com/tooot-app/app
synced 2025-04-23 14:47:21 +02:00
Fix Sentry reported crashes
This commit is contained in:
parent
db6b5e4e70
commit
e5f750c3c8
@ -89,7 +89,7 @@ const contextMenuStatus = ({
|
|||||||
{
|
{
|
||||||
id: 'status-mute',
|
id: 'status-mute',
|
||||||
title: t('status.mute.action', {
|
title: t('status.mute.action', {
|
||||||
context: status.muted.toString()
|
context: (status.muted || false).toString()
|
||||||
}),
|
}),
|
||||||
systemIcon: status.muted ? 'speaker' : 'speaker.slash'
|
systemIcon: status.muted ? 'speaker' : 'speaker.slash'
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ const contextMenuStatus = ({
|
|||||||
accountMenuItems.push({
|
accountMenuItems.push({
|
||||||
id: 'status-pin',
|
id: 'status-pin',
|
||||||
title: t('status.pin.action', {
|
title: t('status.pin.action', {
|
||||||
context: status.pinned.toString()
|
context: (status.pinned || false).toString()
|
||||||
}),
|
}),
|
||||||
systemIcon: status.pinned ? 'pin.slash' : 'pin'
|
systemIcon: status.pinned ? 'pin.slash' : 'pin'
|
||||||
})
|
})
|
||||||
|
@ -12,33 +12,6 @@ import { Edge, SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-co
|
|||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
import EmojisContext, { Emojis, emojisReducer, EmojisState } from './Emojis/helpers/EmojisContext'
|
import EmojisContext, { Emojis, emojisReducer, EmojisState } from './Emojis/helpers/EmojisContext'
|
||||||
|
|
||||||
const prefetchEmojis = (
|
|
||||||
sortedEmojis: {
|
|
||||||
title: string
|
|
||||||
data: Pick<Mastodon.Emoji, 'shortcode' | 'url' | 'static_url'>[][]
|
|
||||||
}[],
|
|
||||||
reduceMotionEnabled: boolean
|
|
||||||
) => {
|
|
||||||
const prefetches: { uri: string }[] = []
|
|
||||||
let requestedIndex = 0
|
|
||||||
sortedEmojis.forEach(sorted => {
|
|
||||||
sorted.data.forEach(emojis =>
|
|
||||||
emojis.forEach(emoji => {
|
|
||||||
if (requestedIndex > 40) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
prefetches.push({
|
|
||||||
uri: reduceMotionEnabled ? emoji.static_url : emoji.url
|
|
||||||
})
|
|
||||||
requestedIndex++
|
|
||||||
})
|
|
||||||
)
|
|
||||||
})
|
|
||||||
try {
|
|
||||||
FastImage.preload(prefetches)
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
inputProps: EmojisState['inputProps']
|
inputProps: EmojisState['inputProps']
|
||||||
customButton?: boolean
|
customButton?: boolean
|
||||||
@ -82,7 +55,6 @@ const ComponentEmojis: React.FC<Props & PropsWithChildren> = ({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
emojis.current = sortedEmojis
|
emojis.current = sortedEmojis
|
||||||
prefetchEmojis(sortedEmojis, reduceMotionEnabled)
|
|
||||||
}
|
}
|
||||||
}, [data, reduceMotionEnabled])
|
}, [data, reduceMotionEnabled])
|
||||||
|
|
||||||
|
@ -6,10 +6,7 @@ import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { createContext } from 'react'
|
import { createContext } from 'react'
|
||||||
import { Platform } from 'react-native'
|
import { Platform } from 'react-native'
|
||||||
import ContextMenu, {
|
import ContextMenu, { ContextMenuAction, ContextMenuProps } from 'react-native-context-menu-view'
|
||||||
ContextMenuAction,
|
|
||||||
ContextMenuProps
|
|
||||||
} from 'react-native-context-menu-view'
|
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
copiableContent: React.MutableRefObject<{
|
copiableContent: React.MutableRefObject<{
|
||||||
@ -52,13 +49,15 @@ const TimelineContextMenu: React.FC<Props & ContextMenuProps> = ({
|
|||||||
queryKey,
|
queryKey,
|
||||||
rootQueryKey
|
rootQueryKey
|
||||||
})
|
})
|
||||||
const accountOnPress = contextMenuAccount({
|
const accountOnPress = status?.account?.id
|
||||||
|
? contextMenuAccount({
|
||||||
actions,
|
actions,
|
||||||
type: 'status',
|
type: 'status',
|
||||||
queryKey,
|
queryKey,
|
||||||
rootQueryKey,
|
rootQueryKey,
|
||||||
id: status.account.id
|
id: status.account.id
|
||||||
})
|
})
|
||||||
|
: null
|
||||||
const instanceOnPress = contextMenuInstance({
|
const instanceOnPress = contextMenuInstance({
|
||||||
actions,
|
actions,
|
||||||
status,
|
status,
|
||||||
@ -71,12 +70,7 @@ const TimelineContextMenu: React.FC<Props & ContextMenuProps> = ({
|
|||||||
<ContextMenu
|
<ContextMenu
|
||||||
actions={actions}
|
actions={actions}
|
||||||
onPress={({ nativeEvent: { index } }) => {
|
onPress={({ nativeEvent: { index } }) => {
|
||||||
for (const on of [
|
for (const on of [shareOnPress, statusOnPress, accountOnPress, instanceOnPress]) {
|
||||||
shareOnPress,
|
|
||||||
statusOnPress,
|
|
||||||
accountOnPress,
|
|
||||||
instanceOnPress
|
|
||||||
]) {
|
|
||||||
on && on(index)
|
on && on(index)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
@ -88,7 +88,7 @@ const composeReducer = (
|
|||||||
attachments: {
|
attachments: {
|
||||||
...state.attachments,
|
...state.attachments,
|
||||||
uploads: state.attachments.uploads.map(upload =>
|
uploads: state.attachments.uploads.map(upload =>
|
||||||
upload.remote!.id === action.payload!.id
|
upload.remote?.id === action.payload?.id
|
||||||
? { ...upload, remote: action.payload }
|
? { ...upload, remote: action.payload }
|
||||||
: upload
|
: upload
|
||||||
)
|
)
|
||||||
|
@ -21,8 +21,7 @@ import FlashMessage from 'react-native-flash-message'
|
|||||||
import {
|
import {
|
||||||
Directions,
|
Directions,
|
||||||
FlingGestureHandler,
|
FlingGestureHandler,
|
||||||
LongPressGestureHandler,
|
LongPressGestureHandler
|
||||||
State
|
|
||||||
} from 'react-native-gesture-handler'
|
} from 'react-native-gesture-handler'
|
||||||
import { Zoom, createZoomListComponent } from 'react-native-reanimated-zoom'
|
import { Zoom, createZoomListComponent } from 'react-native-reanimated-zoom'
|
||||||
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context'
|
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||||
@ -142,7 +141,7 @@ const ScreenImagesViewer = ({
|
|||||||
|
|
||||||
const onViewableItemsChanged = useCallback(
|
const onViewableItemsChanged = useCallback(
|
||||||
({ viewableItems }: { viewableItems: ViewToken[] }) => {
|
({ viewableItems }: { viewableItems: ViewToken[] }) => {
|
||||||
setCurrentIndex(viewableItems[0].index || 0)
|
setCurrentIndex(viewableItems[0]?.index || 0)
|
||||||
},
|
},
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
|
@ -43,7 +43,7 @@ const TabLocal = React.memo(
|
|||||||
title: t('tabs.local.name'),
|
title: t('tabs.local.name'),
|
||||||
disabled: queryKey[1].page === 'Following'
|
disabled: queryKey[1].page === 'Following'
|
||||||
},
|
},
|
||||||
...lists.map(list => ({
|
...lists?.map(list => ({
|
||||||
id: list.id,
|
id: list.id,
|
||||||
title: list.title,
|
title: list.title,
|
||||||
disabled: queryKey[1].page === 'List' && queryKey[1].list === list.id
|
disabled: queryKey[1].page === 'List' && queryKey[1].list === list.id
|
||||||
|
@ -72,7 +72,7 @@ const TabMeProfileRoot: React.FC<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}, [theme, data?.source.privacy])
|
}, [theme, data?.source?.privacy])
|
||||||
|
|
||||||
const onPressSensitive = useCallback(() => {
|
const onPressSensitive = useCallback(() => {
|
||||||
analytics('me_profile_sensitive', {
|
analytics('me_profile_sensitive', {
|
||||||
|
@ -46,7 +46,7 @@ const Collections: React.FC = () => {
|
|||||||
updateInstanceMePage({
|
updateInstanceMePage({
|
||||||
announcements: {
|
announcements: {
|
||||||
shown: announcementsQuery.data?.length ? true : false,
|
shown: announcementsQuery.data?.length ? true : false,
|
||||||
unread: announcementsQuery.data.filter(
|
unread: announcementsQuery.data?.filter(
|
||||||
announcement => !announcement.read
|
announcement => !announcement.read
|
||||||
).length
|
).length
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
|||||||
params: { toot, rootQueryKey }
|
params: { toot, rootQueryKey }
|
||||||
}
|
}
|
||||||
}) => {
|
}) => {
|
||||||
const queryKey: QueryKeyTimeline = [
|
const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Toot', toot: toot.id }]
|
||||||
'Timeline',
|
|
||||||
{ page: 'Toot', toot: toot.id }
|
|
||||||
]
|
|
||||||
|
|
||||||
const flRef = useRef<FlatList>(null)
|
const flRef = useRef<FlatList>(null)
|
||||||
|
|
||||||
@ -46,10 +43,12 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
|||||||
if (pointer < 1) return
|
if (pointer < 1) return
|
||||||
try {
|
try {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
try {
|
||||||
flRef.current?.scrollToIndex({
|
flRef.current?.scrollToIndex({
|
||||||
index: pointer,
|
index: pointer,
|
||||||
viewOffset: 100
|
viewOffset: 100
|
||||||
})
|
})
|
||||||
|
} catch {}
|
||||||
}, 500)
|
}, 500)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return
|
return
|
||||||
|
@ -8,8 +8,8 @@ import { getExpoToken, retriveExpoToken } from '@utils/slices/appSlice'
|
|||||||
import { disableAllPushes } from '@utils/slices/instancesSlice'
|
import { disableAllPushes } from '@utils/slices/instancesSlice'
|
||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import * as Notifications from 'expo-notifications'
|
import * as Notifications from 'expo-notifications'
|
||||||
|
import { TFunction } from 'i18next'
|
||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
import { TFunction } from 'react-i18next'
|
|
||||||
import { AppState } from 'react-native'
|
import { AppState } from 'react-native'
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
|
|
||||||
|
@ -358,7 +358,7 @@ export const checkInstanceFeature =
|
|||||||
f =>
|
f =>
|
||||||
parseFloat(instances[findInstanceActive(instances)]?.version) >=
|
parseFloat(instances[findInstanceActive(instances)]?.version) >=
|
||||||
f.version
|
f.version
|
||||||
).length > 0
|
)?.length > 0
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,7 +434,7 @@ export const getInstanceAccount = ({ instances: { instances } }: RootState) =>
|
|||||||
|
|
||||||
export const getInstanceNotificationsFilter = ({
|
export const getInstanceNotificationsFilter = ({
|
||||||
instances: { instances }
|
instances: { instances }
|
||||||
}: RootState) => instances[findInstanceActive(instances)].notifications_filter
|
}: RootState) => instances[findInstanceActive(instances)]?.notifications_filter
|
||||||
|
|
||||||
export const getInstancePush = ({ instances: { instances } }: RootState) =>
|
export const getInstancePush = ({ instances: { instances } }: RootState) =>
|
||||||
instances[findInstanceActive(instances)]?.push
|
instances[findInstanceActive(instances)]?.push
|
||||||
|
Loading…
x
Reference in New Issue
Block a user