From d43da089bfb5f1345bdce44690e6f722d5e5f758 Mon Sep 17 00:00:00 2001 From: Alex Junior Date: Mon, 7 Mar 2022 12:00:39 -0300 Subject: [PATCH] Chore: Migrate REST API - setUserStatus to Typescript (#3828) * chore: add rest api return * chore: add rest api return --- app/definitions/IUser.ts | 2 +- app/definitions/rest/v1/users.ts | 3 +++ app/lib/rocketchat/services/restApi.ts | 4 +--- app/views/StatusView.tsx | 10 ++-------- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/definitions/IUser.ts b/app/definitions/IUser.ts index 7a82aa64..aaf49bd2 100644 --- a/app/definitions/IUser.ts +++ b/app/definitions/IUser.ts @@ -132,7 +132,7 @@ export interface IUser extends IRocketChatRecord, Omit { user: IUserRegistered }; }; + 'users.setStatus': { + POST: (params: { status: string; message: string }) => {}; + }; }; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index c838bcd8..de888e3a 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -265,10 +265,8 @@ export const setUserPreferences = (userId: string, data: Partial +export const setUserStatus = (status: string, message: string) => // RC 1.2.0 - // TODO: missing definitions from server - // @ts-ignore sdk.post('users.setStatus', { status, message }); export const setReaction = (emoji: string, messageId: string) => diff --git a/app/views/StatusView.tsx b/app/views/StatusView.tsx index a8822df0..2f89660b 100644 --- a/app/views/StatusView.tsx +++ b/app/views/StatusView.tsx @@ -11,7 +11,7 @@ import SafeAreaView from '../containers/SafeAreaView'; import Status from '../containers/Status/Status'; import TextInput from '../containers/TextInput'; import { LISTENER } from '../containers/Toast'; -import { IApplicationState, IBaseScreen } from '../definitions'; +import { IApplicationState, IBaseScreen, IUser } from '../definitions'; import I18n from '../i18n'; import RocketChat from '../lib/rocketchat'; import { getUserSelector } from '../selectors/login'; @@ -54,19 +54,13 @@ const styles = StyleSheet.create({ } }); -interface IUser { - id?: string; - status?: string; - statusText?: string; -} - interface IStatusViewState { statusText: string; loading: boolean; } interface IStatusViewProps extends IBaseScreen { - user: IUser; + user: Pick; isMasterDetail: boolean; Accounts_AllowInvisibleStatusOption: boolean; }