Chore: Migrate REST API - getChannelInfo to TS (#3839)

* add: type for REST API `channels.info`

* add: `ts-ignore` to `RoomActionsView`
This commit is contained in:
Gerzon Z 2022-03-08 09:46:33 -04:00 committed by GitHub
parent fe33a4a6b0
commit d7c46a27d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -52,6 +52,9 @@ export type ChannelsEndpoints = {
'channels.convertToTeam': {
POST: (params: { channelId: string; channelName: string }) => { team: ITeam };
};
'channels.info': {
GET: (params: { roomId: string }) => { channel: IServerRoomItem };
};
'channels.counters': {
GET: (params: { roomId: string }) => {
joined: boolean;

View File

@ -285,10 +285,8 @@ export const getRoomCounters = (
// RC 0.65.0
sdk.get(`${roomTypeToApiType(t)}.counters`, { roomId });
export const getChannelInfo = (roomId: string): any =>
export const getChannelInfo = (roomId: string) =>
// RC 0.48.0
// TODO: missing definitions from server
// @ts-ignore
sdk.get('channels.info', { roomId });
export const getUserPreferences = (userId: string): any =>

View File

@ -106,7 +106,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
this.t = props.route.params?.t;
this.joined = props.route.params?.joined;
this.state = {
room: room || ({ rid: this.rid, t: this.t } as any),
room: room || { rid: this.rid, t: this.t },
membersCount: 0,
member: member || {},
joined: !!room,
@ -144,6 +144,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
try {
const result = await RocketChat.getChannelInfo(room.rid);
if (result.success) {
// @ts-ignore
this.setState({ room: { ...result.channel, rid: result.channel._id } });
}
} catch (e) {