diff --git a/app/views/DiscussionMessagesView.js b/app/views/DiscussionMessagesView.js
index 3a483cb31..06820dbbd 100644
--- a/app/views/DiscussionMessagesView.js
+++ b/app/views/DiscussionMessagesView.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useRef, useState } from 'react';
+import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { FlatList } from 'react-native';
import { useSelector } from 'react-redux';
@@ -6,44 +6,44 @@ import { Q } from '@nozbe/watermelondb';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { HeaderBackButton } from '@react-navigation/stack';
-import Item from './ThreadMessagesView/Item';
import ActivityIndicator from '../containers/ActivityIndicator';
import I18n from '../i18n';
-import RocketChat from '../lib/rocketchat';
import database from '../lib/database';
import StatusBar from '../containers/StatusBar';
import log from '../utils/log';
import debounce from '../utils/debounce';
import { themes } from '../constants/colors';
-import { getUserSelector } from '../selectors/login';
import SafeAreaView from '../containers/SafeAreaView';
import * as HeaderButton from '../containers/HeaderButton';
import * as List from '../containers/List';
import BackgroundContainer from '../containers/BackgroundContainer';
import { isIOS } from '../utils/deviceInfo';
-import { makeThreadName } from '../utils/room';
import { getHeaderTitlePosition } from '../containers/Header';
import SearchHeader from './ThreadMessagesView/SearchHeader';
import { useTheme } from '../theme';
+import Message from '../containers/message';
const DiscussionMessagesView = ({ navigation, route }) => {
- const mounted = useRef();
const rid = route.params?.rid;
- const t = route.params?.t;
- const prid = route.params?.prid;
+ // const t = route.params?.t;
+ // const prid = route.params?.prid;
+ const canAutoTranslate = route.params?.canAutoTranslate;
+ const autoTranslate = route.params?.autoTranslate;
+ const autoTranslateLanguage = route.params?.autoTranslateLanguage;
const baseUrl = useSelector(state => state.server.server);
- const user = useSelector(state => getUserSelector(state));
+ // const user = useSelector(state => getUserSelector(state));
const useRealName = useSelector(state => state.settings.UI_Use_Real_Name);
+ const Message_TimeFormat = useSelector(state => state.settings.Message_TimeFormat);
const isMasterDetail = useSelector(state => state.app.isMasterDetail);
const [loading, setLoading] = useState(false);
const [discussions, setDiscussions] = useState([]);
const [isSearching, setIsSearching] = useState(false);
- // const [searchText, setSearchText] = useState('');
- const theme = useTheme();
+ const [searchText, setSearchText] = useState('');
+ const { theme } = useTheme();
const insets = useSafeAreaInsets();
- const load = debounce(async() => {
- if (loading || !mounted) {
+ const load = async() => {
+ if (loading) {
return;
}
@@ -51,21 +51,26 @@ const DiscussionMessagesView = ({ navigation, route }) => {
try {
const db = database.active;
- const subCollection = db.get('subscriptions');
- const discussionsMessages = await subCollection.query(
+ const subCollection = db.get('messages');
+ const subDiscussions = await subCollection.query(
Q.where('rid', Q.eq(rid)),
- Q.where('prid', Q.eq(prid))
+ Q.where('drid', Q.notEq(null))
);
- setDiscussions(discussionsMessages);
+ setDiscussions(subDiscussions);
setLoading(false);
} catch (e) {
log(e);
}
+ };
+
+ const onSearchChangeText = debounce((text) => {
+ setSearchText(text);
}, 300);
- // const onSearchChangeText = debounce((text) => {
- // setSearchText(text);
- // }, 300);
+ const onCancelSearchPress = () => {
+ setIsSearching(false);
+ setSearchText('');
+ };
const onSearchPress = () => {
setIsSearching(true);
@@ -80,11 +85,11 @@ const DiscussionMessagesView = ({ navigation, route }) => {
),
- headerTitle: () => ,
+ headerTitle: () => ,
headerTitleContainerStyle: {
left: headerTitlePosition.left,
right: headerTitlePosition.right
@@ -102,7 +107,7 @@ const DiscussionMessagesView = ({ navigation, route }) => {
/>
),
headerTitleAlign: 'center',
- headerTitle: I18n.t('Discussion'),
+ headerTitle: I18n.t('Discussions'),
headerTitleContainerStyle: {
left: null,
right: null
@@ -121,54 +126,34 @@ const DiscussionMessagesView = ({ navigation, route }) => {
return options;
};
- // const onCancelSearchPress = () => {
- // setIsSearching(false);
- // setSearchText('');
- // setHeader();
- // };
-
useEffect(() => {
- if (!mounted.current) {
- load();
- mounted.current = true;
- } else {
- setHeader();
- }
+ load();
+ const options = setHeader();
+ navigation.setOptions(options);
}, []);
- const onThreadPress = debounce((item) => {
- if (isMasterDetail) {
- navigation.pop();
- }
+ const onDiscussionPress = debounce((item) => {
navigation.push('RoomView', {
- rid: item.subscription.id,
- name: makeThreadName(item),
- t,
- roomUserId: RocketChat.getUidDirectMessage(item)
+ rid: item.drid, prid: item.rid, name: item.msg, t: 'p'
});
}, 1000, true);
- const getBadgeColor = item => getBadgeColor({ item, theme, messageId: item?.id });
-
// eslint-disable-next-line react/prop-types
- const renderItem = ({ item }) => {
- const badgeColor = getBadgeColor(item);
- return (
-
- );
- };
+ const renderItem = ({ item }) => (
+
+ );
if (!discussions?.length) {
return (
@@ -186,7 +171,6 @@ const DiscussionMessagesView = ({ navigation, route }) => {
renderItem={renderItem}
// style={[styles.list, { backgroundColor: themes[theme].backgroundColor }]}
// contentContainerStyle={styles.contentContainer}
- onEndReached={load}
onEndReachedThreshold={0.5}
maxToRenderPerBatch={5}
windowSize={10}
diff --git a/app/views/RoomActionsView/index.js b/app/views/RoomActionsView/index.js
index 29a4b1a7c..44ffe9de6 100644
--- a/app/views/RoomActionsView/index.js
+++ b/app/views/RoomActionsView/index.js
@@ -985,7 +985,9 @@ class RoomActionsView extends React.Component {
rid,
t,
prid,
- name: 'Discussions'
+ canAutoTranslate,
+ autoTranslate: room.autoTranslate,
+ autoTranslateLanguage: room.autoTranslateLanguage
}
})}
testID='room-actions-discussions'