Skip to content
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
1 change: 1 addition & 0 deletions app/definitions/IRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface IRoom {
prid: string;
t: SubscriptionType;
name: string;
fname?: string;
teamMain: boolean;
alert?: boolean;
customFields: string[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { IRoom } from '../../definitions';
import { getSubscriptionByRoomId } from '../database/services/Subscription';
import RocketChat from '../rocketchat';

const getRoomInfo = async rid => {
const getRoomInfo = async (rid: string): Promise<Partial<IRoom> | null> => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if use a Partial here is the best approach, take a look at the lint erros.

@gerzonc gerzonc Feb 9, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a room, just that getRoomInfo returns less information than what the IRoom interface does, that's why lint complains, we defined this.room with an object with some properties from IRoom, but on the context we're using it is actually a room with less attributes, that's why I opted for Partial<IRoom>.

@AlexAlexandre AlexAlexandre Feb 9, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you can use the Pick<Type, keys>.
Using the keys required at RoomInfo
E.g: Pick<IRoom, 'rid' | 'name' | 'fname' | 't'>

let result;
result = await getSubscriptionByRoomId(rid);
if (result) {
Expand Down