Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
a0eecdc
Add Discussions to RoomActionsView
gerzonc Jul 16, 2021
659f2c8
Add Discussions to ThreadMessagesView
gerzonc Jul 19, 2021
c066c20
Update DiscussionMessagesView and add to stacks
gerzonc Jul 20, 2021
daba3b4
Fix DiscussionMessagesView
gerzonc Jul 21, 2021
da3bdd4
Fix search
gerzonc Jul 21, 2021
9ad45f0
Add E2E test
gerzonc Jul 21, 2021
fc59b74
Remove old changes from ThreadMessagesView
gerzonc Jul 21, 2021
b4c55b3
Merge develop
gerzonc Jul 21, 2021
82b306b
Minor tweak
gerzonc Jul 22, 2021
7feb509
Add discussions for channels
gerzonc Aug 23, 2021
e6e6c9e
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Aug 23, 2021
618eb53
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Aug 23, 2021
2d89d07
Minor tweak
gerzonc Sep 1, 2021
cc404b1
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Sep 1, 2021
330ab40
Fix navToRoomInfo
gerzonc Sep 2, 2021
2b1f78f
Fix search
gerzonc Sep 3, 2021
7429e4b
Add getDiscussions endpoint
gerzonc Sep 3, 2021
ad612e6
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Sep 3, 2021
91dedfb
Convert SearchHeader to reusable component and minor tweaks to Discus…
gerzonc Sep 8, 2021
f4c86ec
Merge develop into branch
gerzonc Sep 14, 2021
cc2a34c
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Sep 14, 2021
565f5d7
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Sep 15, 2021
f88a6fa
Fix lint
gerzonc Sep 15, 2021
191e71c
Merge branch 'develop' into new.add-discusions-roomactionsview
diegolmello Sep 15, 2021
8ccce58
Minor tweaks
gerzonc Sep 16, 2021
ecee12c
Migrate to TypeScript, update interfaces and some changes to containe…
gerzonc Sep 17, 2021
55b89e6
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Sep 17, 2021
6128bc4
Migrate SearchHeader to TS
gerzonc Sep 17, 2021
88dbf34
Update e2e tests
gerzonc Sep 17, 2021
9473bf4
Minor tweaks
gerzonc Sep 17, 2021
c641bf5
Fix threads
gerzonc Sep 17, 2021
cc07128
Remove unused params
gerzonc Sep 17, 2021
ec665e0
Simplify logic
gerzonc Sep 17, 2021
5379109
Rollback interfaces changes
gerzonc Sep 17, 2021
df480fb
Update property type rule
gerzonc Sep 17, 2021
d1d35c7
Minor tweak
gerzonc Sep 17, 2021
f9dc2a9
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Oct 4, 2021
eedfd42
Minor tweak
gerzonc Oct 4, 2021
b48a189
Update Storyshots.test.js.snap
gerzonc Oct 4, 2021
89a2381
test commit
gerzonc Oct 4, 2021
a226cad
Undo changes, add timeFormat prop
gerzonc Oct 5, 2021
da7f954
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Oct 5, 2021
1d40c3b
Update snapshots
gerzonc Oct 6, 2021
dcb79b1
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Oct 6, 2021
714608c
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Oct 13, 2021
0242fb1
Fix en.json
gerzonc Oct 13, 2021
086d13b
Remove no-non-null-assertion
gerzonc Oct 13, 2021
35d869d
Update types and onCancelSearchPress
gerzonc Oct 13, 2021
8e064a5
Fix lint
gerzonc Oct 13, 2021
5dc0a0a
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Oct 20, 2021
f911100
Fix lint
gerzonc Oct 20, 2021
47f7ee8
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Oct 27, 2021
ffb17d6
Minor tweaks
gerzonc Oct 29, 2021
a1c8ce0
Minor tweak
gerzonc Oct 29, 2021
767637b
Merge branch 'develop' into new.add-discusions-roomactionsview
AlexAlexandre Nov 1, 2021
0a3bdb6
Update index.tsx
gerzonc Nov 4, 2021
bd534f5
Minor tweak
gerzonc Nov 4, 2021
184799e
Update 04-discussion.spec.js
gerzonc Nov 8, 2021
c858218
Minor tweak
gerzonc Nov 8, 2021
2b7f589
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Nov 23, 2021
dc70bf6
Add DiscussionDetails and Item for DiscussionsView; update ThreadDeta…
gerzonc Jan 14, 2022
e010d80
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Jan 17, 2022
18da04b
update definitions
gerzonc Jan 17, 2022
eb1712e
minor tweak
gerzonc Jan 17, 2022
89ae430
add storybooks, update snapshots and DiscussionsView
gerzonc Jan 17, 2022
680476a
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Jan 17, 2022
6c9a3f9
Minor tweaks
gerzonc Jan 17, 2022
23244e3
Fix lint
gerzonc Jan 17, 2022
79eeb55
Remove unused import
gerzonc Jan 17, 2022
6be5b7e
Merge branch 'develop' into new.add-discusions-roomactionsview
diegolmello Jan 20, 2022
ea9a2da
Merge branch 'develop' into new.add-discusions-roomactionsview
diegolmello Jan 21, 2022
0a6e5d3
Move onDiscussionpress logic on message, update SearchHeader and Disc…
gerzonc Jan 24, 2022
ce8a208
Update interfaces and minor tweaks to DiscussionsView screen and comp…
gerzonc Jan 24, 2022
bce775d
Fix navigation logic and update interfaces
gerzonc Jan 24, 2022
5d84468
Minor tweaks
gerzonc Jan 24, 2022
4995df2
Undo change on project.pbxproj
gerzonc Jan 24, 2022
67e034c
Update project.pbxproj
gerzonc Jan 24, 2022
42946c1
Update project.pbxproj
gerzonc Jan 24, 2022
4f9460b
Remove style.ts
gerzonc Jan 24, 2022
e0d7cbb
Minor tweak
gerzonc Jan 24, 2022
a1a2e5c
update snapshots
gerzonc Jan 24, 2022
5a320a8
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Jan 28, 2022
a093af3
test
gerzonc Jan 31, 2022
350a20d
remove console.log
gerzonc Jan 31, 2022
89613bb
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Jan 31, 2022
67541ba
Add missing DiscussionsView snapshot
gerzonc Jan 31, 2022
c0e7f43
fix build and useless done and async generator
dnlsilva Feb 1, 2022
93edb9b
update snapshot
dnlsilva Feb 1, 2022
04f3c7e
Merge branch 'fix-ci-limiter-and-test' into new.add-discusions-roomac…
gerzonc Feb 1, 2022
7278241
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Feb 1, 2022
9caff40
Merge branch 'develop' into new.add-discusions-roomactionsview
gerzonc Feb 1, 2022
1b6f574
Merge branch 'new.add-discusions-roomactionsview' of https://github.c…
gerzonc Feb 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@
"No_threads": "There are no threads",
"No_threads_following": "You are not following any threads",
"No_threads_unread": "There are no unread threads",
"No_discussions": "There are no discussions",
"Messagebox_Send_to_channel": "Send to channel",
"Leader": "Leader",
"Moderator": "Moderator",
Expand Down
5 changes: 5 additions & 0 deletions app/stacks/InsideStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -114,6 +115,10 @@ const ChatsStackNavigator = () => {
component={RoomMembersView}
options={RoomMembersView.navigationOptions}
/>
<ChatsStack.Screen
name='DiscussionMessagesView'
component={DiscussionMessagesView}
/>
<ChatsStack.Screen
name='SearchMessagesView'
component={SearchMessagesView}
Expand Down
5 changes: 5 additions & 0 deletions app/stacks/MasterDetailStack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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();
Expand Down Expand Up @@ -212,6 +213,10 @@ const ModalStackNavigator = React.memo(({ navigation }) => {
name='ThreadMessagesView'
component={ThreadMessagesView}
/>
<ModalStack.Screen
name='DiscussionMessagesView'
component={DiscussionMessagesView}
/>
<ModalStack.Screen
name='TeamChannelsView'
component={TeamChannelsView}
Expand Down
210 changes: 210 additions & 0 deletions app/views/DiscussionMessagesView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { FlatList } from 'react-native';
import { useSelector } from 'react-redux';
import { Q } from '@nozbe/watermelondb';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { HeaderBackButton } from '@react-navigation/stack';

import ActivityIndicator from '../containers/ActivityIndicator';
import I18n from '../i18n';
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 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 { getHeaderTitlePosition } from '../containers/Header';
import SearchHeader from './ThreadMessagesView/SearchHeader';
import { useTheme } from '../theme';
import Message from '../containers/message';
import { sanitizeLikeString } from '../lib/database/utils';

const DiscussionMessagesView = ({ navigation, route }) => {
Comment thread
gerzonc marked this conversation as resolved.
Outdated
const rid = route.params?.rid;
const canAutoTranslate = route.params?.canAutoTranslate;
const autoTranslate = route.params?.autoTranslate;
const autoTranslateLanguage = route.params?.autoTranslateLanguage;
const baseUrl = useSelector(state => state.server.server);
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 { theme } = useTheme();
const insets = useSafeAreaInsets();

const load = async() => {
if (loading) {
return;
}

setLoading(true);

try {
const db = database.active;
const subCollection = db.get('messages');
const subDiscussions = await subCollection.query(
Q.where('rid', Q.eq(rid)),
Q.where('drid', Q.notEq(null))
);
setDiscussions(subDiscussions);
setLoading(false);
} catch (e) {
log(e);
}
};

const onSearchChangeText = debounce(async(text) => {
Comment thread
gerzonc marked this conversation as resolved.
Outdated
try {
const db = database.active;
const whereClause = [
Q.where('rid', Q.eq(rid)),
Q.where('drid', Q.notEq(null))
];

if (text?.trim()) {
whereClause.push(Q.where('msg', Q.like(`%${ sanitizeLikeString(text?.trim()) }%`)));
}

const discussionsMessages = await db
.get('messages')
.query(...whereClause);
setDiscussions(discussionsMessages);
} catch (e) {
log(e);
}
}, 300);

const onCancelSearchPress = () => {
setIsSearching(false);
load();
};

const onSearchPress = () => {
setIsSearching(true);
};

const setHeader = () => {
if (isSearching) {
const headerTitlePosition = getHeaderTitlePosition({ insets, numIconsRight: 1 });
return {
headerTitleAlign: 'left',
headerLeft: () => (
<HeaderButton.Container left>
<HeaderButton.Item
iconName='close'
onPress={onCancelSearchPress}
/>
</HeaderButton.Container>
),
headerTitle: () => <SearchHeader onSearchChangeText={onSearchChangeText} />,
headerTitleContainerStyle: {
left: headerTitlePosition.left,
right: headerTitlePosition.right
},
headerRight: () => null
};
}

const options = {
headerLeft: () => (
<HeaderBackButton
labelVisible={false}
onPress={() => navigation.pop()}
tintColor={themes[theme].headerTintColor}
/>
),
headerTitleAlign: 'center',
headerTitle: I18n.t('Discussions'),
headerTitleContainerStyle: {
left: null,
right: null
}
};

if (isMasterDetail) {
options.headerLeft = () => <HeaderButton.CloseModal navigation={navigation} />;
}

options.headerRight = () => (
<HeaderButton.Container>
<HeaderButton.Item iconName='search' onPress={onSearchPress} />
</HeaderButton.Container>
);
return options;
};

useEffect(() => {
load();
}, []);

useEffect(() => {
const options = setHeader();
navigation.setOptions(options);
}, [navigation, isSearching]);


const onDiscussionPress = debounce((item) => {
navigation.push('RoomView', {
rid: item.drid, prid: item.rid, name: item.msg, t: 'p'
});
}, 1000, true);

// eslint-disable-next-line react/prop-types
const renderItem = ({ item }) => (
Comment thread
AlexAlexandre marked this conversation as resolved.
Outdated
<Message
Comment thread
gerzonc marked this conversation as resolved.
Outdated
item={item}
// eslint-disable-next-line react/prop-types
user={item.id}
rid={rid}
onDiscussionPress={onDiscussionPress}
baseUrl={baseUrl}
timeFormat={Message_TimeFormat}
useRealName={useRealName}
autoTranslateRoom={canAutoTranslate && autoTranslate}
autoTranslateLanguage={autoTranslateLanguage}
/>
);

if (!discussions?.length) {
return (
<>
Comment thread
gerzonc marked this conversation as resolved.
Outdated
<BackgroundContainer text={I18n.t('No_discussions')} />
Comment thread
gerzonc marked this conversation as resolved.
Outdated
</>
);
}

return (
<SafeAreaView testID='discussion-messages-view'>
<StatusBar />
<FlatList
Comment thread
gerzonc marked this conversation as resolved.
Outdated
data={discussions}
renderItem={renderItem}
// eslint-disable-next-line react/prop-types
keyExtractor={item => item.msg}
style={{ backgroundColor: themes[theme].backgroundColor }}
onEndReachedThreshold={0.5}
maxToRenderPerBatch={5}
windowSize={10}
initialNumToRender={7}
removeClippedSubviews={isIOS}
ItemSeparatorComponent={List.Separator}
ListFooterComponent={loading ? <ActivityIndicator theme={theme} /> : null}
scrollIndicatorInsets={{ right: 1 }}
/>
</SafeAreaView>
);
};

DiscussionMessagesView.propTypes = {
navigation: PropTypes.object,
route: PropTypes.object
};

export default DiscussionMessagesView;
27 changes: 26 additions & 1 deletion app/views/RoomActionsView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ class RoomActionsView extends React.Component {
room, membersCount, canViewMembers, canAddUser, canInviteUser, joined, canAutoTranslate, canForwardGuest, canReturnQueue
} = this.state;
const {
rid, t
rid, t, prid
} = room;
const isGroupChat = RocketChat.isGroupChat(room);

Expand Down Expand Up @@ -974,6 +974,31 @@ class RoomActionsView extends React.Component {
)
: null}

{['c', 'p', 'd'].includes(t) && !prid
? (
<>
<List.Item
title='Discussions'
onPress={() => this.onPressTouchable({
route: 'DiscussionMessagesView',
params: {
rid,
t,
prid,
canAutoTranslate,
autoTranslate: room.autoTranslate,
autoTranslateLanguage: room.autoTranslateLanguage
}
})}
testID='room-actions-discussions'
left={() => <List.Icon name='discussions' />}
showActionIndicator
/>
<List.Separator />
</>
)
: null}

{['c', 'p', 'd'].includes(t)
? (
<>
Expand Down
2 changes: 1 addition & 1 deletion app/views/RoomView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ class RoomView extends React.Component {
}
});
} else {
navigation.navigate('RoomActionsView', {
navigation.push('RoomActionsView', {
rid: this.rid, t: this.t, room, member
});
}
Expand Down
23 changes: 22 additions & 1 deletion e2e/tests/room/04-discussion.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Discussion', () => {
});

describe('Check RoomActionsView render', () => {
it('should navigete to RoomActionsView', async() => {
it('should navigate to RoomActionsView', async() => {
await waitFor(element(by.id('room-header'))).toBeVisible().withTimeout(5000);
await element(by.id('room-header')).tap();
await waitFor(element(by.id('room-actions-view'))).toBeVisible().withTimeout(5000);
Expand Down Expand Up @@ -130,4 +130,25 @@ describe('Discussion', () => {
await expect(element(by.id('room-info-view-edit-button'))).toBeVisible();
});
});

describe('Open Discussion from DiscussionMessagesView', () => {
const discussionName = `${ data.random }message`;
it('should go back to main room', async() => {
await tapBack();
await waitFor(element(by.id('room-actions-view'))).toBeVisible().withTimeout(5000);
await tapBack();
await waitFor(element(by.id(`room-view-title-${ discussionName }`))).toExist().withTimeout(5000);
await tapBack();
await navigateToRoom();
});

it('should navigate to DiscussionMessagesView', async() => {
await waitFor(element(by.id(`room-view-title-${ channel }`))).toExist().withTimeout(5000);
await waitFor(element(by.id('room-header'))).toBeVisible().withTimeout(5000);
await element(by.id('room-header')).tap();
await waitFor(element(by.id('room-actions-discussions'))).toBeVisible().withTimeout(5000);
await element(by.id('room-actions-discussions')).tap();
await waitFor(element(by.id('discussion-messages-view'))).toBeVisible().withTimeout(5000);
});
});
});