chore: add rest api return (#3865)

This commit is contained in:
Alex Junior 2022-03-09 14:04:25 -03:00 committed by GitHub
parent abd9722133
commit b962925121
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 8 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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 }) => {};
};
};

View File

@ -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<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) =>

View File

@ -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<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;