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 methods/getRoomInfo to TS #3695

Merged
merged 8 commits into from
Feb 19, 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
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
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.

Copy link
Contributor Author

@gerzonc gerzonc Feb 9, 2022

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>.

Copy link
Contributor

@AlexAlexandre AlexAlexandre Feb 9, 2022

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