diff --git a/app/stacks/InsideStack.js b/app/stacks/InsideStack.js
index 83fc22240..9f500a52c 100644
--- a/app/stacks/InsideStack.js
+++ b/app/stacks/InsideStack.js
@@ -74,6 +74,7 @@ import QueueListView from '../ee/omnichannel/views/QueueListView';
import AddChannelTeamView from '../views/AddChannelTeamView';
import AddExistingChannelView from '../views/AddExistingChannelView';
import SelectListView from '../views/SelectListView';
+import DiscussionMessagesView from '../views/DiscussionMessagesView';
// ChatsStackNavigator
const ChatsStack = createStackNavigator();
@@ -114,6 +115,10 @@ const ChatsStackNavigator = () => {
component={RoomMembersView}
options={RoomMembersView.navigationOptions}
/>
+
{
name='ThreadMessagesView'
component={ThreadMessagesView}
/>
+
{
+ const mounted = useRef();
+ const rid = route.params?.rid;
+ const t = route.params?.t;
+ const prid = route.params?.prid;
+ const baseUrl = useSelector(state => state.server.server);
+ const user = useSelector(state => getUserSelector(state));
+ const useRealName = useSelector(state => state.settings.UI_Use_Real_Name);
+ 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 insets = useSafeAreaInsets();
+
+ const load = debounce(async() => {
+ if (loading || !mounted) {
+ return;
+ }
+
+ setLoading(true);
+
+ try {
+ const db = database.active;
+ const subCollection = db.get('subscriptions');
+ const discussionsMessages = await subCollection.query(
+ Q.where('rid', Q.eq(rid)),
+ Q.where('prid', Q.eq(prid))
+ );
+ setDiscussions(discussionsMessages);
+ setLoading(false);
+ } catch (e) {
+ log(e);
+ }
+ }, 300);
+
+ // const onSearchChangeText = debounce((text) => {
+ // setSearchText(text);
+ // }, 300);
+
+ const onSearchPress = () => {
+ setIsSearching(true);
+ };
+
+ const setHeader = () => {
+ if (isSearching) {
+ const headerTitlePosition = getHeaderTitlePosition({ insets, numIconsRight: 1 });
+ return {
+ headerTitleAlign: 'left',
+ headerLeft: () => (
+
+
+
+ ),
+ headerTitle: () => ,
+ headerTitleContainerStyle: {
+ left: headerTitlePosition.left,
+ right: headerTitlePosition.right
+ },
+ headerRight: () => null
+ };
+ }
+
+ const options = {
+ headerLeft: () => (
+ navigation.pop()}
+ tintColor={themes[theme].headerTintColor}
+ />
+ ),
+ headerTitleAlign: 'center',
+ headerTitle: I18n.t('Discussion'),
+ headerTitleContainerStyle: {
+ left: null,
+ right: null
+ }
+ };
+
+ if (isMasterDetail) {
+ options.headerLeft = () => ;
+ }
+
+ options.headerRight = () => (
+
+
+
+ );
+ return options;
+ };
+
+ // const onCancelSearchPress = () => {
+ // setIsSearching(false);
+ // setSearchText('');
+ // setHeader();
+ // };
+
+ useEffect(() => {
+ if (!mounted.current) {
+ load();
+ mounted.current = true;
+ } else {
+ setHeader();
+ }
+ }, []);
+
+
+ const onThreadPress = debounce((item) => {
+ if (isMasterDetail) {
+ navigation.pop();
+ }
+ navigation.push('RoomView', {
+ rid: item.subscription.id,
+ name: makeThreadName(item),
+ t,
+ roomUserId: RocketChat.getUidDirectMessage(item)
+ });
+ }, 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 (
+
+ );
+ };
+
+ if (!discussions?.length) {
+ return (
+ <>
+
+ >
+ );
+ }
+
+ return (
+
+
+ : null}
+ scrollIndicatorInsets={{ right: 1 }} // https://github.com/facebook/react-native/issues/26610#issuecomment-539843444
+ />
+
+ );
+};
+
+DiscussionMessagesView.propTypes = {
+ navigation: PropTypes.object,
+ route: PropTypes.object
+};
+
+export default DiscussionMessagesView;
diff --git a/app/views/RoomActionsView/index.js b/app/views/RoomActionsView/index.js
index e44126006..29a4b1a7c 100644
--- a/app/views/RoomActionsView/index.js
+++ b/app/views/RoomActionsView/index.js
@@ -980,13 +980,12 @@ class RoomActionsView extends React.Component {
this.onPressTouchable({
- route: 'ThreadMessagesView',
+ route: 'DiscussionMessagesView',
params: {
rid,
t,
prid,
- name: 'Discussions',
- isDiscussion: true
+ name: 'Discussions'
}
})}
testID='room-actions-discussions'