Chore: Evaluate RoomActionsView - TypeScript (#4148)
This commit is contained in:
parent
a84d4e9534
commit
93c3c5f3a9
|
@ -210,6 +210,8 @@ export interface IServerRoom extends IRocketChatRecord {
|
||||||
departmentId?: string;
|
departmentId?: string;
|
||||||
livechatData?: any;
|
livechatData?: any;
|
||||||
tags?: string[];
|
tags?: string[];
|
||||||
|
|
||||||
|
isLastOwner?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IRoomNotifications {
|
export interface IRoomNotifications {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable complexity */
|
||||||
import { Q } from '@nozbe/watermelondb';
|
import { Q } from '@nozbe/watermelondb';
|
||||||
import { StackNavigationOptions } from '@react-navigation/stack';
|
import { StackNavigationOptions } from '@react-navigation/stack';
|
||||||
import isEmpty from 'lodash/isEmpty';
|
import isEmpty from 'lodash/isEmpty';
|
||||||
|
@ -45,6 +46,10 @@ import {
|
||||||
import { Services } from '../../lib/services';
|
import { Services } from '../../lib/services';
|
||||||
import { getSubscriptionByRoomId } from '../../lib/database/services/Subscription';
|
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'> {
|
interface IRoomActionsViewProps extends IBaseScreen<ChatsStackParamList, 'RoomActionsView'> {
|
||||||
userId: string;
|
userId: string;
|
||||||
jitsiEnabled: boolean;
|
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 {
|
try {
|
||||||
const counters = await Services.getRoomCounters(room.rid, room.t as any);
|
const counters = await Services.getRoomCounters(room.rid, room.t as any);
|
||||||
if (counters.success) {
|
if (counters.success) {
|
||||||
|
@ -246,8 +251,11 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
return room.t === 'l' && room.status === 'queued' && !this.joined;
|
return room.t === 'l' && room.status === 'queued' && !this.joined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: assert params required for navigation
|
onPressTouchable: IOnPressTouch = (item: {
|
||||||
onPressTouchable = (item: { route?: keyof ChatsStackParamList; params?: object; event?: Function }) => {
|
route?: keyof ChatsStackParamList;
|
||||||
|
params?: ChatsStackParamList[keyof ChatsStackParamList];
|
||||||
|
event?: Function;
|
||||||
|
}) => {
|
||||||
const { route, event, params } = item;
|
const { route, event, params } = item;
|
||||||
if (route) {
|
if (route) {
|
||||||
/**
|
/**
|
||||||
|
@ -640,7 +648,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
if (result.rooms?.length) {
|
if (result.rooms?.length) {
|
||||||
const teamChannels = result.rooms.map((r: any) => ({
|
const teamChannels = result.rooms.map(r => ({
|
||||||
rid: r._id,
|
rid: r._id,
|
||||||
name: r.name,
|
name: r.name,
|
||||||
teamId: r.teamId,
|
teamId: r.teamId,
|
||||||
|
@ -1090,7 +1098,6 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
this.onPressTouchable({
|
this.onPressTouchable({
|
||||||
route: 'SelectedUsersView',
|
route: 'SelectedUsersView',
|
||||||
params: {
|
params: {
|
||||||
rid,
|
|
||||||
title: I18n.t('Add_users'),
|
title: I18n.t('Add_users'),
|
||||||
nextAction: this.addUser
|
nextAction: this.addUser
|
||||||
}
|
}
|
||||||
|
@ -1275,7 +1282,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
<>
|
<>
|
||||||
<List.Item
|
<List.Item
|
||||||
title='Canned_Responses'
|
title='Canned_Responses'
|
||||||
onPress={() => this.onPressTouchable({ route: 'CannedResponsesListView', params: { rid, room } })}
|
onPress={() => this.onPressTouchable({ route: 'CannedResponsesListView', params: { rid } })}
|
||||||
left={() => <List.Icon name='canned-response' />}
|
left={() => <List.Icon name='canned-response' />}
|
||||||
showActionIndicator
|
showActionIndicator
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue