Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Migrate REST API - setUserStatus to Typescript #3828

Merged
merged 4 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/definitions/IUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export interface IUser extends IRocketChatRecord, Omit<ILoggedUser, 'username' |
name?: string;
services?: IUserServices;
emails?: IUserEmail[];
status?: UserStatus;
status: UserStatus;
statusConnection?: string;
lastLogin?: Date;
avatarOrigin?: string;
Expand Down
3 changes: 3 additions & 0 deletions app/definitions/rest/v1/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ export type UsersEndpoints = {
'users.listTeams': {
GET: (params: { userId: IUser['_id'] }) => { teams: Array<ITeam> };
};
'users.setStatus': {
POST: (params: { status: string; message: string }) => { success: boolean };
AlexAlexandre marked this conversation as resolved.
Show resolved Hide resolved
};
};
4 changes: 1 addition & 3 deletions app/lib/rocketchat/services/restApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,8 @@ export const setUserPreferences = (userId: string, data: Partial<INotificationPr
// RC 0.62.0
sdk.post('users.setPreferences', { userId, data });

export const setUserStatus = (status?: string, message?: string): any =>
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): any =>
Expand Down
10 changes: 2 additions & 8 deletions app/views/StatusView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<any, 'StatusView'> {
user: IUser;
user: Pick<IUser, 'id' | 'status' | 'statusText'>;
isMasterDetail: boolean;
Accounts_AllowInvisibleStatusOption: boolean;
}
Expand Down