Skip to content

Commit

Permalink
chore: add rest api return (#3865)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAlexandre authored Mar 9, 2022
1 parent abd9722 commit b962925
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
12 changes: 11 additions & 1 deletion app/definitions/IRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion app/definitions/IUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion app/definitions/rest/v1/rooms.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -41,4 +41,7 @@ export type RoomsEndpoints = {
'rooms.favorite': {
POST: (params: { roomId: string; favorite: boolean }) => {};
};
'rooms.saveNotification': {
POST: (params: { roomId: string; notifications: IRoomNotifications }) => {};
};
};
6 changes: 2 additions & 4 deletions app/lib/rocketchat/services/restApi.ts
Original file line number Diff line number Diff line change
@@ -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 = ({
Expand Down Expand Up @@ -555,10 +555,8 @@ export const saveUserPreferences = (data: Partial<INotificationPreferences>) =>
// 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) =>
Expand Down
3 changes: 2 additions & 1 deletion app/views/NotificationPreferencesView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -73,7 +74,7 @@ class NotificationPreferencesView extends React.Component<INotificationPreferenc
}
}

saveNotificationSettings = async (key: string, value: string | boolean, params: any) => {
saveNotificationSettings = async (key: string, value: string | boolean, params: IRoomNotifications) => {
// @ts-ignore
logEvent(events[`NP_${key.toUpperCase()}`]);
const { room } = this.state;
Expand Down

0 comments on commit b962925

Please sign in to comment.