Files
mattermost-mobile/app/utils/navigation/index.ts
Elias Nahum 7aa5bd0611 Update Dependencies and bug fixes (#7000)
* update dependencies

* update dependencies

* feedback review

* update @mattermost/react-native-turbo-mailer
2023-01-24 09:14:23 +02:00

98 lines
3.3 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Alert} from 'react-native';
import {Navigation, Options} from 'react-native-navigation';
import {Screens, ServerErrors} from '@constants';
import {isServerError} from '@utils/errors';
import type {AvailableScreens} from '@typings/screens/navigation';
import type {IntlShape} from 'react-intl';
export const appearanceControlledScreens = new Set<AvailableScreens>([
Screens.ONBOARDING,
Screens.SERVER,
Screens.LOGIN,
Screens.FORGOT_PASSWORD,
Screens.MFA,
Screens.SSO,
Screens.REVIEW_APP,
Screens.SHARE_FEEDBACK,
]);
export function mergeNavigationOptions(componentId: string, options: Options) {
Navigation.mergeOptions(componentId, options);
}
export function alertTeamRemove(displayName: string, intl: IntlShape) {
Alert.alert(
intl.formatMessage({
id: 'alert.removed_from_team.title',
defaultMessage: 'Removed from team',
}),
intl.formatMessage({
id: 'alert.removed_from_team.description',
defaultMessage: 'You have been removed from team {displayName}.',
}, {displayName}),
[{
style: 'cancel',
text: intl.formatMessage({id: 'mobile.oauth.something_wrong.okButton', defaultMessage: 'OK'}),
}],
);
}
export function alertChannelRemove(displayName: string, intl: IntlShape) {
Alert.alert(
intl.formatMessage({
id: 'alert.removed_from_channel.title',
defaultMessage: 'Removed from channel',
}),
intl.formatMessage({
id: 'alert.removed_from_channel.description',
defaultMessage: 'You have been removed from channel {displayName}.',
}, {displayName}),
[{
style: 'cancel',
text: intl.formatMessage({id: 'mobile.oauth.something_wrong.okButton', defaultMessage: 'OK'}),
}],
);
}
export function alertChannelArchived(displayName: string, intl: IntlShape) {
Alert.alert(
intl.formatMessage({
id: 'alert.channel_deleted.title',
defaultMessage: 'Archived channel',
}),
intl.formatMessage({
id: 'alert.channel_deleted.description',
defaultMessage: 'The channel {displayName} has been archived.',
}, {displayName}),
[{
style: 'cancel',
text: intl.formatMessage({id: 'mobile.oauth.something_wrong.okButton', defaultMessage: 'OK'}),
}],
);
}
export function alertTeamAddError(error: unknown, intl: IntlShape) {
let errMsg = intl.formatMessage({id: 'join_team.error.message', defaultMessage: 'There has been an error joining the team.'});
if (isServerError(error)) {
if (error.server_error_id === ServerErrors.TEAM_MEMBERSHIP_DENIAL_ERROR_ID) {
errMsg = intl.formatMessage({
id: 'join_team.error.group_error',
defaultMessage: 'You need to be a member of a linked group to join this team.',
});
} else if (error.message) {
errMsg = error.message;
}
}
Alert.alert(
intl.formatMessage({id: 'join_team.error.title', defaultMessage: 'Error joining a team'}),
errMsg,
);
}