do not remove inside app alerts
This commit is contained in:
parent
499114f4f9
commit
41ca61966b
7 changed files with 11 additions and 42 deletions
|
|
@ -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';
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
<Header
|
||||
pushProxyStatus={PUSH_PROXY_RESPONSE_NOT_AVAILABLE}
|
||||
|
|
@ -32,25 +31,9 @@ describe('components/channel_list/header', () => {
|
|||
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(
|
||||
<Header
|
||||
pushProxyStatus={PUSH_PROXY_RESPONSE_NOT_AVAILABLE}
|
||||
canCreateChannels={true}
|
||||
canJoinChannels={true}
|
||||
canInvitePeople={true}
|
||||
displayName={'Test!'}
|
||||
pushDisabledAck={true}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(wrapper.queryByTestId('channel_list_header.push_alert')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
</Text>
|
||||
{pushProxyStatus !== PUSH_PROXY_STATUS_VERIFIED && !pushDisabledAck && (
|
||||
{pushProxyStatus !== PUSH_PROXY_STATUS_VERIFIED && (
|
||||
<TouchableWithFeedback
|
||||
onPress={onPushAlertPress}
|
||||
testID='channel_list_header.push_alert'
|
||||
|
|
|
|||
|
|
@ -7,23 +7,16 @@ import {combineLatest, of as of$} from 'rxjs';
|
|||
import {distinctUntilChanged, switchMap} from 'rxjs/operators';
|
||||
|
||||
import {Permissions} from '@constants';
|
||||
import {withServerUrl} from '@context/server';
|
||||
import {observePushDisabledInServerAcknowledged} from '@queries/app/global';
|
||||
import {observePermissionForTeam} from '@queries/servers/role';
|
||||
import {observeConfigBooleanValue, observePushVerificationStatus} from '@queries/servers/system';
|
||||
import {observeCurrentTeam} from '@queries/servers/team';
|
||||
import {observeCurrentUser} from '@queries/servers/user';
|
||||
import {urlSafeBase64Encode} from '@utils/security';
|
||||
|
||||
import ChannelListHeader from './header';
|
||||
|
||||
import type {WithDatabaseArgs} from '@typings/database/database';
|
||||
|
||||
type Props = WithDatabaseArgs & {
|
||||
serverUrl: string;
|
||||
}
|
||||
|
||||
const enhanced = withObservables([], ({serverUrl, database}: Props) => {
|
||||
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));
|
||||
|
|
|
|||
|
|
@ -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)),
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
</Text>
|
||||
{server.lastActiveAt > 0 && pushProxyStatus !== PUSH_PROXY_STATUS_VERIFIED && !pushDisabledAck && (
|
||||
{server.lastActiveAt > 0 && pushProxyStatus !== PUSH_PROXY_STATUS_VERIFIED && (
|
||||
<CompassIcon
|
||||
name='alert-outline'
|
||||
color={theme.errorTextColor}
|
||||
|
|
|
|||
|
|
@ -36,14 +36,14 @@ export async function canReceiveNotifications(serverUrl: string, verification: s
|
|||
}
|
||||
}
|
||||
|
||||
const handleAlertResponse = async (buttonIndex: number, serverUrl: string) => {
|
||||
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',
|
||||
|
|
|
|||
Loading…
Reference in a new issue