From c9c41a8ab378300c59eeccdb2273f1663ddc6f43 Mon Sep 17 00:00:00 2001 From: Alex Junior Date: Wed, 9 Mar 2022 21:16:20 -0300 Subject: [PATCH] cherry-pick conflicts --- app/lib/rocketchat/services/restApi.ts | 4 +--- .../UserNotificationPreferencesView/index.tsx | 15 +++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index bec43857f..738e323a4 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -290,10 +290,8 @@ export const getChannelInfo = (roomId: string) => // RC 0.48.0 sdk.get('channels.info', { roomId }); -export const getUserPreferences = (userId: string): any => +export const getUserPreferences = (userId: string) => // RC 0.62.0 - // TODO: missing definitions from server - // @ts-ignore sdk.get('users.getPreferences', { userId }); export const getRoomInfo = (roomId: string) => diff --git a/app/views/UserNotificationPreferencesView/index.tsx b/app/views/UserNotificationPreferencesView/index.tsx index 79a681732..a4d23291b 100644 --- a/app/views/UserNotificationPreferencesView/index.tsx +++ b/app/views/UserNotificationPreferencesView/index.tsx @@ -15,6 +15,7 @@ import { getUserSelector } from '../../selectors/login'; import sharedStyles from '../Styles'; import { OPTIONS } from './options'; import { ProfileStackParamList } from '../../stacks/types'; +import { INotificationPreferences } from '../../definitions'; const styles = StyleSheet.create({ pickerText: { @@ -26,11 +27,7 @@ const styles = StyleSheet.create({ type TKey = 'desktopNotifications' | 'pushNotifications' | 'emailNotificationMode'; interface IUserNotificationPreferencesViewState { - preferences: { - desktopNotifications?: string; - pushNotifications?: string; - emailNotificationMode?: string; - }; + preferences: INotificationPreferences; loading: boolean; } @@ -53,7 +50,7 @@ class UserNotificationPreferencesView extends React.Component< constructor(props: IUserNotificationPreferencesViewProps) { super(props); this.state = { - preferences: {}, + preferences: {} as INotificationPreferences, loading: false }; } @@ -62,8 +59,10 @@ class UserNotificationPreferencesView extends React.Component< const { user } = this.props; const { id } = user; const result = await RocketChat.getUserPreferences(id); - const { preferences } = result; - this.setState({ preferences, loading: true }); + if (result.success) { + const { preferences } = result; + this.setState({ preferences, loading: true }); + } } findDefaultOption = (key: TKey) => {