Chore: Migrate REST API - getRoomCounters to Typescript (#3842)

* Chore: Migrate REST API - getRoomCounters to Typescript

* minor tweak
This commit is contained in:
Reinaldo Neto 2022-03-07 13:48:33 -03:00 committed by GitHub
parent e3f4e9797d
commit 45c0e0630c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 3 deletions

View File

@ -52,6 +52,17 @@ export type ChannelsEndpoints = {
'channels.convertToTeam': { 'channels.convertToTeam': {
POST: (params: { channelId: string; channelName: string }) => { team: ITeam }; POST: (params: { channelId: string; channelName: string }) => { team: ITeam };
}; };
'channels.counters': {
GET: (params: { roomId: string }) => {
joined: boolean;
members: number;
unreads: number;
unreadsFrom: Date;
msgs: number;
latest: Date;
userMentions: number;
};
};
'channels.join': { 'channels.join': {
POST: (params: { roomId: string; joinCode: string | null }) => { channel: IServerRoomItem }; POST: (params: { roomId: string; joinCode: string | null }) => { channel: IServerRoomItem };
}; };

View File

@ -46,6 +46,17 @@ export type GroupsEndpoints = {
'groups.convertToTeam': { 'groups.convertToTeam': {
POST: (params: { roomId: string; roomName: string }) => { team: ITeam }; POST: (params: { roomId: string; roomName: string }) => { team: ITeam };
}; };
'groups.counters': {
GET: (params: { roomId: string }) => {
joined: boolean;
members: number;
unreads: number;
unreadsFrom: Date;
msgs: number;
latest: Date;
userMentions: number;
};
};
'groups.close': { 'groups.close': {
POST: (params: { roomId: string }) => {}; POST: (params: { roomId: string }) => {};
}; };

View File

@ -278,10 +278,11 @@ export const toggleRead = (read: boolean, roomId: string) => {
return sdk.post('subscriptions.read', { rid: roomId }); return sdk.post('subscriptions.read', { rid: roomId });
}; };
export const getRoomCounters = (roomId: string, t: RoomTypes): any => export const getRoomCounters = (
roomId: string,
t: SubscriptionType.CHANNEL | SubscriptionType.GROUP | SubscriptionType.OMNICHANNEL
) =>
// RC 0.65.0 // RC 0.65.0
// TODO: missing definitions from server
// @ts-ignore
sdk.get(`${roomTypeToApiType(t)}.counters`, { roomId }); sdk.get(`${roomTypeToApiType(t)}.counters`, { roomId });
export const getChannelInfo = (roomId: string): any => export const getChannelInfo = (roomId: string): any =>