mirror of
https://github.com/tooot-app/app
synced 2025-04-25 07:28:41 +02:00
Fix Sentry reported crashes
This commit is contained in:
parent
db6b5e4e70
commit
e5f750c3c8
@ -89,7 +89,7 @@ const contextMenuStatus = ({
|
||||
{
|
||||
id: 'status-mute',
|
||||
title: t('status.mute.action', {
|
||||
context: status.muted.toString()
|
||||
context: (status.muted || false).toString()
|
||||
}),
|
||||
systemIcon: status.muted ? 'speaker' : 'speaker.slash'
|
||||
}
|
||||
@ -108,7 +108,7 @@ const contextMenuStatus = ({
|
||||
accountMenuItems.push({
|
||||
id: 'status-pin',
|
||||
title: t('status.pin.action', {
|
||||
context: status.pinned.toString()
|
||||
context: (status.pinned || false).toString()
|
||||
}),
|
||||
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 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 = {
|
||||
inputProps: EmojisState['inputProps']
|
||||
customButton?: boolean
|
||||
@ -82,7 +55,6 @@ const ComponentEmojis: React.FC<Props & PropsWithChildren> = ({
|
||||
})
|
||||
}
|
||||
emojis.current = sortedEmojis
|
||||
prefetchEmojis(sortedEmojis, reduceMotionEnabled)
|
||||
}
|
||||
}, [data, reduceMotionEnabled])
|
||||
|
||||
|
@ -6,10 +6,7 @@ import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||
import React from 'react'
|
||||
import { createContext } from 'react'
|
||||
import { Platform } from 'react-native'
|
||||
import ContextMenu, {
|
||||
ContextMenuAction,
|
||||
ContextMenuProps
|
||||
} from 'react-native-context-menu-view'
|
||||
import ContextMenu, { ContextMenuAction, ContextMenuProps } from 'react-native-context-menu-view'
|
||||
|
||||
export interface Props {
|
||||
copiableContent: React.MutableRefObject<{
|
||||
@ -52,13 +49,15 @@ const TimelineContextMenu: React.FC<Props & ContextMenuProps> = ({
|
||||
queryKey,
|
||||
rootQueryKey
|
||||
})
|
||||
const accountOnPress = contextMenuAccount({
|
||||
actions,
|
||||
type: 'status',
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
id: status.account.id
|
||||
})
|
||||
const accountOnPress = status?.account?.id
|
||||
? contextMenuAccount({
|
||||
actions,
|
||||
type: 'status',
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
id: status.account.id
|
||||
})
|
||||
: null
|
||||
const instanceOnPress = contextMenuInstance({
|
||||
actions,
|
||||
status,
|
||||
@ -71,12 +70,7 @@ const TimelineContextMenu: React.FC<Props & ContextMenuProps> = ({
|
||||
<ContextMenu
|
||||
actions={actions}
|
||||
onPress={({ nativeEvent: { index } }) => {
|
||||
for (const on of [
|
||||
shareOnPress,
|
||||
statusOnPress,
|
||||
accountOnPress,
|
||||
instanceOnPress
|
||||
]) {
|
||||
for (const on of [shareOnPress, statusOnPress, accountOnPress, instanceOnPress]) {
|
||||
on && on(index)
|
||||
}
|
||||
}}
|
||||
|
@ -88,7 +88,7 @@ const composeReducer = (
|
||||
attachments: {
|
||||
...state.attachments,
|
||||
uploads: state.attachments.uploads.map(upload =>
|
||||
upload.remote!.id === action.payload!.id
|
||||
upload.remote?.id === action.payload?.id
|
||||
? { ...upload, remote: action.payload }
|
||||
: upload
|
||||
)
|
||||
|
@ -21,8 +21,7 @@ import FlashMessage from 'react-native-flash-message'
|
||||
import {
|
||||
Directions,
|
||||
FlingGestureHandler,
|
||||
LongPressGestureHandler,
|
||||
State
|
||||
LongPressGestureHandler
|
||||
} from 'react-native-gesture-handler'
|
||||
import { Zoom, createZoomListComponent } from 'react-native-reanimated-zoom'
|
||||
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||
@ -142,7 +141,7 @@ const ScreenImagesViewer = ({
|
||||
|
||||
const onViewableItemsChanged = useCallback(
|
||||
({ 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'),
|
||||
disabled: queryKey[1].page === 'Following'
|
||||
},
|
||||
...lists.map(list => ({
|
||||
...lists?.map(list => ({
|
||||
id: list.id,
|
||||
title: list.title,
|
||||
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(() => {
|
||||
analytics('me_profile_sensitive', {
|
||||
|
@ -46,7 +46,7 @@ const Collections: React.FC = () => {
|
||||
updateInstanceMePage({
|
||||
announcements: {
|
||||
shown: announcementsQuery.data?.length ? true : false,
|
||||
unread: announcementsQuery.data.filter(
|
||||
unread: announcementsQuery.data?.filter(
|
||||
announcement => !announcement.read
|
||||
).length
|
||||
}
|
||||
|
@ -12,10 +12,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
||||
params: { toot, rootQueryKey }
|
||||
}
|
||||
}) => {
|
||||
const queryKey: QueryKeyTimeline = [
|
||||
'Timeline',
|
||||
{ page: 'Toot', toot: toot.id }
|
||||
]
|
||||
const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Toot', toot: toot.id }]
|
||||
|
||||
const flRef = useRef<FlatList>(null)
|
||||
|
||||
@ -46,10 +43,12 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
|
||||
if (pointer < 1) return
|
||||
try {
|
||||
setTimeout(() => {
|
||||
flRef.current?.scrollToIndex({
|
||||
index: pointer,
|
||||
viewOffset: 100
|
||||
})
|
||||
try {
|
||||
flRef.current?.scrollToIndex({
|
||||
index: pointer,
|
||||
viewOffset: 100
|
||||
})
|
||||
} catch {}
|
||||
}, 500)
|
||||
} catch (error) {
|
||||
return
|
||||
|
@ -8,8 +8,8 @@ import { getExpoToken, retriveExpoToken } from '@utils/slices/appSlice'
|
||||
import { disableAllPushes } from '@utils/slices/instancesSlice'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import * as Notifications from 'expo-notifications'
|
||||
import { TFunction } from 'i18next'
|
||||
import { useEffect } from 'react'
|
||||
import { TFunction } from 'react-i18next'
|
||||
import { AppState } from 'react-native'
|
||||
import { useSelector } from 'react-redux'
|
||||
|
||||
|
@ -147,11 +147,11 @@ const instancesSlice = createSlice({
|
||||
.map((e, i) =>
|
||||
i === foundEmojiIndex
|
||||
? {
|
||||
...e,
|
||||
score: calculateScore(e),
|
||||
count: e.count + 1,
|
||||
lastUsed: new Date().getTime()
|
||||
}
|
||||
...e,
|
||||
score: calculateScore(e),
|
||||
count: e.count + 1,
|
||||
lastUsed: new Date().getTime()
|
||||
}
|
||||
: e
|
||||
)
|
||||
.sort((a, b) => b.score - a.score)
|
||||
@ -350,17 +350,17 @@ export const getInstanceVersion = ({ instances: { instances } }: RootState) =>
|
||||
instances[findInstanceActive(instances)]?.version
|
||||
export const checkInstanceFeature =
|
||||
(feature: string) =>
|
||||
({ instances: { instances } }: RootState): Boolean => {
|
||||
return (
|
||||
features
|
||||
.filter(f => f.feature === feature)
|
||||
.filter(
|
||||
f =>
|
||||
parseFloat(instances[findInstanceActive(instances)]?.version) >=
|
||||
f.version
|
||||
).length > 0
|
||||
)
|
||||
}
|
||||
({ instances: { instances } }: RootState): Boolean => {
|
||||
return (
|
||||
features
|
||||
.filter(f => f.feature === feature)
|
||||
.filter(
|
||||
f =>
|
||||
parseFloat(instances[findInstanceActive(instances)]?.version) >=
|
||||
f.version
|
||||
)?.length > 0
|
||||
)
|
||||
}
|
||||
|
||||
/* Get Instance Configuration */
|
||||
export const getInstanceConfigurationStatusMaxChars = ({
|
||||
@ -434,7 +434,7 @@ export const getInstanceAccount = ({ instances: { instances } }: RootState) =>
|
||||
|
||||
export const getInstanceNotificationsFilter = ({
|
||||
instances: { instances }
|
||||
}: RootState) => instances[findInstanceActive(instances)].notifications_filter
|
||||
}: RootState) => instances[findInstanceActive(instances)]?.notifications_filter
|
||||
|
||||
export const getInstancePush = ({ instances: { instances } }: RootState) =>
|
||||
instances[findInstanceActive(instances)]?.push
|
||||
|
Loading…
x
Reference in New Issue
Block a user