diff --git a/src/components/ContextMenu/status.ts b/src/components/ContextMenu/status.ts index 6974fe2e..5caac672 100644 --- a/src/components/ContextMenu/status.ts +++ b/src/components/ContextMenu/status.ts @@ -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' }) diff --git a/src/components/Emojis.tsx b/src/components/Emojis.tsx index 755d2b84..ca744678 100644 --- a/src/components/Emojis.tsx +++ b/src/components/Emojis.tsx @@ -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[][] - }[], - 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 = ({ }) } emojis.current = sortedEmojis - prefetchEmojis(sortedEmojis, reduceMotionEnabled) } }, [data, reduceMotionEnabled]) diff --git a/src/components/Timeline/Shared/ContextMenu.tsx b/src/components/Timeline/Shared/ContextMenu.tsx index 911ad328..f5935e9d 100644 --- a/src/components/Timeline/Shared/ContextMenu.tsx +++ b/src/components/Timeline/Shared/ContextMenu.tsx @@ -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 = ({ 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 = ({ { - for (const on of [ - shareOnPress, - statusOnPress, - accountOnPress, - instanceOnPress - ]) { + for (const on of [shareOnPress, statusOnPress, accountOnPress, instanceOnPress]) { on && on(index) } }} diff --git a/src/screens/Compose/utils/reducer.ts b/src/screens/Compose/utils/reducer.ts index 921a9f0d..2440d14b 100644 --- a/src/screens/Compose/utils/reducer.ts +++ b/src/screens/Compose/utils/reducer.ts @@ -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 ) diff --git a/src/screens/ImagesViewer.tsx b/src/screens/ImagesViewer.tsx index afbe4f3a..295c9c22 100644 --- a/src/screens/ImagesViewer.tsx +++ b/src/screens/ImagesViewer.tsx @@ -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) }, [] ) diff --git a/src/screens/Tabs/Local.tsx b/src/screens/Tabs/Local.tsx index 7b30a1c6..d3141e2b 100644 --- a/src/screens/Tabs/Local.tsx +++ b/src/screens/Tabs/Local.tsx @@ -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 diff --git a/src/screens/Tabs/Me/Profile/Root.tsx b/src/screens/Tabs/Me/Profile/Root.tsx index ae0abbe1..9fc5466a 100644 --- a/src/screens/Tabs/Me/Profile/Root.tsx +++ b/src/screens/Tabs/Me/Profile/Root.tsx @@ -72,7 +72,7 @@ const TabMeProfileRoot: React.FC< } } ) - }, [theme, data?.source.privacy]) + }, [theme, data?.source?.privacy]) const onPressSensitive = useCallback(() => { analytics('me_profile_sensitive', { diff --git a/src/screens/Tabs/Me/Root/Collections.tsx b/src/screens/Tabs/Me/Root/Collections.tsx index 504d5305..daf2608e 100644 --- a/src/screens/Tabs/Me/Root/Collections.tsx +++ b/src/screens/Tabs/Me/Root/Collections.tsx @@ -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 } diff --git a/src/screens/Tabs/Shared/Toot.tsx b/src/screens/Tabs/Shared/Toot.tsx index b238ebad..1c2dca2d 100644 --- a/src/screens/Tabs/Shared/Toot.tsx +++ b/src/screens/Tabs/Shared/Toot.tsx @@ -12,10 +12,7 @@ const TabSharedToot: React.FC> = ({ params: { toot, rootQueryKey } } }) => { - const queryKey: QueryKeyTimeline = [ - 'Timeline', - { page: 'Toot', toot: toot.id } - ] + const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Toot', toot: toot.id }] const flRef = useRef(null) @@ -46,10 +43,12 @@ const TabSharedToot: React.FC> = ({ 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 diff --git a/src/utils/push/useConnect.ts b/src/utils/push/useConnect.ts index 3d8ad47f..ab2f7adc 100644 --- a/src/utils/push/useConnect.ts +++ b/src/utils/push/useConnect.ts @@ -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' diff --git a/src/utils/slices/instancesSlice.ts b/src/utils/slices/instancesSlice.ts index 845a38b1..48f56887 100644 --- a/src/utils/slices/instancesSlice.ts +++ b/src/utils/slices/instancesSlice.ts @@ -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