prevent webapp from erasing new mobile notify props

This commit is contained in:
Christopher Poile 2024-05-30 17:09:32 -04:00
parent b561ac8cb2
commit e983d7b8f4
No known key found for this signature in database
GPG Key ID: 9A44D32A3E15A411
6 changed files with 23 additions and 0 deletions

View File

@ -19,6 +19,7 @@ describe('components/admin_console/reset_password_modal/reset_password_modal.tsx
desktop: 'default',
desktop_sound: 'true',
calls_desktop_sound: 'true',
calls_mobile_sound: 'true',
email: 'true',
first_name: 'true',
mark_unread: 'all',

View File

@ -60,8 +60,10 @@ type State = {
pushStatus: UserNotifyProps['push_status'];
desktopSound: UserNotifyProps['desktop_sound'];
callsDesktopSound: UserNotifyProps['calls_desktop_sound'];
callsMobileSound: UserNotifyProps['calls_mobile_sound'];
desktopNotificationSound: UserNotifyProps['desktop_notification_sound'];
callsNotificationSound: UserNotifyProps['calls_notification_sound'];
callsMobileNotificationSound: UserNotifyProps['calls_mobile_notification_sound'];
usernameKey: boolean;
isCustomKeysWithNotificationInputChecked: boolean;
customKeysWithNotification: MultiInputValue[];
@ -85,8 +87,10 @@ function getDefaultStateFromProps(props: Props): State {
let emailThreads: UserNotifyProps['email_threads'] = NotificationLevels.ALL;
let sound: UserNotifyProps['desktop_sound'] = 'true';
let callsSound: UserNotifyProps['calls_desktop_sound'] = 'true';
let callsMobileSound: UserNotifyProps['calls_mobile_sound'] = 'true';
let desktopNotificationSound: UserNotifyProps['desktop_notification_sound'] = 'Bing';
let callsNotificationSound: UserNotifyProps['calls_notification_sound'] = 'Calm';
let callsMobileNotificationSound: UserNotifyProps['calls_mobile_notification_sound'] = 'Calm';
let comments: UserNotifyProps['comments'] = 'never';
let enableEmail: UserNotifyProps['email'] = 'true';
let pushActivity: UserNotifyProps['push'] = NotificationLevels.MENTION;
@ -117,12 +121,18 @@ function getDefaultStateFromProps(props: Props): State {
if (props.user.notify_props.calls_desktop_sound) {
callsSound = props.user.notify_props.calls_desktop_sound;
}
if (props.user.notify_props.calls_mobile_sound) {
callsMobileSound = props.user.notify_props.calls_mobile_sound;
}
if (props.user.notify_props.desktop_notification_sound) {
desktopNotificationSound = props.user.notify_props.desktop_notification_sound;
}
if (props.user.notify_props.calls_notification_sound) {
callsNotificationSound = props.user.notify_props.calls_notification_sound;
}
if (props.user.notify_props.calls_mobile_notification_sound) {
callsMobileNotificationSound = props.user.notify_props.calls_mobile_notification_sound;
}
if (props.user.notify_props.comments) {
comments = props.user.notify_props.comments;
}
@ -200,8 +210,10 @@ function getDefaultStateFromProps(props: Props): State {
pushStatus,
desktopSound: sound,
callsDesktopSound: callsSound,
callsMobileSound,
desktopNotificationSound,
callsNotificationSound,
callsMobileNotificationSound,
usernameKey,
customKeysWithNotification,
isCustomKeysWithNotificationInputChecked,
@ -235,8 +247,10 @@ class NotificationsTab extends React.PureComponent<Props, State> {
data.email = this.state.enableEmail;
data.desktop_sound = this.state.desktopSound;
data.calls_desktop_sound = this.state.callsDesktopSound;
data.calls_mobile_sound = this.state.callsMobileSound;
data.desktop_notification_sound = this.state.desktopNotificationSound;
data.calls_notification_sound = this.state.callsNotificationSound;
data.calls_mobile_notification_sound = this.state.callsMobileNotificationSound;
data.desktop = this.state.desktopActivity;
data.desktop_threads = this.state.desktopThreads;
data.email_threads = this.state.emailThreads;

View File

@ -101,6 +101,7 @@ class TestHelper {
desktop: 'default',
desktop_sound: 'false',
calls_desktop_sound: 'true',
calls_mobile_sound: 'true',
email: 'false',
first_name: 'false',
mark_unread: 'mention',
@ -143,6 +144,7 @@ class TestHelper {
desktop: 'default',
desktop_sound: 'false',
calls_desktop_sound: 'true',
calls_mobile_sound: 'true',
email: 'false',
first_name: 'false',
mark_unread: 'mention',
@ -470,6 +472,7 @@ class TestHelper {
desktop: 'default',
desktop_sound: 'true',
calls_desktop_sound: 'true',
calls_mobile_sound: 'true',
email: 'true',
mark_unread: 'all',
push: 'default',

View File

@ -28,6 +28,7 @@ describe('Utils.Route', () => {
notify_props: {desktop: 'default',
desktop_sound: 'false',
calls_desktop_sound: 'true',
calls_mobile_sound: 'true',
email: 'true',
mark_unread: 'all',
push: 'default',
@ -89,6 +90,7 @@ describe('Utils.Route', () => {
desktop: 'default',
desktop_sound: 'false',
calls_desktop_sound: 'true',
calls_mobile_sound: 'true',
email: 'true',
mark_unread: 'all',
push: 'default',

View File

@ -65,6 +65,7 @@ export class TestHelper {
desktop: 'default',
desktop_sound: 'false',
calls_desktop_sound: 'true',
calls_mobile_sound: 'true',
email: 'false',
first_name: 'false',
mark_unread: 'mention',

View File

@ -12,6 +12,7 @@ export type UserNotifyProps = {
desktop: 'default' | 'all' | 'mention' | 'none';
desktop_sound: 'true' | 'false';
calls_desktop_sound: 'true' | 'false';
calls_mobile_sound: 'true' | 'false';
email: 'true' | 'false';
mark_unread: 'all' | 'mention';
push: 'default' | 'all' | 'mention' | 'none';
@ -23,6 +24,7 @@ export type UserNotifyProps = {
highlight_keys: string;
desktop_notification_sound?: 'Bing' | 'Crackle' | 'Down' | 'Hello' | 'Ripple' | 'Upstairs';
calls_notification_sound?: 'Dynamic' | 'Calm' | 'Urgent' | 'Cheerful';
calls_mobile_notification_sound?: 'Dynamic' | 'Calm' | 'Urgent' | 'Cheerful';
desktop_threads?: 'default' | 'all' | 'mention' | 'none';
email_threads?: 'default' | 'all' | 'mention' | 'none';
push_threads?: 'default' | 'all' | 'mention' | 'none';