diff --git a/app/definitions/IRoom.ts b/app/definitions/IRoom.ts index 378e7b798..552d7b5a9 100644 --- a/app/definitions/IRoom.ts +++ b/app/definitions/IRoom.ts @@ -4,7 +4,7 @@ import { IMessage } from './IMessage'; import { IRocketChatRecord } from './IRocketChatRecord'; import { IServedBy } from './IServedBy'; import { IVisitor, SubscriptionType } from './ISubscription'; -import { IUser } from './IUser'; +import { IUser, TNotifications } from './IUser'; interface IRequestTranscript { email: string; @@ -202,3 +202,13 @@ export interface IServerRoom extends IRocketChatRecord { livechatData?: any; tags?: string[]; } + +export interface IRoomNotifications { + disableNotifications?: boolean; + muteGroupMentions?: boolean; + hideUnreadStatus?: boolean; + audioNotificationsValue?: string; + desktopNotifications?: TNotifications; + mobilePushNotifications?: TNotifications; + emailNotifications?: TNotifications; +} diff --git a/app/definitions/IUser.ts b/app/definitions/IUser.ts index 6dfbdf5e7..93bce8805 100644 --- a/app/definitions/IUser.ts +++ b/app/definitions/IUser.ts @@ -103,7 +103,7 @@ export interface IUserSettings { [key: string]: any; }; } -type TNotifications = 'default' | 'all' | 'mentions' | 'nothing'; +export type TNotifications = 'default' | 'all' | 'mentions' | 'nothing'; export interface INotificationPreferences { id: string; diff --git a/app/definitions/rest/v1/rooms.ts b/app/definitions/rest/v1/rooms.ts index d4bb971bc..ebcb29cd4 100644 --- a/app/definitions/rest/v1/rooms.ts +++ b/app/definitions/rest/v1/rooms.ts @@ -1,5 +1,5 @@ import type { IMessage } from '../../IMessage'; -import type { IServerRoom } from '../../IRoom'; +import type { IRoomNotifications, IServerRoom } from '../../IRoom'; import type { IUser } from '../../IUser'; export type RoomsEndpoints = { @@ -41,4 +41,7 @@ export type RoomsEndpoints = { 'rooms.favorite': { POST: (params: { roomId: string; favorite: boolean }) => {}; }; + 'rooms.saveNotification': { + POST: (params: { roomId: string; notifications: IRoomNotifications }) => {}; + }; }; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index 6bb6e6c1c..8eabe4566 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -1,7 +1,7 @@ import sdk from './sdk'; import { TEAM_TYPE } from '../../../definitions/ITeam'; import roomTypeToApiType, { RoomTypes } from '../methods/roomTypeToApiType'; -import { SubscriptionType, INotificationPreferences } from '../../../definitions'; +import { SubscriptionType, INotificationPreferences, IRoomNotifications } from '../../../definitions'; import { ISpotlight } from '../../../definitions/ISpotlight'; export const createChannel = ({ @@ -555,10 +555,8 @@ export const saveUserPreferences = (data: Partial) => // RC 0.62.0 sdk.post('users.setPreferences', { data }); -export const saveNotificationSettings = (roomId: string, notifications: any): any => +export const saveNotificationSettings = (roomId: string, notifications: IRoomNotifications) => // RC 0.63.0 - // TODO: missing definitions from server - // @ts-ignore sdk.post('rooms.saveNotification', { roomId, notifications }); export const getSingleMessage = (msgId: string) => diff --git a/app/views/NotificationPreferencesView/index.tsx b/app/views/NotificationPreferencesView/index.tsx index 71edd8d05..bf76d9e38 100644 --- a/app/views/NotificationPreferencesView/index.tsx +++ b/app/views/NotificationPreferencesView/index.tsx @@ -18,6 +18,7 @@ import log, { events, logEvent } from '../../utils/log'; import sharedStyles from '../Styles'; import { OPTIONS } from './options'; import { ChatsStackParamList } from '../../stacks/types'; +import { IRoomNotifications } from '../../definitions'; const styles = StyleSheet.create({ pickerText: { @@ -73,7 +74,7 @@ class NotificationPreferencesView extends React.Component { + saveNotificationSettings = async (key: string, value: string | boolean, params: IRoomNotifications) => { // @ts-ignore logEvent(events[`NP_${key.toUpperCase()}`]); const { room } = this.state;