From 41ca61966bcf035fb692d5988e401f154fb9b5d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Andr=C3=A9s=20V=C3=A9lez=20Vidal?= Date: Tue, 10 Oct 2023 17:10:44 +0200 Subject: [PATCH] do not remove inside app alerts --- app/managers/session_manager.ts | 2 +- .../categories_list/header/header.test.tsx | 19 +------------------ .../categories_list/header/header.tsx | 6 ++---- .../categories_list/header/index.ts | 12 ++---------- .../servers/servers_list/server_item/index.ts | 4 +--- .../servers_list/server_item/server_item.tsx | 4 +--- app/utils/push_proxy.ts | 6 +++--- 7 files changed, 11 insertions(+), 42 deletions(-) diff --git a/app/managers/session_manager.ts b/app/managers/session_manager.ts index f5bbe2562c6..1ba1fbbb0ca 100644 --- a/app/managers/session_manager.ts +++ b/app/managers/session_manager.ts @@ -7,7 +7,6 @@ import FastImage from 'react-native-fast-image'; import {removePushDisabledInServerAcknowledged, storeOnboardingViewedValue} from '@actions/app/global'; import {cancelSessionNotification, logout, scheduleSessionNotification} from '@actions/remote/session'; -import {urlSafeBase64Encode} from '@app/utils/security'; import {Events, Launch} from '@constants'; import DatabaseManager from '@database/manager'; import {resetMomentLocale} from '@i18n'; @@ -23,6 +22,7 @@ import {getThemeFromState} from '@screens/navigation'; import EphemeralStore from '@store/ephemeral_store'; import {deleteFileCache, deleteFileCacheByDir} from '@utils/file'; import {isMainActivity} from '@utils/helpers'; +import {urlSafeBase64Encode} from '@utils/security'; import {addNewServer} from '@utils/server'; import type {LaunchType} from '@typings/launch'; diff --git a/app/screens/home/channel_list/categories_list/header/header.test.tsx b/app/screens/home/channel_list/categories_list/header/header.test.tsx index 8414a7a711c..7299f0c982d 100644 --- a/app/screens/home/channel_list/categories_list/header/header.test.tsx +++ b/app/screens/home/channel_list/categories_list/header/header.test.tsx @@ -17,14 +17,13 @@ describe('components/channel_list/header', () => { canJoinChannels={true} canInvitePeople={true} displayName={'Test!'} - pushDisabledAck={true} />, ); expect(toJSON()).toMatchSnapshot(); }); - it('Push notifications disabled and not having acknoledged it show alert icon', () => { + it('Push notifications disabled show alert icon', () => { const wrapper = renderWithIntl(
{ canJoinChannels={true} canInvitePeople={true} displayName={'Test!'} - pushDisabledAck={false} />, ); expect(wrapper.getByTestId('channel_list_header.push_alert')).toBeTruthy(); }); - - it('Push notifications are disabled, but even after acknowledging them, the alert icon does not appear', () => { - const wrapper = renderWithIntl( -
, - ); - - expect(wrapper.queryByTestId('channel_list_header.push_alert')).toBeNull(); - }); }); diff --git a/app/screens/home/channel_list/categories_list/header/header.tsx b/app/screens/home/channel_list/categories_list/header/header.tsx index fb1528d9bbb..ca2840642dc 100644 --- a/app/screens/home/channel_list/categories_list/header/header.tsx +++ b/app/screens/home/channel_list/categories_list/header/header.tsx @@ -38,7 +38,6 @@ type Props = { iconPad?: boolean; onHeaderPress?: () => void; pushProxyStatus: string; - pushDisabledAck: boolean; } const getStyles = makeStyleSheetFromTheme((theme: Theme) => ({ @@ -112,7 +111,6 @@ const ChannelListHeader = ({ iconPad, onHeaderPress, pushProxyStatus, - pushDisabledAck, }: Props) => { const theme = useTheme(); const isTablet = useIsTablet(); @@ -168,7 +166,7 @@ const ChannelListHeader = ({ const onPushAlertPress = useCallback(() => { if (pushProxyStatus === PUSH_PROXY_STATUS_NOT_AVAILABLE) { - alertPushProxyError(intl, serverUrl); + alertPushProxyError(intl); } else { alertPushProxyUnknown(intl); } @@ -208,7 +206,7 @@ const ChannelListHeader = ({ > {serverDisplayName} - {pushProxyStatus !== PUSH_PROXY_STATUS_VERIFIED && !pushDisabledAck && ( + {pushProxyStatus !== PUSH_PROXY_STATUS_VERIFIED && ( { +const enhanced = withObservables([], ({database}: WithDatabaseArgs) => { const team = observeCurrentTeam(database); const currentUser = observeCurrentUser(database); @@ -64,8 +57,7 @@ const enhanced = withObservables([], ({serverUrl, database}: Props) => { distinctUntilChanged(), ), pushProxyStatus: observePushVerificationStatus(database), - pushDisabledAck: observePushDisabledInServerAcknowledged(urlSafeBase64Encode(serverUrl)), }; }); -export default withDatabase(withServerUrl(enhanced(ChannelListHeader))); +export default withDatabase(enhanced(ChannelListHeader)); diff --git a/app/screens/home/channel_list/servers/servers_list/server_item/index.ts b/app/screens/home/channel_list/servers/servers_list/server_item/index.ts index be9090cc216..a46828e7193 100644 --- a/app/screens/home/channel_list/servers/servers_list/server_item/index.ts +++ b/app/screens/home/channel_list/servers/servers_list/server_item/index.ts @@ -7,9 +7,8 @@ import {of as of$} from 'rxjs'; import {Tutorial} from '@constants'; import {PUSH_PROXY_STATUS_UNKNOWN} from '@constants/push_proxy'; import DatabaseManager from '@database/manager'; -import {observePushDisabledInServerAcknowledged, observeTutorialWatched} from '@queries/app/global'; +import {observeTutorialWatched} from '@queries/app/global'; import {observePushVerificationStatus} from '@queries/servers/system'; -import {urlSafeBase64Encode} from '@utils/security'; import ServerItem from './server_item'; @@ -27,7 +26,6 @@ const enhance = withObservables(['highlight'], ({highlight, server}: {highlight: server: server.observe(), tutorialWatched, pushProxyStatus: serverDatabase ? observePushVerificationStatus(serverDatabase) : of$(PUSH_PROXY_STATUS_UNKNOWN), - pushDisabledAck: observePushDisabledInServerAcknowledged(urlSafeBase64Encode(server.url)), }; }); diff --git a/app/screens/home/channel_list/servers/servers_list/server_item/server_item.tsx b/app/screens/home/channel_list/servers/servers_list/server_item/server_item.tsx index 0f463cba6bb..efe10083e3b 100644 --- a/app/screens/home/channel_list/servers/servers_list/server_item/server_item.tsx +++ b/app/screens/home/channel_list/servers/servers_list/server_item/server_item.tsx @@ -44,7 +44,6 @@ type Props = { server: ServersModel; tutorialWatched: boolean; pushProxyStatus: string; - pushDisabledAck: boolean; } type BadgeValues = { @@ -148,7 +147,6 @@ const ServerItem = ({ server, tutorialWatched, pushProxyStatus, - pushDisabledAck, }: Props) => { const intl = useIntl(); const theme = useTheme(); @@ -430,7 +428,7 @@ const ServerItem = ({ > {displayName} - {server.lastActiveAt > 0 && pushProxyStatus !== PUSH_PROXY_STATUS_VERIFIED && !pushDisabledAck && ( + {server.lastActiveAt > 0 && pushProxyStatus !== PUSH_PROXY_STATUS_VERIFIED && ( { - if (buttonIndex === 0) { +const handleAlertResponse = async (buttonIndex: number, serverUrl?: string) => { + if (buttonIndex === 0 && serverUrl) { // User clicked "Okay" acknowledging that the push notifications are disabled on that server await storePushDisabledInServerAcknowledged(urlSafeBase64Encode(serverUrl)); } }; -export function alertPushProxyError(intl: IntlShape, serverUrl: string) { +export function alertPushProxyError(intl: IntlShape, serverUrl?: string) { Alert.alert( intl.formatMessage({ id: 'alert.push_proxy_error.title',