Chore: Evaluate RoomActionsView - TypeScript (#4148)

This commit is contained in:
Reinaldo Neto 2022-05-02 20:13:39 -03:00 committed by GitHub
parent a84d4e9534
commit 93c3c5f3a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View File

@ -210,6 +210,8 @@ export interface IServerRoom extends IRocketChatRecord {
departmentId?: string;
livechatData?: any;
tags?: string[];
isLastOwner?: boolean;
}
export interface IRoomNotifications {

View File

@ -1,3 +1,4 @@
/* eslint-disable complexity */
import { Q } from '@nozbe/watermelondb';
import { StackNavigationOptions } from '@react-navigation/stack';
import isEmpty from 'lodash/isEmpty';
@ -45,6 +46,10 @@ import {
import { Services } from '../../lib/services';
import { getSubscriptionByRoomId } from '../../lib/database/services/Subscription';
interface IOnPressTouch {
<T extends keyof ChatsStackParamList>(item: { route?: T; params?: ChatsStackParamList[T]; event?: Function }): void;
}
interface IRoomActionsViewProps extends IBaseScreen<ChatsStackParamList, 'RoomActionsView'> {
userId: string;
jitsiEnabled: boolean;
@ -176,7 +181,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
}
}
if (room && room.t !== 'd' && this.canViewMembers()) {
if (room && room.t !== 'd' && (await this.canViewMembers())) {
try {
const counters = await Services.getRoomCounters(room.rid, room.t as any);
if (counters.success) {
@ -246,8 +251,11 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
return room.t === 'l' && room.status === 'queued' && !this.joined;
}
// TODO: assert params required for navigation
onPressTouchable = (item: { route?: keyof ChatsStackParamList; params?: object; event?: Function }) => {
onPressTouchable: IOnPressTouch = (item: {
route?: keyof ChatsStackParamList;
params?: ChatsStackParamList[keyof ChatsStackParamList];
event?: Function;
}) => {
const { route, event, params } = item;
if (route) {
/**
@ -640,7 +648,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
if (result.success) {
if (result.rooms?.length) {
const teamChannels = result.rooms.map((r: any) => ({
const teamChannels = result.rooms.map(r => ({
rid: r._id,
name: r.name,
teamId: r.teamId,
@ -1090,7 +1098,6 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
this.onPressTouchable({
route: 'SelectedUsersView',
params: {
rid,
title: I18n.t('Add_users'),
nextAction: this.addUser
}
@ -1275,7 +1282,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
<>
<List.Item
title='Canned_Responses'
onPress={() => this.onPressTouchable({ route: 'CannedResponsesListView', params: { rid, room } })}
onPress={() => this.onPressTouchable({ route: 'CannedResponsesListView', params: { rid } })}
left={() => <List.Icon name='canned-response' />}
showActionIndicator
/>