chore: changing other components to room requirements
This commit is contained in:
parent
55982566f7
commit
8a4892e61e
|
@ -23,7 +23,7 @@ interface IMessageActions {
|
||||||
autoTranslate: any;
|
autoTranslate: any;
|
||||||
reactWhenReadOnly: any;
|
reactWhenReadOnly: any;
|
||||||
};
|
};
|
||||||
tmid: string;
|
tmid?: string;
|
||||||
user: {
|
user: {
|
||||||
id: string | number;
|
id: string | number;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,8 @@ export enum RoomType {
|
||||||
DIRECT = 'd',
|
DIRECT = 'd',
|
||||||
CHANNEL = 'c',
|
CHANNEL = 'c',
|
||||||
OMNICHANNEL = 'l',
|
OMNICHANNEL = 'l',
|
||||||
THREAD = 'thread'
|
THREAD = 'thread',
|
||||||
|
E2E_MESSAGE_TYPE = 'e2e'
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IRoom extends IRocketChatRecord {
|
export interface IRoom extends IRocketChatRecord {
|
||||||
|
|
|
@ -25,6 +25,7 @@ export type ChatsStackParamList = {
|
||||||
jumpToMessageId?: string;
|
jumpToMessageId?: string;
|
||||||
jumpToThreadId?: string;
|
jumpToThreadId?: string;
|
||||||
roomUserId?: string;
|
roomUserId?: string;
|
||||||
|
usedCannedResponse?: boolean;
|
||||||
};
|
};
|
||||||
RoomActionsView: {
|
RoomActionsView: {
|
||||||
room: IRoom;
|
room: IRoom;
|
||||||
|
@ -48,6 +49,7 @@ export type ChatsStackParamList = {
|
||||||
member: any;
|
member: any;
|
||||||
rid: string;
|
rid: string;
|
||||||
t: RoomType;
|
t: RoomType;
|
||||||
|
showCloseModal?: boolean;
|
||||||
};
|
};
|
||||||
RoomInfoEditView: {
|
RoomInfoEditView: {
|
||||||
rid: string;
|
rid: string;
|
||||||
|
|
|
@ -14,6 +14,7 @@ interface IRoomBannerProps {
|
||||||
theme: string;
|
theme: string;
|
||||||
bannerClosed: boolean;
|
bannerClosed: boolean;
|
||||||
closeBanner(): void;
|
closeBanner(): void;
|
||||||
|
rid?: string; // TODO - verify if this props exist
|
||||||
}
|
}
|
||||||
|
|
||||||
const Banner = React.memo(
|
const Banner = React.memo(
|
||||||
|
|
|
@ -13,7 +13,7 @@ const styles = StyleSheet.create({
|
||||||
});
|
});
|
||||||
|
|
||||||
interface IRoomLeftButtonsProps {
|
interface IRoomLeftButtonsProps {
|
||||||
tmid: string;
|
tmid?: string;
|
||||||
unreadsCount: number;
|
unreadsCount: number;
|
||||||
navigation: any; // TODO - change this after merge react navigation
|
navigation: any; // TODO - change this after merge react navigation
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
|
|
|
@ -36,11 +36,11 @@ const onScroll = ({ y }: any) =>
|
||||||
interface IRoomListContainerProps {
|
interface IRoomListContainerProps {
|
||||||
renderRow: Function;
|
renderRow: Function;
|
||||||
rid: string;
|
rid: string;
|
||||||
tmid: string;
|
tmid?: string;
|
||||||
theme: string;
|
theme: string;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
listRef: any;
|
listRef: any;
|
||||||
hideSystemMessages: [];
|
hideSystemMessages: any[];
|
||||||
tunread: [];
|
tunread: [];
|
||||||
ignored: [];
|
ignored: [];
|
||||||
navigation: any; // TODO - change this after merge with navigation ts;
|
navigation: any; // TODO - change this after merge with navigation ts;
|
||||||
|
|
|
@ -15,13 +15,14 @@ interface IRoomRightButtonsContainerProps {
|
||||||
threadsEnabled: boolean;
|
threadsEnabled: boolean;
|
||||||
rid: string;
|
rid: string;
|
||||||
t: string;
|
t: string;
|
||||||
tmid: string;
|
tmid?: string;
|
||||||
teamId: string;
|
teamId: string;
|
||||||
navigation: any; // TODO - change this after merge react navigation
|
navigation: any; // TODO - change this after merge react navigation
|
||||||
isMasterDetail: boolean;
|
isMasterDetail: boolean;
|
||||||
toggleFollowThread: Function;
|
toggleFollowThread: Function;
|
||||||
joined: boolean;
|
joined: boolean;
|
||||||
encrypted: boolean;
|
encrypted: boolean;
|
||||||
|
teamMain?: string; // TODO - verify if this props exist
|
||||||
}
|
}
|
||||||
|
|
||||||
class RightButtonsContainer extends Component<IRoomRightButtonsContainerProps, any> {
|
class RightButtonsContainer extends Component<IRoomRightButtonsContainerProps, any> {
|
||||||
|
|
|
@ -34,7 +34,7 @@ const styles = StyleSheet.create({
|
||||||
});
|
});
|
||||||
|
|
||||||
interface IRoomDateSeparatorProps {
|
interface IRoomDateSeparatorProps {
|
||||||
ts: Date;
|
ts: Date | null;
|
||||||
unread: boolean;
|
unread: boolean;
|
||||||
theme: string;
|
theme: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,6 +137,19 @@ interface IRoomViewProps {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IRoomItem {
|
||||||
|
id: string;
|
||||||
|
tmid: string;
|
||||||
|
tmsg: string;
|
||||||
|
t: RoomType;
|
||||||
|
e2e: string;
|
||||||
|
tlm: string;
|
||||||
|
rid: string;
|
||||||
|
ts: Date;
|
||||||
|
status: any;
|
||||||
|
u: { _id: string };
|
||||||
|
}
|
||||||
|
|
||||||
class RoomView extends React.Component<IRoomViewProps, any> {
|
class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
private rid: string;
|
private rid: string;
|
||||||
private t: RoomType;
|
private t: RoomType;
|
||||||
|
@ -479,7 +492,7 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
};
|
};
|
||||||
|
|
||||||
// goRoomActionsView = (screen?: keyof ChatsStackParamList) => {
|
// goRoomActionsView = (screen?: keyof ChatsStackParamList) => {
|
||||||
goRoomActionsView = (screen: any) => {
|
goRoomActionsView = (screen?: any) => {
|
||||||
logEvent(events.ROOM_GO_RA);
|
logEvent(events.ROOM_GO_RA);
|
||||||
const { room, member, joined } = this.state;
|
const { room, member, joined } = this.state;
|
||||||
const { navigation, isMasterDetail } = this.props;
|
const { navigation, isMasterDetail } = this.props;
|
||||||
|
@ -653,7 +666,7 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onReplyInit = (message: string, mention: string) => {
|
onReplyInit = (message: string, mention: boolean) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
selectedMessage: message,
|
selectedMessage: message,
|
||||||
replying: true,
|
replying: true,
|
||||||
|
@ -815,7 +828,7 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
EventEmitter.removeListener('connected', this.handleConnected);
|
EventEmitter.removeListener('connected', this.handleConnected);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleRoomRemoved = ({ rid }: {rid: string}) => {
|
handleRoomRemoved = ({ rid }: { rid: string }) => {
|
||||||
const { room } = this.state;
|
const { room } = this.state;
|
||||||
if (rid === this.rid) {
|
if (rid === this.rid) {
|
||||||
Navigation.navigate('RoomsListView');
|
Navigation.navigate('RoomsListView');
|
||||||
|
@ -852,7 +865,7 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
setLastOpen = lastOpen => this.setState({ lastOpen });
|
setLastOpen = (lastOpen: Date | null) => this.setState({ lastOpen });
|
||||||
|
|
||||||
onJoin = () => {
|
onJoin = () => {
|
||||||
this.internalSetState({
|
this.internalSetState({
|
||||||
|
@ -882,9 +895,9 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
getThreadName = (tmid, messageId) => getThreadName(this.rid, tmid, messageId);
|
getThreadName = (tmid: string, messageId: string) => getThreadName(this.rid, tmid, messageId);
|
||||||
|
|
||||||
toggleFollowThread = async (isFollowingThread, tmid) => {
|
toggleFollowThread = async (isFollowingThread: boolean, tmid: string) => {
|
||||||
try {
|
try {
|
||||||
await RocketChat.toggleFollowMessage(tmid ?? this.tmid, !isFollowingThread);
|
await RocketChat.toggleFollowMessage(tmid ?? this.tmid, !isFollowingThread);
|
||||||
EventEmitter.emit(LISTENER, { message: isFollowingThread ? I18n.t('Unfollowed_thread') : I18n.t('Following_thread') });
|
EventEmitter.emit(LISTENER, { message: isFollowingThread ? I18n.t('Unfollowed_thread') : I18n.t('Following_thread') });
|
||||||
|
@ -893,13 +906,13 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
getBadgeColor = messageId => {
|
getBadgeColor = (messageId: string) => {
|
||||||
const { room } = this.state;
|
const { room } = this.state;
|
||||||
const { theme } = this.props;
|
const { theme } = this.props;
|
||||||
return getBadgeColor({ subscription: room, theme, messageId });
|
return getBadgeColor({ subscription: room, theme, messageId });
|
||||||
};
|
};
|
||||||
|
|
||||||
navToRoomInfo = navParam => {
|
navToRoomInfo = (navParam: ChatsStackParamList['RoomInfoView']) => {
|
||||||
const { navigation, user, isMasterDetail } = this.props;
|
const { navigation, user, isMasterDetail } = this.props;
|
||||||
logEvent(events[`ROOM_GO_${navParam.t === 'd' ? 'USER' : 'ROOM'}_INFO`]);
|
logEvent(events[`ROOM_GO_${navParam.t === 'd' ? 'USER' : 'ROOM'}_INFO`]);
|
||||||
if (navParam.rid === user.id) {
|
if (navParam.rid === user.id) {
|
||||||
|
@ -913,7 +926,7 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
navToThread = async item => {
|
navToThread = async (item: IRoomItem) => {
|
||||||
const { roomUserId } = this.state;
|
const { roomUserId } = this.state;
|
||||||
const { navigation } = this.props;
|
const { navigation } = this.props;
|
||||||
|
|
||||||
|
@ -951,9 +964,9 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
navToRoom = async message => {
|
navToRoom = async (message: IRoomItem) => {
|
||||||
const { navigation, isMasterDetail } = this.props;
|
const { navigation, isMasterDetail } = this.props;
|
||||||
const roomInfo = await getRoomInfo(message.rid);
|
const roomInfo: any = await getRoomInfo(message.rid);
|
||||||
return goRoom({
|
return goRoom({
|
||||||
item: roomInfo,
|
item: roomInfo,
|
||||||
isMasterDetail,
|
isMasterDetail,
|
||||||
|
@ -972,11 +985,11 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleCommands = ({ event }) => {
|
handleCommands = ({ event }: any) => {
|
||||||
if (this.rid) {
|
if (this.rid) {
|
||||||
const { input } = event;
|
const { input } = event;
|
||||||
if (handleCommandScroll(event)) {
|
if (handleCommandScroll(event)) {
|
||||||
const offset = input === 'UIKeyInputUpArrow' ? 100 : -100;
|
const offset: any = input === 'UIKeyInputUpArrow' ? 100 : -100;
|
||||||
this.offset += offset;
|
this.offset += offset;
|
||||||
this.flatList?.scrollToOffset({ offset: this.offset });
|
this.flatList?.scrollToOffset({ offset: this.offset });
|
||||||
} else if (handleCommandRoomActions(event)) {
|
} else if (handleCommandRoomActions(event)) {
|
||||||
|
@ -992,7 +1005,7 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
blockAction = ({ actionId, appId, value, blockId, rid, mid }) =>
|
blockAction = ({ actionId, appId, value, blockId, rid, mid }: any) =>
|
||||||
RocketChat.triggerBlockAction({
|
RocketChat.triggerBlockAction({
|
||||||
blockId,
|
blockId,
|
||||||
actionId,
|
actionId,
|
||||||
|
@ -1020,12 +1033,12 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
isIgnored = message => {
|
isIgnored = (message: IRoomItem) => {
|
||||||
const { room } = this.state;
|
const { room } = this.state;
|
||||||
return room?.ignored?.includes?.(message?.u?._id) ?? false;
|
return room?.ignored?.includes?.(message?.u?._id) ?? false;
|
||||||
};
|
};
|
||||||
|
|
||||||
onLoadMoreMessages = loaderItem =>
|
onLoadMoreMessages = (loaderItem: any): any =>
|
||||||
RoomServices.getMoreMessages({
|
RoomServices.getMoreMessages({
|
||||||
rid: this.rid,
|
rid: this.rid,
|
||||||
tmid: this.tmid,
|
tmid: this.tmid,
|
||||||
|
@ -1033,7 +1046,7 @@ class RoomView extends React.Component<IRoomViewProps, any> {
|
||||||
loaderItem
|
loaderItem
|
||||||
});
|
});
|
||||||
|
|
||||||
renderItem = (item, previousItem, highlightedMessage) => {
|
renderItem = (item: IRoomItem, previousItem: IRoomItem, highlightedMessage: any) => {
|
||||||
const { room, lastOpen, canAutoTranslate } = this.state;
|
const { room, lastOpen, canAutoTranslate } = this.state;
|
||||||
const { user, Message_GroupingPeriod, Message_TimeFormat, useRealName, baseUrl, Message_Read_Receipt_Enabled, theme } =
|
const { user, Message_GroupingPeriod, Message_TimeFormat, useRealName, baseUrl, Message_Read_Receipt_Enabled, theme } =
|
||||||
this.props;
|
this.props;
|
||||||
|
|
Loading…
Reference in New Issue