From 0023c11bb00133f41881f2b5c424c44bb1ad3124 Mon Sep 17 00:00:00 2001 From: Patryk Klatka Date: Fri, 4 Aug 2023 09:29:43 +0200 Subject: [PATCH] [native] Use new Alert wrapper Summary: Solution for [ENG-4421](https://linear.app/comm/issue/ENG-4421/use-new-alert-wrapper-on-native). This diff replaces all native Alert occurrences with a new Alert wrapper, which sets the currently selected theme as an Alert theme. Depends on D8586. Test Plan: Test on iOS (setting alert theme is only supported on this platform) and on Android (to check if nothing breaks). Prior to testing, make sure what theme you have set on iOS device. Then set app theme opposite to theme set on device. This will make sure, that Alerts use app theme rather than system theme. Testing each location where the Alert import was replaced can be time-intensive, therefore only selected areas have been inspected to determine if the Alert function operates as expected: - Login panel -> invalid username, empty password - Edit message -> cancel editing - Edit password -> not matching passwords, incorrect pasword - Logout -> keep login info in chain alert - Delete account panel -> invalid password - Chat -> leave chat Reviewers: bartek, tomek, inka Reviewed By: tomek Subscribers: ashoat, tomek Differential Revision: https://phab.comm.dev/D8648 --- native/account/fullscreen-siwe-panel.react.js | 3 ++- native/account/log-in-panel.react.js | 3 ++- native/account/register-panel.react.js | 2 +- .../registration/existing-ethereum-account.react.js | 3 ++- native/account/registration/registration-server-call.js | 3 ++- native/account/siwe-panel.react.js | 2 +- native/avatars/avatar-hooks.js | 2 +- .../avatars/native-edit-thread-avatar-provider.react.js | 2 +- native/calendar/entry.react.js | 2 +- native/chat/chat-input-bar.react.js | 2 +- native/chat/compose-subchannel.react.js | 3 ++- native/chat/message-report-utils.js | 2 +- native/chat/reaction-message-utils.js | 2 +- native/chat/relationship-prompt.react.js | 3 ++- native/chat/settings/add-users-modal.react.js | 3 ++- native/chat/settings/color-selector-modal.react.js | 3 ++- .../chat/settings/thread-settings-description.react.js | 2 +- .../settings/thread-settings-edit-relationship.react.js | 3 ++- .../chat/settings/thread-settings-leave-thread.react.js | 3 ++- .../thread-settings-member-tooltip-modal.react.js | 2 +- native/chat/settings/thread-settings-name.react.js | 2 +- .../settings/thread-settings-promote-sidebar.react.js | 3 ++- .../chat/settings/thread-settings-push-notifs.react.js | 2 +- native/chat/thread-screen-pruner.react.js | 2 +- native/components/user-list-user.react.js | 3 ++- native/data/sqlite-data-handler.js | 2 +- native/dev-menu.js | 2 +- native/invite-links/manage-public-link-screen.react.js | 3 ++- native/markdown/markdown-link.react.js | 3 ++- .../profile/default-notifications-preferences.react.js | 3 ++- native/profile/delete-account.react.js | 2 +- native/profile/edit-password.react.js | 2 +- native/profile/profile-screen.react.js | 3 ++- .../relationship-list-item-tooltip-modal.react.js | 3 ++- native/profile/relationship-list-item.react.js | 9 ++------- native/profile/relationship-list.react.js | 3 ++- native/push/push-handler.react.js | 3 ++- native/roles/change-roles-header-left-button.react.js | 3 ++- native/roles/role-utils.react.js | 3 ++- native/socket.react.js | 2 +- native/types/message-types-validator.js | 2 +- native/utils/edit-messages-utils.js | 2 +- 42 files changed, 64 insertions(+), 48 deletions(-) diff --git a/native/account/fullscreen-siwe-panel.react.js b/native/account/fullscreen-siwe-panel.react.js index c5f3506f29..87b588befe 100644 --- a/native/account/fullscreen-siwe-panel.react.js +++ b/native/account/fullscreen-siwe-panel.react.js @@ -1,7 +1,7 @@ // @flow import * as React from 'react'; -import { Alert, ActivityIndicator, View } from 'react-native'; +import { ActivityIndicator, View } from 'react-native'; import { useDispatch } from 'react-redux'; import { setDataLoadedActionType } from 'lib/actions/client-db-store-actions.js'; @@ -9,6 +9,7 @@ import type { SIWEResult } from 'lib/types/siwe-types.js'; import { useSIWEServerCall } from './siwe-hooks.js'; import SIWEPanel from './siwe-panel.react.js'; +import Alert from '../utils/alert.js'; type Props = { +goBackToPrompt: () => mixed, diff --git a/native/account/log-in-panel.react.js b/native/account/log-in-panel.react.js index dabb2500df..9cdd0ab425 100644 --- a/native/account/log-in-panel.react.js +++ b/native/account/log-in-panel.react.js @@ -2,7 +2,7 @@ import invariant from 'invariant'; import * as React from 'react'; -import { View, StyleSheet, Alert, Keyboard, Platform } from 'react-native'; +import { View, StyleSheet, Keyboard, Platform } from 'react-native'; import Animated from 'react-native-reanimated'; import { logInActionTypes, logIn } from 'lib/actions/user-actions.js'; @@ -37,6 +37,7 @@ import { NavContext } from '../navigation/navigation-context.js'; import { useSelector } from '../redux/redux-utils.js'; import { nativeLogInExtraInfoSelector } from '../selectors/account-selectors.js'; import type { KeyPressEvent } from '../types/react-native.js'; +import Alert from '../utils/alert.js'; import { useInitialNotificationsEncryptedMessage } from '../utils/crypto-utils.js'; import type { StateContainer } from '../utils/state-container.js'; diff --git a/native/account/register-panel.react.js b/native/account/register-panel.react.js index c92e6830a2..afe17bdd26 100644 --- a/native/account/register-panel.react.js +++ b/native/account/register-panel.react.js @@ -8,7 +8,6 @@ import { StyleSheet, Platform, Keyboard, - Alert, Linking, } from 'react-native'; import Animated from 'react-native-reanimated'; @@ -40,6 +39,7 @@ import { NavContext } from '../navigation/navigation-context.js'; import { useSelector } from '../redux/redux-utils.js'; import { nativeLogInExtraInfoSelector } from '../selectors/account-selectors.js'; import type { KeyPressEvent } from '../types/react-native.js'; +import Alert from '../utils/alert.js'; import { useInitialNotificationsEncryptedMessage } from '../utils/crypto-utils.js'; import { type StateContainer } from '../utils/state-container.js'; diff --git a/native/account/registration/existing-ethereum-account.react.js b/native/account/registration/existing-ethereum-account.react.js index 76327417f6..6bdd917f2b 100644 --- a/native/account/registration/existing-ethereum-account.react.js +++ b/native/account/registration/existing-ethereum-account.react.js @@ -1,7 +1,7 @@ // @flow import * as React from 'react'; -import { Text, View, Alert } from 'react-native'; +import { Text, View } from 'react-native'; import { useDispatch } from 'react-redux'; import { setDataLoadedActionType } from 'lib/actions/client-db-store-actions.js'; @@ -18,6 +18,7 @@ import type { RegistrationNavigationProp } from './registration-navigator.react. import type { NavigationRoute } from '../../navigation/route-names.js'; import { useSelector } from '../../redux/redux-utils.js'; import { useStyles } from '../../themes/colors.js'; +import Alert from '../../utils/alert.js'; import { useSIWEServerCall } from '../siwe-hooks.js'; const siweAuthLoadingStatusSelector = diff --git a/native/account/registration/registration-server-call.js b/native/account/registration/registration-server-call.js index f373e84e17..ce8b4c0535 100644 --- a/native/account/registration/registration-server-call.js +++ b/native/account/registration/registration-server-call.js @@ -1,7 +1,7 @@ // @flow import * as React from 'react'; -import { Alert, Platform } from 'react-native'; +import { Platform } from 'react-native'; import { useDispatch } from 'react-redux'; import { setDataLoadedActionType } from 'lib/actions/client-db-store-actions.js'; @@ -25,6 +25,7 @@ import { import { NavContext } from '../../navigation/navigation-context.js'; import { useSelector } from '../../redux/redux-utils.js'; import { nativeLogInExtraInfoSelector } from '../../selectors/account-selectors.js'; +import Alert from '../../utils/alert.js'; import { setNativeCredentials } from '../native-credentials.js'; import { useSIWEServerCall } from '../siwe-hooks.js'; diff --git a/native/account/siwe-panel.react.js b/native/account/siwe-panel.react.js index bc5ab46a78..c436eb6849 100644 --- a/native/account/siwe-panel.react.js +++ b/native/account/siwe-panel.react.js @@ -2,7 +2,6 @@ import BottomSheet from '@gorhom/bottom-sheet'; import * as React from 'react'; -import { Alert } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import WebView from 'react-native-webview'; @@ -21,6 +20,7 @@ import { import { commCoreModule } from '../native-modules.js'; import { useSelector } from '../redux/redux-utils.js'; +import Alert from '../utils/alert.js'; import { defaultLandingURLPrefix } from '../utils/url-utils.js'; const commSIWE = `${defaultLandingURLPrefix}/siwe`; diff --git a/native/avatars/avatar-hooks.js b/native/avatars/avatar-hooks.js index 251d527253..9a00c6e8f0 100644 --- a/native/avatars/avatar-hooks.js +++ b/native/avatars/avatar-hooks.js @@ -5,7 +5,6 @@ import * as ImagePicker from 'expo-image-picker'; import invariant from 'invariant'; import * as React from 'react'; import { Platform } from 'react-native'; -import Alert from 'react-native/Libraries/Alert/Alert.js'; import filesystem from 'react-native-fs'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; @@ -34,6 +33,7 @@ import type { MediaResult } from '../media/media-utils.js'; import { processMedia } from '../media/media-utils.js'; import { useSelector } from '../redux/redux-utils.js'; import { useStyles } from '../themes/colors.js'; +import Alert from '../utils/alert.js'; import { useStaffCanSee } from '../utils/staff-utils.js'; function displayAvatarUpdateFailureAlert(): void { diff --git a/native/avatars/native-edit-thread-avatar-provider.react.js b/native/avatars/native-edit-thread-avatar-provider.react.js index 9e55240c64..f21d0ffe36 100644 --- a/native/avatars/native-edit-thread-avatar-provider.react.js +++ b/native/avatars/native-edit-thread-avatar-provider.react.js @@ -1,13 +1,13 @@ // @flow import * as React from 'react'; -import { Alert } from 'react-native'; import { BaseEditThreadAvatarProvider } from 'lib/components/base-edit-thread-avatar-provider.react.js'; import { selectFromGallery, useUploadSelectedMedia } from './avatar-hooks.js'; import { activeThreadSelector } from '../navigation/nav-selectors.js'; import { NavContext } from '../navigation/navigation-context.js'; +import Alert from '../utils/alert.js'; const displayAvatarUpdateFailureAlert = () => Alert.alert( diff --git a/native/calendar/entry.react.js b/native/calendar/entry.react.js index cb466e685b..1d1c0b67de 100644 --- a/native/calendar/entry.react.js +++ b/native/calendar/entry.react.js @@ -11,7 +11,6 @@ import { TextInput as BaseTextInput, Platform, TouchableWithoutFeedback, - Alert, LayoutAnimation, Keyboard, } from 'react-native'; @@ -81,6 +80,7 @@ import type { TabNavigationProp } from '../navigation/tab-navigator.react.js'; import { useSelector } from '../redux/redux-utils.js'; import { colors, useStyles } from '../themes/colors.js'; import type { LayoutEvent } from '../types/react-native.js'; +import Alert from '../utils/alert.js'; import { waitForInteractions } from '../utils/timers.js'; function hueDistance(firstColor: string, secondColor: string): number { diff --git a/native/chat/chat-input-bar.react.js b/native/chat/chat-input-bar.react.js index 46b3eb0624..4618957e69 100644 --- a/native/chat/chat-input-bar.react.js +++ b/native/chat/chat-input-bar.react.js @@ -14,7 +14,6 @@ import { TouchableWithoutFeedback, NativeAppEventEmitter, } from 'react-native'; -import Alert from 'react-native/Libraries/Alert/Alert.js'; import { TextInputKeyboardMangerIOS } from 'react-native-keyboard-input'; import Animated, { EasingNode, @@ -126,6 +125,7 @@ import { useSelector } from '../redux/redux-utils.js'; import { type Colors, useStyles, useColors } from '../themes/colors.js'; import type { LayoutEvent } from '../types/react-native.js'; import { type AnimatedViewStyle, AnimatedView } from '../types/styles.js'; +import Alert from '../utils/alert.js'; import { runTiming } from '../utils/animation-utils.js'; import { exitEditAlert } from '../utils/edit-messages-utils.js'; import { nativeTypeaheadRegex } from '../utils/typeahead-utils.js'; diff --git a/native/chat/compose-subchannel.react.js b/native/chat/compose-subchannel.react.js index c8c4db7ec1..0e4af96f23 100644 --- a/native/chat/compose-subchannel.react.js +++ b/native/chat/compose-subchannel.react.js @@ -5,7 +5,7 @@ import _filter from 'lodash/fp/filter.js'; import _flow from 'lodash/fp/flow.js'; import _sortBy from 'lodash/fp/sortBy.js'; import * as React from 'react'; -import { View, Text, Alert } from 'react-native'; +import { View, Text } from 'react-native'; import { newThreadActionTypes, newThread } from 'lib/actions/thread-actions.js'; import { useENSNames } from 'lib/hooks/ens-cache.js'; @@ -35,6 +35,7 @@ import { useCalendarQuery } from '../navigation/nav-selectors.js'; import type { NavigationRoute } from '../navigation/route-names.js'; import { useSelector } from '../redux/redux-utils.js'; import { useStyles } from '../themes/colors.js'; +import Alert from '../utils/alert.js'; const TagInput = createTagInput(); diff --git a/native/chat/message-report-utils.js b/native/chat/message-report-utils.js index c459ebee30..83521621ec 100644 --- a/native/chat/message-report-utils.js +++ b/native/chat/message-report-utils.js @@ -1,7 +1,6 @@ // @flow import * as React from 'react'; -import { Alert } from 'react-native'; import { sendMessageReport, @@ -14,6 +13,7 @@ import { import { displayActionResultModal } from '../navigation/action-result-modal.js'; import type { TooltipRoute } from '../tooltip/tooltip.react.js'; +import Alert from '../utils/alert.js'; const confirmReport = () => displayActionResultModal('reported to admin'); diff --git a/native/chat/reaction-message-utils.js b/native/chat/reaction-message-utils.js index c6ed789ed5..abb8b22db9 100644 --- a/native/chat/reaction-message-utils.js +++ b/native/chat/reaction-message-utils.js @@ -2,7 +2,6 @@ import invariant from 'invariant'; import * as React from 'react'; -import Alert from 'react-native/Libraries/Alert/Alert.js'; import { sendReactionMessage, @@ -22,6 +21,7 @@ import type { LayoutCoordinates, VerticalBounds, } from '../types/layout-types.js'; +import Alert from '../utils/alert.js'; function useSendReaction( messageID: ?string, diff --git a/native/chat/relationship-prompt.react.js b/native/chat/relationship-prompt.react.js index 811929001f..0edf9b3b76 100644 --- a/native/chat/relationship-prompt.react.js +++ b/native/chat/relationship-prompt.react.js @@ -2,7 +2,7 @@ import Icon from '@expo/vector-icons/FontAwesome5.js'; import * as React from 'react'; -import { Alert, Text, View } from 'react-native'; +import { Text, View } from 'react-native'; import { useRelationshipPrompt } from 'lib/hooks/relationship-prompt.js'; import { userRelationshipStatus } from 'lib/types/relationship-types.js'; @@ -11,6 +11,7 @@ import type { UserInfo } from 'lib/types/user-types.js'; import Button from '../components/button.react.js'; import { useStyles } from '../themes/colors.js'; +import Alert from '../utils/alert.js'; type Props = { +pendingPersonalThreadUserInfo: ?UserInfo, diff --git a/native/chat/settings/add-users-modal.react.js b/native/chat/settings/add-users-modal.react.js index 7315f7542a..eefe7329f8 100644 --- a/native/chat/settings/add-users-modal.react.js +++ b/native/chat/settings/add-users-modal.react.js @@ -1,7 +1,7 @@ // @flow import * as React from 'react'; -import { View, Text, ActivityIndicator, Alert } from 'react-native'; +import { View, Text, ActivityIndicator } from 'react-native'; import { changeThreadSettingsActionTypes, @@ -31,6 +31,7 @@ import type { RootNavigationProp } from '../../navigation/root-navigator.react.j import type { NavigationRoute } from '../../navigation/route-names.js'; import { useSelector } from '../../redux/redux-utils.js'; import { useStyles } from '../../themes/colors.js'; +import Alert from '../../utils/alert.js'; const TagInput = createTagInput(); diff --git a/native/chat/settings/color-selector-modal.react.js b/native/chat/settings/color-selector-modal.react.js index 805f232cdf..85c138090e 100644 --- a/native/chat/settings/color-selector-modal.react.js +++ b/native/chat/settings/color-selector-modal.react.js @@ -2,7 +2,7 @@ import Icon from '@expo/vector-icons/FontAwesome.js'; import * as React from 'react'; -import { TouchableHighlight, Alert } from 'react-native'; +import { TouchableHighlight } from 'react-native'; import { changeThreadSettingsActionTypes, @@ -25,6 +25,7 @@ import type { RootNavigationProp } from '../../navigation/root-navigator.react.j import type { NavigationRoute } from '../../navigation/route-names.js'; import { useSelector } from '../../redux/redux-utils.js'; import { type Colors, useStyles, useColors } from '../../themes/colors.js'; +import Alert from '../../utils/alert.js'; export type ColorSelectorModalParams = { +presentedFrom: string, diff --git a/native/chat/settings/thread-settings-description.react.js b/native/chat/settings/thread-settings-description.react.js index 87821d14ac..bc912f34e7 100644 --- a/native/chat/settings/thread-settings-description.react.js +++ b/native/chat/settings/thread-settings-description.react.js @@ -4,7 +4,6 @@ import invariant from 'invariant'; import * as React from 'react'; import { Text, - Alert, ActivityIndicator, TextInput as BaseTextInput, View, @@ -44,6 +43,7 @@ import type { LayoutEvent, ContentSizeChangeEvent, } from '../../types/react-native.js'; +import Alert from '../../utils/alert.js'; type BaseProps = { +threadInfo: ThreadInfo, diff --git a/native/chat/settings/thread-settings-edit-relationship.react.js b/native/chat/settings/thread-settings-edit-relationship.react.js index ca3e70a5cb..8dbce795cf 100644 --- a/native/chat/settings/thread-settings-edit-relationship.react.js +++ b/native/chat/settings/thread-settings-edit-relationship.react.js @@ -2,7 +2,7 @@ import invariant from 'invariant'; import * as React from 'react'; -import { Alert, Text, View } from 'react-native'; +import { Text, View } from 'react-native'; import { updateRelationships as serverUpdateRelationships, @@ -28,6 +28,7 @@ import Button from '../../components/button.react.js'; import { useSelector } from '../../redux/redux-utils.js'; import { useStyles, useColors } from '../../themes/colors.js'; import type { ViewStyle } from '../../types/styles.js'; +import Alert from '../../utils/alert.js'; type Props = { +threadInfo: ThreadInfo, diff --git a/native/chat/settings/thread-settings-leave-thread.react.js b/native/chat/settings/thread-settings-leave-thread.react.js index 5d7816e4f7..ac2c95c61a 100644 --- a/native/chat/settings/thread-settings-leave-thread.react.js +++ b/native/chat/settings/thread-settings-leave-thread.react.js @@ -2,7 +2,7 @@ import invariant from 'invariant'; import * as React from 'react'; -import { Text, Alert, ActivityIndicator, View } from 'react-native'; +import { Text, ActivityIndicator, View } from 'react-native'; import { leaveThreadActionTypes, @@ -28,6 +28,7 @@ import { import { useSelector } from '../../redux/redux-utils.js'; import { type Colors, useColors, useStyles } from '../../themes/colors.js'; import type { ViewStyle } from '../../types/styles.js'; +import Alert from '../../utils/alert.js'; type BaseProps = { +threadInfo: ThreadInfo, diff --git a/native/chat/settings/thread-settings-member-tooltip-modal.react.js b/native/chat/settings/thread-settings-member-tooltip-modal.react.js index a000ac3416..64f4341f14 100644 --- a/native/chat/settings/thread-settings-member-tooltip-modal.react.js +++ b/native/chat/settings/thread-settings-member-tooltip-modal.react.js @@ -1,7 +1,6 @@ // @flow import * as React from 'react'; -import { Alert } from 'react-native'; import { removeUsersFromThread } from 'lib/actions/thread-actions.js'; import { removeMemberFromThread } from 'lib/shared/thread-utils.js'; @@ -22,6 +21,7 @@ import { type BaseTooltipProps, type TooltipMenuProps, } from '../../tooltip/tooltip.react.js'; +import Alert from '../../utils/alert.js'; export type ThreadSettingsMemberTooltipModalParams = TooltipParams<{ +memberInfo: RelativeMemberInfo, diff --git a/native/chat/settings/thread-settings-name.react.js b/native/chat/settings/thread-settings-name.react.js index d3dbff1134..fdad78302a 100644 --- a/native/chat/settings/thread-settings-name.react.js +++ b/native/chat/settings/thread-settings-name.react.js @@ -4,7 +4,6 @@ import invariant from 'invariant'; import * as React from 'react'; import { Text, - Alert, ActivityIndicator, TextInput as BaseTextInput, View, @@ -35,6 +34,7 @@ import { SingleLine } from '../../components/single-line.react.js'; import TextInput from '../../components/text-input.react.js'; import { useSelector } from '../../redux/redux-utils.js'; import { type Colors, useStyles, useColors } from '../../themes/colors.js'; +import Alert from '../../utils/alert.js'; type BaseProps = { +threadInfo: ResolvedThreadInfo, diff --git a/native/chat/settings/thread-settings-promote-sidebar.react.js b/native/chat/settings/thread-settings-promote-sidebar.react.js index f63f450364..7917587b9d 100644 --- a/native/chat/settings/thread-settings-promote-sidebar.react.js +++ b/native/chat/settings/thread-settings-promote-sidebar.react.js @@ -1,7 +1,7 @@ // @flow import * as React from 'react'; -import { Text, ActivityIndicator, View, Alert } from 'react-native'; +import { Text, ActivityIndicator, View } from 'react-native'; import { usePromoteSidebar } from 'lib/hooks/promote-sidebar.react.js'; import type { LoadingStatus } from 'lib/types/loading-types.js'; @@ -10,6 +10,7 @@ import type { ThreadInfo } from 'lib/types/thread-types.js'; import Button from '../../components/button.react.js'; import { type Colors, useColors, useStyles } from '../../themes/colors.js'; import type { ViewStyle } from '../../types/styles.js'; +import Alert from '../../utils/alert.js'; type BaseProps = { +threadInfo: ThreadInfo, diff --git a/native/chat/settings/thread-settings-push-notifs.react.js b/native/chat/settings/thread-settings-push-notifs.react.js index 5f34401ea0..88786df8fc 100644 --- a/native/chat/settings/thread-settings-push-notifs.react.js +++ b/native/chat/settings/thread-settings-push-notifs.react.js @@ -2,7 +2,6 @@ import * as React from 'react'; import { View, Switch, TouchableOpacity, Platform } from 'react-native'; -import Alert from 'react-native/Libraries/Alert/Alert.js'; import Linking from 'react-native/Libraries/Linking/Linking.js'; import { @@ -25,6 +24,7 @@ import SWMansionIcon from '../../components/swmansion-icon.react.js'; import { CommAndroidNotifications } from '../../push/android.js'; import { useSelector } from '../../redux/redux-utils.js'; import { useStyles } from '../../themes/colors.js'; +import Alert from '../../utils/alert.js'; type BaseProps = { +threadInfo: ThreadInfo, diff --git a/native/chat/thread-screen-pruner.react.js b/native/chat/thread-screen-pruner.react.js index b3934c425b..a3c9bd3af3 100644 --- a/native/chat/thread-screen-pruner.react.js +++ b/native/chat/thread-screen-pruner.react.js @@ -2,7 +2,6 @@ import invariant from 'invariant'; import * as React from 'react'; -import { Alert } from 'react-native'; import { threadIsPending } from 'lib/shared/thread-utils.js'; @@ -21,6 +20,7 @@ import { } from '../navigation/route-names.js'; import { useSelector } from '../redux/redux-utils.js'; import type { AppState } from '../redux/state-types.js'; +import Alert from '../utils/alert.js'; const ThreadScreenPruner: React.ComponentType<{}> = React.memo<{}>( function ThreadScreenPruner() { diff --git a/native/components/user-list-user.react.js b/native/components/user-list-user.react.js index 428d21f0fd..ca85145325 100644 --- a/native/components/user-list-user.react.js +++ b/native/components/user-list-user.react.js @@ -1,7 +1,7 @@ // @flow import * as React from 'react'; -import { Text, Platform, Alert } from 'react-native'; +import { Text, Platform } from 'react-native'; import type { UserListItem, AccountUserInfo } from 'lib/types/user-types.js'; @@ -10,6 +10,7 @@ import { SingleLine } from './single-line.react.js'; import UserAvatar from '../avatars/user-avatar.react.js'; import { type Colors, useColors, useStyles } from '../themes/colors.js'; import type { TextStyle } from '../types/styles.js'; +import Alert from '../utils/alert.js'; // eslint-disable-next-line no-unused-vars const getUserListItemHeight = (item: UserListItem): number => { diff --git a/native/data/sqlite-data-handler.js b/native/data/sqlite-data-handler.js index 1238be4ce8..553e381649 100644 --- a/native/data/sqlite-data-handler.js +++ b/native/data/sqlite-data-handler.js @@ -1,7 +1,6 @@ // @flow import * as React from 'react'; -import { Alert } from 'react-native'; import { useDispatch } from 'react-redux'; import { setClientDBStoreActionType } from 'lib/actions/client-db-store-actions.js'; @@ -22,6 +21,7 @@ import { commCoreModule } from '../native-modules.js'; import { setStoreLoadedActionType } from '../redux/action-types.js'; import { useSelector } from '../redux/redux-utils.js'; import { StaffContext } from '../staff/staff-context.js'; +import Alert from '../utils/alert.js'; import { useInitialNotificationsEncryptedMessage } from '../utils/crypto-utils.js'; import { isTaskCancelledError } from '../utils/error-handling.js'; import { useStaffCanSee } from '../utils/staff-utils.js'; diff --git a/native/dev-menu.js b/native/dev-menu.js index 907466f8fb..7a23e7d0dc 100644 --- a/native/dev-menu.js +++ b/native/dev-menu.js @@ -1,11 +1,11 @@ // @flow import { registerDevMenuItems } from 'expo-dev-menu'; -import { Alert } from 'react-native'; import { getMessageForException } from 'lib/utils/errors.js'; import { filesystemMediaCache } from './media/media-cache.js'; +import Alert from './utils/alert.js'; import { wipeAndExit } from './utils/crash-utils.js'; // see https://docs.expo.dev/develop/development-builds/development-workflows/#extending-the-dev-menu diff --git a/native/invite-links/manage-public-link-screen.react.js b/native/invite-links/manage-public-link-screen.react.js index 8b53ca5f75..211e09ab6d 100644 --- a/native/invite-links/manage-public-link-screen.react.js +++ b/native/invite-links/manage-public-link-screen.react.js @@ -1,7 +1,7 @@ // @flow import * as React from 'react'; -import { Text, View, Alert } from 'react-native'; +import { Text, View } from 'react-native'; import { inviteLinkUrl } from 'lib/facts/links.js'; import { useInviteLinksActions } from 'lib/hooks/invite-links.js'; @@ -18,6 +18,7 @@ import type { RootNavigationProp } from '../navigation/root-navigator.react.js'; import type { NavigationRoute } from '../navigation/route-names.js'; import { useSelector } from '../redux/redux-utils.js'; import { useStyles } from '../themes/colors.js'; +import Alert from '../utils/alert.js'; export type ManagePublicLinkScreenParams = { +community: ThreadInfo, diff --git a/native/markdown/markdown-link.react.js b/native/markdown/markdown-link.react.js index ecee51dcde..53a1e5a2a2 100644 --- a/native/markdown/markdown-link.react.js +++ b/native/markdown/markdown-link.react.js @@ -2,7 +2,7 @@ import invariant from 'invariant'; import * as React from 'react'; -import { Text, Linking, Alert } from 'react-native'; +import { Text, Linking } from 'react-native'; import { inviteLinkUrl } from 'lib/facts/links.js'; @@ -14,6 +14,7 @@ import { MarkdownSpoilerContext } from './markdown-spoiler-context.js'; import { MessagePressResponderContext } from '../chat/message-press-responder-context.js'; import { TextMessageMarkdownContext } from '../chat/text-message-markdown-context.js'; import { InviteLinksContext } from '../invite-links/invite-links-context-provider.react.js'; +import Alert from '../utils/alert.js'; import { normalizeURL } from '../utils/url-utils.js'; function useHandleLinkClick( diff --git a/native/profile/default-notifications-preferences.react.js b/native/profile/default-notifications-preferences.react.js index 63673fb4b2..072db24e14 100644 --- a/native/profile/default-notifications-preferences.react.js +++ b/native/profile/default-notifications-preferences.react.js @@ -1,7 +1,7 @@ // @flow import * as React from 'react'; -import { View, Text, Platform, Alert } from 'react-native'; +import { View, Text, Platform } from 'react-native'; import { ScrollView } from 'react-native-gesture-handler'; import { @@ -28,6 +28,7 @@ import SWMansionIcon from '../components/swmansion-icon.react.js'; import type { NavigationRoute } from '../navigation/route-names.js'; import { useSelector } from '../redux/redux-utils.js'; import { useStyles } from '../themes/colors.js'; +import Alert from '../utils/alert.js'; const CheckIcon = () => ( , diff --git a/native/profile/profile-screen.react.js b/native/profile/profile-screen.react.js index 68ef521221..8c44e8a72e 100644 --- a/native/profile/profile-screen.react.js +++ b/native/profile/profile-screen.react.js @@ -1,7 +1,7 @@ // @flow import * as React from 'react'; -import { View, Text, Alert, Platform, ScrollView } from 'react-native'; +import { View, Text, Platform, ScrollView } from 'react-native'; import { logOutActionTypes, logOut } from 'lib/actions/user-actions.js'; import { useStringForUser } from 'lib/hooks/ens-cache.js'; @@ -38,6 +38,7 @@ import { } from '../navigation/route-names.js'; import { useSelector } from '../redux/redux-utils.js'; import { type Colors, useColors, useStyles } from '../themes/colors.js'; +import Alert from '../utils/alert.js'; import { useStaffCanSee } from '../utils/staff-utils.js'; type ProfileRowProps = { diff --git a/native/profile/relationship-list-item-tooltip-modal.react.js b/native/profile/relationship-list-item-tooltip-modal.react.js index 7216233d60..8568fa3594 100644 --- a/native/profile/relationship-list-item-tooltip-modal.react.js +++ b/native/profile/relationship-list-item-tooltip-modal.react.js @@ -1,7 +1,7 @@ // @flow import * as React from 'react'; -import { Alert, TouchableOpacity } from 'react-native'; +import { TouchableOpacity } from 'react-native'; import { updateRelationshipsActionTypes, @@ -22,6 +22,7 @@ import { type BaseTooltipProps, type TooltipMenuProps, } from '../tooltip/tooltip.react.js'; +import Alert from '../utils/alert.js'; type Action = 'unfriend' | 'unblock'; diff --git a/native/profile/relationship-list-item.react.js b/native/profile/relationship-list-item.react.js index 8a88fc849c..ea58945d0f 100644 --- a/native/profile/relationship-list-item.react.js +++ b/native/profile/relationship-list-item.react.js @@ -2,13 +2,7 @@ import invariant from 'invariant'; import * as React from 'react'; -import { - Alert, - View, - Text, - TouchableOpacity, - ActivityIndicator, -} from 'react-native'; +import { View, Text, TouchableOpacity, ActivityIndicator } from 'react-native'; import { updateRelationshipsActionTypes, @@ -54,6 +48,7 @@ import { import { useSelector } from '../redux/redux-utils.js'; import { type Colors, useColors, useStyles } from '../themes/colors.js'; import type { VerticalBounds } from '../types/layout-types.js'; +import Alert from '../utils/alert.js'; type BaseProps = { +userInfo: AccountUserInfo, diff --git a/native/profile/relationship-list.react.js b/native/profile/relationship-list.react.js index d88b3fd15b..9177317537 100644 --- a/native/profile/relationship-list.react.js +++ b/native/profile/relationship-list.react.js @@ -2,7 +2,7 @@ import invariant from 'invariant'; import * as React from 'react'; -import { View, Text, Alert, Platform } from 'react-native'; +import { View, Text, Platform } from 'react-native'; import { FlatList } from 'react-native-gesture-handler'; import { @@ -44,6 +44,7 @@ import { import { useSelector } from '../redux/redux-utils.js'; import { useStyles, useIndicatorStyle } from '../themes/colors.js'; import type { VerticalBounds } from '../types/layout-types.js'; +import Alert from '../utils/alert.js'; const TagInput = createTagInput(); diff --git a/native/push/push-handler.react.js b/native/push/push-handler.react.js index 9497cfb885..2be5225f4b 100644 --- a/native/push/push-handler.react.js +++ b/native/push/push-handler.react.js @@ -2,7 +2,7 @@ import * as Haptics from 'expo-haptics'; import * as React from 'react'; -import { Platform, Alert, LogBox } from 'react-native'; +import { Platform, LogBox } from 'react-native'; import { Notification as InAppNotification } from 'react-native-in-app-message'; import { useDispatch } from 'react-redux'; @@ -73,6 +73,7 @@ import { useSelector } from '../redux/redux-utils.js'; import { RootContext, type RootContextType } from '../root-context.js'; import type { EventSubscription } from '../types/react-native.js'; import { type GlobalTheme } from '../types/themes.js'; +import Alert from '../utils/alert.js'; LogBox.ignoreLogs([ // react-native-in-app-message diff --git a/native/roles/change-roles-header-left-button.react.js b/native/roles/change-roles-header-left-button.react.js index 3f686af1a9..b3617e47da 100644 --- a/native/roles/change-roles-header-left-button.react.js +++ b/native/roles/change-roles-header-left-button.react.js @@ -3,11 +3,12 @@ import { HeaderBackButton as BaseHeaderBackButton } from '@react-navigation/elements'; import invariant from 'invariant'; import * as React from 'react'; -import { Alert, Text } from 'react-native'; +import { Text } from 'react-native'; import { TouchableOpacity } from 'react-native-gesture-handler'; import type { NavigationRoute } from '../navigation/route-names'; import { useColors } from '../themes/colors.js'; +import Alert from '../utils/alert.js'; type ChangeRolesHeaderLeftButtonProps = { +route: NavigationRoute<'ChangeRolesScreen'>, diff --git a/native/roles/role-utils.react.js b/native/roles/role-utils.react.js index f0294fcd5e..4af5c54a80 100644 --- a/native/roles/role-utils.react.js +++ b/native/roles/role-utils.react.js @@ -1,7 +1,6 @@ // @flow import * as React from 'react'; -import { Alert } from 'react-native'; import { deleteCommunityRole, @@ -14,6 +13,8 @@ import { } from 'lib/utils/action-utils.js'; import { constructRoleDeletionMessagePrompt } from 'lib/utils/role-utils.js'; +import Alert from '../utils/alert.js'; + function useDisplayDeleteRoleAlert( threadInfo: ThreadInfo, existingRoleID: string, diff --git a/native/socket.react.js b/native/socket.react.js index 4314c1016e..a78a5a6025 100644 --- a/native/socket.react.js +++ b/native/socket.react.js @@ -1,7 +1,6 @@ // @flow import * as React from 'react'; -import Alert from 'react-native/Libraries/Alert/Alert.js'; import { useDispatch } from 'react-redux'; import { logOut, logOutActionTypes } from 'lib/actions/user-actions.js'; @@ -31,6 +30,7 @@ import { nativeGetClientResponsesSelector, nativeSessionStateFuncSelector, } from './selectors/socket-selectors.js'; +import Alert from './utils/alert.js'; import { useInitialNotificationsEncryptedMessage } from './utils/crypto-utils.js'; const NativeSocket: React.ComponentType = diff --git a/native/types/message-types-validator.js b/native/types/message-types-validator.js index be4c57873b..5536628d37 100644 --- a/native/types/message-types-validator.js +++ b/native/types/message-types-validator.js @@ -1,10 +1,10 @@ // @flow -import { Alert } from 'react-native'; import { messageSpecs } from 'lib/shared/messages/message-specs.js'; import { messageTypes } from 'lib/types/message-types-enum.js'; import { commConstants } from '../native-modules.js'; +import Alert from '../utils/alert.js'; if (__DEV__) { const messageTypesCpp = new Set(commConstants.NATIVE_MESSAGE_TYPES); diff --git a/native/utils/edit-messages-utils.js b/native/utils/edit-messages-utils.js index 662405649e..609ab09c35 100644 --- a/native/utils/edit-messages-utils.js +++ b/native/utils/edit-messages-utils.js @@ -1,6 +1,6 @@ // @flow -import Alert from 'react-native/Libraries/Alert/Alert.js'; +import Alert from './alert.js'; type ExitAlertOptions = { onDiscard: () => void,