chore: minor tweaks
This commit is contained in:
parent
d675828c28
commit
f68ed794d2
|
@ -24,5 +24,6 @@ export interface IRoom extends IRocketChatRecord {
|
||||||
autoTranslateLanguage?: boolean;
|
autoTranslateLanguage?: boolean;
|
||||||
autoTranslate?: boolean;
|
autoTranslate?: boolean;
|
||||||
observe?: Function;
|
observe?: Function;
|
||||||
usedCannedResponse: string;
|
usedCannedResponse?: string;
|
||||||
|
bannerClosed?: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { ModalStackParamList } from './MasterDetailStack/types';
|
||||||
|
|
||||||
export type ChatsStackParamList = {
|
export type ChatsStackParamList = {
|
||||||
ModalStackNavigator: NavigatorScreenParams<ModalStackParamList>;
|
ModalStackNavigator: NavigatorScreenParams<ModalStackParamList>;
|
||||||
// E2ESaveYourPasswordStackNavigator: NavigatorScreenParams<E2ESaveYourPasswordStackParamList>;
|
E2ESaveYourPasswordStackNavigator: NavigatorScreenParams<E2ESaveYourPasswordStackParamList>;
|
||||||
RoomsListView: undefined;
|
RoomsListView: undefined;
|
||||||
RoomView: {
|
RoomView: {
|
||||||
rid: string;
|
rid: string;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FlatList, InteractionManager, Text, View } from 'react-native';
|
import { InteractionManager, Text, View } from 'react-native';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import parse from 'url-parse';
|
import parse from 'url-parse';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
@ -66,9 +66,8 @@ import UploadProgress from './UploadProgress';
|
||||||
import ReactionPicker from './ReactionPicker';
|
import ReactionPicker from './ReactionPicker';
|
||||||
import List from './List';
|
import List from './List';
|
||||||
import { ChatsStackParamList } from '../../stacks/types';
|
import { ChatsStackParamList } from '../../stacks/types';
|
||||||
import { RoomType } from '../../definitions/IRoom';
|
import { IRoom, RoomType } from '../../definitions/IRoom';
|
||||||
import { IAttachment } from '../../definitions/IAttachment';
|
import { IAttachment } from '../../definitions/IAttachment';
|
||||||
import { ModalStackParamList } from '../../stacks/MasterDetailStack/types';
|
|
||||||
|
|
||||||
const stateAttrsUpdate = [
|
const stateAttrsUpdate = [
|
||||||
'joined',
|
'joined',
|
||||||
|
@ -125,7 +124,7 @@ interface IRoomViewProps {
|
||||||
Hide_System_Messages: [];
|
Hide_System_Messages: [];
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
serverVersion: string;
|
serverVersion: string;
|
||||||
customEmojis: object;
|
customEmojis: [key: string];
|
||||||
isMasterDetail: boolean;
|
isMasterDetail: boolean;
|
||||||
theme: string;
|
theme: string;
|
||||||
replyBroadcast: Function;
|
replyBroadcast: Function;
|
||||||
|
@ -158,8 +157,8 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
private jumpToThreadId?: string;
|
private jumpToThreadId?: string;
|
||||||
private messagebox: React.RefObject<typeof MessageBox>;
|
private messagebox: React.RefObject<typeof MessageBox>;
|
||||||
private list: React.RefObject<List>;
|
private list: React.RefObject<List>;
|
||||||
private joinCode: React.RefObject<typeof JoinCode>;
|
private joinCode?: React.ForwardedRef<typeof JoinCode>;
|
||||||
private flatList: React.RefObject<FlatList>;
|
private flatList: any;
|
||||||
private mounted: boolean;
|
private mounted: boolean;
|
||||||
private sub?: RoomClass;
|
private sub?: RoomClass;
|
||||||
private offset?: number;
|
private offset?: number;
|
||||||
|
@ -718,7 +717,7 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
logEvent(events.ROOM_ENCRYPTED_PRESS);
|
logEvent(events.ROOM_ENCRYPTED_PRESS);
|
||||||
const { navigation, isMasterDetail } = this.props;
|
const { navigation, isMasterDetail } = this.props;
|
||||||
|
|
||||||
const screen: ModalStackParamList = { screen: 'E2EHowItWorksView', params: { showCloseModal: true } };
|
const screen: any = { screen: 'E2EHowItWorksView', params: { showCloseModal: true } };
|
||||||
|
|
||||||
if (isMasterDetail) {
|
if (isMasterDetail) {
|
||||||
return navigation.navigate('ModalStackNavigator', screen);
|
return navigation.navigate('ModalStackNavigator', screen);
|
||||||
|
@ -748,16 +747,16 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
.query(Q.where('archived', false), Q.where('open', true), Q.where('rid', Q.notEq(this.rid)))
|
.query(Q.where('archived', false), Q.where('open', true), Q.where('rid', Q.notEq(this.rid)))
|
||||||
.observeWithColumns(['unread']);
|
.observeWithColumns(['unread']);
|
||||||
|
|
||||||
this.queryUnreads = observable.subscribe(data => {
|
this.queryUnreads = observable.subscribe((data: any) => {
|
||||||
const { unreadsCount } = this.state;
|
const { unreadsCount } = this.state;
|
||||||
const newUnreadsCount = data.filter(s => s.unread > 0).reduce((a, b) => a + (b.unread || 0), 0);
|
const newUnreadsCount = data.filter((s: any) => s.unread > 0).reduce((a: any, b: any) => a + (b.unread || 0), 0);
|
||||||
if (unreadsCount !== newUnreadsCount) {
|
if (unreadsCount !== newUnreadsCount) {
|
||||||
this.setState({ unreadsCount: newUnreadsCount }, () => this.setHeader());
|
this.setState({ unreadsCount: newUnreadsCount }, () => this.setHeader());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
onThreadPress = debounce(item => this.navToThread(item), 1000, true);
|
onThreadPress = debounce((item: IRoomItem) => this.navToThread(item), 1000, true);
|
||||||
|
|
||||||
shouldNavigateToRoom = (message: { tmid: string; rid: string }) => {
|
shouldNavigateToRoom = (message: { tmid: string; rid: string }) => {
|
||||||
if (message.tmid && message.tmid === this.tmid) {
|
if (message.tmid && message.tmid === this.tmid) {
|
||||||
|
@ -841,6 +840,7 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
if (!this.mounted) {
|
if (!this.mounted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// @ts-ignore
|
||||||
this.setState(...args);
|
this.setState(...args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -884,7 +884,8 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
} else {
|
} else {
|
||||||
const { joinCodeRequired } = room;
|
const { joinCodeRequired } = room;
|
||||||
if (joinCodeRequired) {
|
if (joinCodeRequired) {
|
||||||
this.joinCode.current?.show();
|
// @ts-ignore
|
||||||
|
this.joinCode?.current?.show();
|
||||||
} else {
|
} else {
|
||||||
await RocketChat.joinRoom(this.rid, null, this.t);
|
await RocketChat.joinRoom(this.rid, null, this.t);
|
||||||
this.onJoin();
|
this.onJoin();
|
||||||
|
@ -1024,7 +1025,7 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
try {
|
try {
|
||||||
const db = database.active;
|
const db = database.active;
|
||||||
await db.action(async () => {
|
await db.action(async () => {
|
||||||
await room.update(r => {
|
await room.update((r: IRoom) => {
|
||||||
r.bannerClosed = true;
|
r.bannerClosed = true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue