Chore: Server API types - user.setPreferences (#3781)
* chore: implementing type for test api - user.setPreferences * chore: minor tweak
This commit is contained in:
parent
4ba7f16b71
commit
7de686b0e8
|
@ -103,6 +103,22 @@ export interface IUserSettings {
|
|||
[key: string]: any;
|
||||
};
|
||||
}
|
||||
type TNotifications = 'default' | 'all' | 'mentions' | 'nothing';
|
||||
|
||||
export interface INotificationPreferences {
|
||||
id: string;
|
||||
enableMessageParserEarlyAdoption: boolean;
|
||||
desktopNotifications: TNotifications;
|
||||
pushNotifications: TNotifications;
|
||||
emailNotificationMode?: 'mentions' | 'nothing';
|
||||
}
|
||||
|
||||
export interface IUserPreferences {
|
||||
user: { _id: string };
|
||||
settings: {
|
||||
preferences: INotificationPreferences;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IUser extends IRocketChatRecord, Omit<ILoggedUser, 'username' | 'name' | 'status'> {
|
||||
_id: string;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { IUser, IUserRegistered } from '../../IUser';
|
||||
import { INotificationPreferences, IUser, IUserPreferences, IUserRegistered } from '../../IUser';
|
||||
|
||||
export type UserEndpoints = {
|
||||
'users.info': {
|
||||
|
@ -11,6 +11,12 @@ export type UserEndpoints = {
|
|||
success: boolean;
|
||||
};
|
||||
};
|
||||
'users.setPreferences': {
|
||||
POST: (params: { userId: IUser['_id']; data: Partial<INotificationPreferences> }) => {
|
||||
user: IUserPreferences;
|
||||
success: boolean;
|
||||
};
|
||||
};
|
||||
'users.register': {
|
||||
POST: (params: { name: string; email: string; username: string; pass: string }) => { user: IUserRegistered };
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { SubscriptionType } from '../../../definitions';
|
||||
import sdk from './sdk';
|
||||
import { TEAM_TYPE } from '../../../definitions/ITeam';
|
||||
import roomTypeToApiType, { RoomTypes } from '../methods/roomTypeToApiType';
|
||||
import sdk from './sdk';
|
||||
import { SubscriptionType, INotificationPreferences } from '../../../definitions';
|
||||
|
||||
export const createChannel = ({
|
||||
name,
|
||||
|
@ -283,10 +283,8 @@ export const reportMessage = (messageId: string): any =>
|
|||
// @ts-ignore
|
||||
sdk.post('chat.reportMessage', { messageId, description: 'Message reported by user' });
|
||||
|
||||
export const setUserPreferences = (userId: string, data: any): any =>
|
||||
export const setUserPreferences = (userId: string, data: Partial<INotificationPreferences>) =>
|
||||
// RC 0.62.0
|
||||
// TODO: missing definitions from server
|
||||
// @ts-ignore
|
||||
sdk.post('users.setPreferences', { userId, data });
|
||||
|
||||
export const setUserStatus = (status?: string, message?: string): any =>
|
||||
|
|
|
@ -106,10 +106,12 @@ class UserNotificationPreferencesView extends React.Component<
|
|||
const { user } = this.props;
|
||||
const { id } = user;
|
||||
const result = await RocketChat.setUserPreferences(id, params);
|
||||
const {
|
||||
user: { settings }
|
||||
} = result;
|
||||
this.setState({ preferences: settings.preferences });
|
||||
if (result.success) {
|
||||
const {
|
||||
user: { settings }
|
||||
} = result;
|
||||
this.setState({ preferences: settings.preferences });
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
|
|
Loading…
Reference in New Issue