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 { IRocketChatRecord } from './IRocketChatRecord';
import { IServedBy } from './IServedBy'; import { IServedBy } from './IServedBy';
import { IVisitor, SubscriptionType } from './ISubscription'; import { IVisitor, SubscriptionType } from './ISubscription';
import { IUser } from './IUser'; import { IUser, TNotifications } from './IUser';
interface IRequestTranscript { interface IRequestTranscript {
email: string; email: string;
@ -202,3 +202,13 @@ export interface IServerRoom extends IRocketChatRecord {
livechatData?: any; livechatData?: any;
tags?: string[]; 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; [key: string]: any;
}; };
} }
type TNotifications = 'default' | 'all' | 'mentions' | 'nothing'; export type TNotifications = 'default' | 'all' | 'mentions' | 'nothing';
export interface INotificationPreferences { export interface INotificationPreferences {
id: string; id: string;

View File

@ -1,5 +1,5 @@
import type { IMessage } from '../../IMessage'; import type { IMessage } from '../../IMessage';
import type { IServerRoom } from '../../IRoom'; import type { IRoomNotifications, IServerRoom } from '../../IRoom';
import type { IUser } from '../../IUser'; import type { IUser } from '../../IUser';
export type RoomsEndpoints = { export type RoomsEndpoints = {
@ -41,4 +41,7 @@ export type RoomsEndpoints = {
'rooms.favorite': { 'rooms.favorite': {
POST: (params: { roomId: string; favorite: boolean }) => {}; 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 sdk from './sdk';
import { TEAM_TYPE } from '../../../definitions/ITeam'; import { TEAM_TYPE } from '../../../definitions/ITeam';
import roomTypeToApiType, { RoomTypes } from '../methods/roomTypeToApiType'; import roomTypeToApiType, { RoomTypes } from '../methods/roomTypeToApiType';
import { SubscriptionType, INotificationPreferences } from '../../../definitions'; import { SubscriptionType, INotificationPreferences, IRoomNotifications } from '../../../definitions';
import { ISpotlight } from '../../../definitions/ISpotlight'; import { ISpotlight } from '../../../definitions/ISpotlight';
export const createChannel = ({ export const createChannel = ({
@ -555,10 +555,8 @@ export const saveUserPreferences = (data: Partial<INotificationPreferences>) =>
// RC 0.62.0 // RC 0.62.0
sdk.post('users.setPreferences', { data }); sdk.post('users.setPreferences', { data });
export const saveNotificationSettings = (roomId: string, notifications: any): any => export const saveNotificationSettings = (roomId: string, notifications: IRoomNotifications) =>
// RC 0.63.0 // RC 0.63.0
// TODO: missing definitions from server
// @ts-ignore
sdk.post('rooms.saveNotification', { roomId, notifications }); sdk.post('rooms.saveNotification', { roomId, notifications });
export const getSingleMessage = (msgId: string) => export const getSingleMessage = (msgId: string) =>

View File

@ -18,6 +18,7 @@ import log, { events, logEvent } from '../../utils/log';
import sharedStyles from '../Styles'; import sharedStyles from '../Styles';
import { OPTIONS } from './options'; import { OPTIONS } from './options';
import { ChatsStackParamList } from '../../stacks/types'; import { ChatsStackParamList } from '../../stacks/types';
import { IRoomNotifications } from '../../definitions';
const styles = StyleSheet.create({ const styles = StyleSheet.create({
pickerText: { 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 // @ts-ignore
logEvent(events[`NP_${key.toUpperCase()}`]); logEvent(events[`NP_${key.toUpperCase()}`]);
const { room } = this.state; const { room } = this.state;