Minor tweaks

This commit is contained in:
Gerzon Z 2021-09-16 14:16:02 -04:00
parent 191e71c887
commit 8ccce58ddd
7 changed files with 862 additions and 850 deletions

View File

@ -70,7 +70,7 @@ import QueueListView from '../ee/omnichannel/views/QueueListView';
import AddChannelTeamView from '../views/AddChannelTeamView'; import AddChannelTeamView from '../views/AddChannelTeamView';
import AddExistingChannelView from '../views/AddExistingChannelView'; import AddExistingChannelView from '../views/AddExistingChannelView';
import SelectListView from '../views/SelectListView'; import SelectListView from '../views/SelectListView';
import DiscussionMessagesView from '../views/DiscussionMessagesView'; import DiscussionsView from '../views/DiscussionsView';
// ChatsStackNavigator // ChatsStackNavigator
const ChatsStack = createStackNavigator(); const ChatsStack = createStackNavigator();
@ -85,10 +85,7 @@ const ChatsStackNavigator = () => {
<ChatsStack.Screen name='RoomInfoView' component={RoomInfoView} options={RoomInfoView.navigationOptions} /> <ChatsStack.Screen name='RoomInfoView' component={RoomInfoView} options={RoomInfoView.navigationOptions} />
<ChatsStack.Screen name='RoomInfoEditView' component={RoomInfoEditView} options={RoomInfoEditView.navigationOptions} /> <ChatsStack.Screen name='RoomInfoEditView' component={RoomInfoEditView} options={RoomInfoEditView.navigationOptions} />
<ChatsStack.Screen name='RoomMembersView' component={RoomMembersView} options={RoomMembersView.navigationOptions} /> <ChatsStack.Screen name='RoomMembersView' component={RoomMembersView} options={RoomMembersView.navigationOptions} />
<ChatsStack.Screen <ChatsStack.Screen name='DiscussionsView' component={DiscussionsView} />
name='DiscussionMessagesView'
component={DiscussionMessagesView}
/>
<ChatsStack.Screen <ChatsStack.Screen
name='SearchMessagesView' name='SearchMessagesView'
component={SearchMessagesView} component={SearchMessagesView}

View File

@ -59,7 +59,7 @@ import QueueListView from '../../ee/omnichannel/views/QueueListView';
import AddChannelTeamView from '../../views/AddChannelTeamView'; import AddChannelTeamView from '../../views/AddChannelTeamView';
import AddExistingChannelView from '../../views/AddExistingChannelView'; import AddExistingChannelView from '../../views/AddExistingChannelView';
import SelectListView from '../../views/SelectListView'; import SelectListView from '../../views/SelectListView';
import DiscussionMessagesView from '../../views/DiscussionMessagesView'; import DiscussionsView from '../../views/DiscussionsView';
import { ModalContainer } from './ModalContainer'; import { ModalContainer } from './ModalContainer';
// ChatsStackNavigator // ChatsStackNavigator
@ -160,34 +160,12 @@ const ModalStackNavigator = React.memo(({ navigation }) => {
component={ForwardLivechatView} component={ForwardLivechatView}
options={ForwardLivechatView.navigationOptions} options={ForwardLivechatView.navigationOptions}
/> />
<ModalStack.Screen <ModalStack.Screen name='LivechatEditView' component={LivechatEditView} options={LivechatEditView.navigationOptions} />
name='LivechatEditView' <ModalStack.Screen name='PickerView' component={PickerView} options={PickerView.navigationOptions} />
component={LivechatEditView} <ModalStack.Screen name='ThreadMessagesView' component={ThreadMessagesView} />
options={LivechatEditView.navigationOptions} <ModalStack.Screen name='DiscussionsView' component={DiscussionsView} />
/> <ModalStack.Screen name='TeamChannelsView' component={TeamChannelsView} options={TeamChannelsView.navigationOptions} />
<ModalStack.Screen <ModalStack.Screen name='MarkdownTableView' component={MarkdownTableView} options={MarkdownTableView.navigationOptions} />
name='PickerView'
component={PickerView}
options={PickerView.navigationOptions}
/>
<ModalStack.Screen
name='ThreadMessagesView'
component={ThreadMessagesView}
/>
<ModalStack.Screen
name='DiscussionMessagesView'
component={DiscussionMessagesView}
/>
<ModalStack.Screen
name='TeamChannelsView'
component={TeamChannelsView}
options={TeamChannelsView.navigationOptions}
/>
<ModalStack.Screen
name='MarkdownTableView'
component={MarkdownTableView}
options={MarkdownTableView.navigationOptions}
/>
<ModalStack.Screen <ModalStack.Screen
name='ReadReceiptsView' name='ReadReceiptsView'
component={ReadReceiptsView} component={ReadReceiptsView}

View File

@ -23,9 +23,9 @@ import Message from '../containers/message';
import RocketChat from '../lib/rocketchat'; import RocketChat from '../lib/rocketchat';
import SearchHeader from '../containers/SearchHeader'; import SearchHeader from '../containers/SearchHeader';
const API_FETCH_COUNT = 25; const API_FETCH_COUNT = 50;
const DiscussionMessagesView = ({ navigation, route }) => { const DiscussionsView = ({ navigation, route }) => {
const rid = route.params?.rid; const rid = route.params?.rid;
const canAutoTranslate = route.params?.canAutoTranslate; const canAutoTranslate = route.params?.canAutoTranslate;
const autoTranslate = route.params?.autoTranslate; const autoTranslate = route.params?.autoTranslate;
@ -42,11 +42,12 @@ const DiscussionMessagesView = ({ navigation, route }) => {
const [discussions, setDiscussions] = useState([]); const [discussions, setDiscussions] = useState([]);
const [search, setSearch] = useState([]); const [search, setSearch] = useState([]);
const [isSearching, setIsSearching] = useState(false); const [isSearching, setIsSearching] = useState(false);
const [total, setTotal] = useState(0);
const { theme } = useTheme(); const { theme } = useTheme();
const insets = useSafeAreaInsets(); const insets = useSafeAreaInsets();
const load = async(text = '') => { const load = async (text = '') => {
if (loading) { if (loading) {
return; return;
} }
@ -63,8 +64,10 @@ const DiscussionMessagesView = ({ navigation, route }) => {
if (result.success) { if (result.success) {
if (isSearching) { if (isSearching) {
setSearch(result.messages); setSearch(result.messages);
setTotal(result.total);
} else { } else {
setDiscussions(result.messages); setDiscussions(result.messages);
setTotal(result.total);
} }
} }
setLoading(false); setLoading(false);
@ -74,7 +77,7 @@ const DiscussionMessagesView = ({ navigation, route }) => {
} }
}; };
const onSearchChangeText = debounce(async(text) => { const onSearchChangeText = debounce(async text => {
setIsSearching(true); setIsSearching(true);
await load(text); await load(text);
}, 300); }, 300);
@ -95,10 +98,7 @@ const DiscussionMessagesView = ({ navigation, route }) => {
headerTitleAlign: 'left', headerTitleAlign: 'left',
headerLeft: () => ( headerLeft: () => (
<HeaderButton.Container left> <HeaderButton.Container left>
<HeaderButton.Item <HeaderButton.Item iconName='close' onPress={onCancelSearchPress} />
iconName='close'
onPress={onCancelSearchPress}
/>
</HeaderButton.Container> </HeaderButton.Container>
), ),
headerTitle: () => ( headerTitle: () => (
@ -119,11 +119,7 @@ const DiscussionMessagesView = ({ navigation, route }) => {
const options = { const options = {
headerLeft: () => ( headerLeft: () => (
<HeaderBackButton <HeaderBackButton labelVisible={false} onPress={() => navigation.pop()} tintColor={themes[theme].headerTintColor} />
labelVisible={false}
onPress={() => navigation.pop()}
tintColor={themes[theme].headerTintColor}
/>
), ),
headerTitleAlign: 'center', headerTitleAlign: 'center',
headerTitle: I18n.t('Discussions'), headerTitle: I18n.t('Discussions'),
@ -154,12 +150,18 @@ const DiscussionMessagesView = ({ navigation, route }) => {
navigation.setOptions(options); navigation.setOptions(options);
}, [navigation, isSearching]); }, [navigation, isSearching]);
const onDiscussionPress = debounce(
const onDiscussionPress = debounce((item) => { item => {
navigation.push('RoomView', { navigation.push('RoomView', {
rid: item.drid, prid: item.rid, name: item.msg, t: 'p' rid: item.drid,
prid: item.rid,
name: item.msg,
t: 'p'
}); });
}, 1000, true); },
1000,
true
);
const renderItem = ({ item }) => ( const renderItem = ({ item }) => (
<Message <Message
@ -176,11 +178,7 @@ const DiscussionMessagesView = ({ navigation, route }) => {
/> />
); );
if (!discussions?.length) { if (!discussions?.length) {
return ( return <BackgroundContainer loading={loading} text={I18n.t('No_discussions')} />;
<>
<BackgroundContainer text={I18n.t('No_discussions')} />
</>
);
} }
return ( return (
@ -196,7 +194,7 @@ const DiscussionMessagesView = ({ navigation, route }) => {
windowSize={10} windowSize={10}
initialNumToRender={7} initialNumToRender={7}
removeClippedSubviews={isIOS} removeClippedSubviews={isIOS}
onEndReached={() => discussions.length > API_FETCH_COUNT ?? load()} onEndReached={() => total > API_FETCH_COUNT ?? load()}
ItemSeparatorComponent={List.Separator} ItemSeparatorComponent={List.Separator}
ListFooterComponent={loading ? <ActivityIndicator theme={theme} /> : null} ListFooterComponent={loading ? <ActivityIndicator theme={theme} /> : null}
scrollIndicatorInsets={{ right: 1 }} scrollIndicatorInsets={{ right: 1 }}
@ -205,7 +203,7 @@ const DiscussionMessagesView = ({ navigation, route }) => {
); );
}; };
DiscussionMessagesView.propTypes = { DiscussionsView.propTypes = {
navigation: PropTypes.object, navigation: PropTypes.object,
route: PropTypes.object, route: PropTypes.object,
item: PropTypes.shape({ item: PropTypes.shape({
@ -213,4 +211,4 @@ DiscussionMessagesView.propTypes = {
}) })
}; };
export default DiscussionMessagesView; export default DiscussionsView;

View File

@ -1004,7 +1004,7 @@ class RoomActionsView extends React.Component {
title='Discussions' title='Discussions'
onPress={() => onPress={() =>
this.onPressTouchable({ this.onPressTouchable({
route: 'DiscussionMessagesView', route: 'DiscussionsView',
params: { params: {
rid, rid,
t, t,

View File

@ -171,24 +171,36 @@ describe('Discussion', () => {
}); });
}); });
describe('Open Discussion from DiscussionMessagesView', () => { describe('Open Discussion from DiscussionsView', () => {
const discussionName = `${ data.random }message`; const discussionName = `${data.random}message`;
it('should go back to main room', async() => { it('should go back to main room', async () => {
await tapBack(); await tapBack();
await waitFor(element(by.id('room-actions-view'))).toBeVisible().withTimeout(5000); await waitFor(element(by.id('room-actions-view')))
.toBeVisible()
.withTimeout(5000);
await tapBack(); await tapBack();
await waitFor(element(by.id(`room-view-title-${ discussionName }`))).toExist().withTimeout(5000); await waitFor(element(by.id(`room-view-title-${discussionName}`)))
.toExist()
.withTimeout(5000);
await tapBack(); await tapBack();
await navigateToRoom(); await navigateToRoom();
}); });
it('should navigate to DiscussionMessagesView', async() => { it('should navigate to DiscussionsView', async () => {
await waitFor(element(by.id(`room-view-title-${ channel }`))).toExist().withTimeout(5000); await waitFor(element(by.id(`room-view-title-${channel}`)))
await waitFor(element(by.id('room-header'))).toBeVisible().withTimeout(5000); .toExist()
.withTimeout(5000);
await waitFor(element(by.id('room-header')))
.toBeVisible()
.withTimeout(5000);
await element(by.id('room-header')).tap(); await element(by.id('room-header')).tap();
await waitFor(element(by.id('room-actions-discussions'))).toBeVisible().withTimeout(5000); await waitFor(element(by.id('room-actions-discussions')))
.toBeVisible()
.withTimeout(5000);
await element(by.id('room-actions-discussions')).tap(); await element(by.id('room-actions-discussions')).tap();
await waitFor(element(by.id('discussion-messages-view'))).toBeVisible().withTimeout(5000); await waitFor(element(by.id('discussion-messages-view')))
.toBeVisible()
.withTimeout(5000);
}); });
}); });
}); });

View File

@ -541,8 +541,35 @@ PODS:
- TOCropViewController - TOCropViewController
- RNLocalize (2.1.1): - RNLocalize (2.1.1):
- React-Core - React-Core
- RNReanimated (1.9.0): - RNReanimated (2.2.0):
- DoubleConversion
- FBLazyVector
- FBReactNativeSpec
- glog
- RCT-Folly
- RCTRequired
- RCTTypeSafety
- React - React
- React-callinvoker
- React-Core
- React-Core/DevSupport
- React-Core/RCTWebSocket
- React-CoreModules
- React-cxxreact
- React-jsi
- React-jsiexecutor
- React-jsinspector
- React-RCTActionSheet
- React-RCTAnimation
- React-RCTBlob
- React-RCTImage
- React-RCTLinking
- React-RCTNetwork
- React-RCTSettings
- React-RCTText
- React-RCTVibration
- ReactCommon/turbomodule/core
- Yoga
- RNRootView (1.0.3): - RNRootView (1.0.3):
- React - React
- RNScreens (2.9.0): - RNScreens (2.9.0):
@ -940,7 +967,7 @@ SPEC CHECKSUMS:
EXVideoThumbnails: cd257fc6e07884a704a5674d362a6410933acb68 EXVideoThumbnails: cd257fc6e07884a704a5674d362a6410933acb68
EXWebBrowser: d37a5ffdea1b65947352bc001dd9f732463725d4 EXWebBrowser: d37a5ffdea1b65947352bc001dd9f732463725d4
FBLazyVector: e686045572151edef46010a6f819ade377dfeb4b FBLazyVector: e686045572151edef46010a6f819ade377dfeb4b
FBReactNativeSpec: b427d2f482828b9533661dbcf9edf846cb60dc7b FBReactNativeSpec: 686ac17e193dcf7d5df4d772b224504dd2f3ad81
Firebase: 919186c8e119dd9372a45fd1dd17a8a942bc1892 Firebase: 919186c8e119dd9372a45fd1dd17a8a942bc1892
FirebaseAnalytics: 5fa308e1b13f838d0f6dc74719ac2a72e8c5afc4 FirebaseAnalytics: 5fa308e1b13f838d0f6dc74719ac2a72e8c5afc4
FirebaseCore: 8cd4f8ea22075e0ee582849b1cf79d8816506085 FirebaseCore: 8cd4f8ea22075e0ee582849b1cf79d8816506085
@ -1026,7 +1053,7 @@ SPEC CHECKSUMS:
RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211 RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211
RNImageCropPicker: 38865ab4af1b0b2146ad66061196bc0184946855 RNImageCropPicker: 38865ab4af1b0b2146ad66061196bc0184946855
RNLocalize: 82a569022724d35461e2dc5b5d015a13c3ca995b RNLocalize: 82a569022724d35461e2dc5b5d015a13c3ca995b
RNReanimated: b5ccb50650ba06f6e749c7c329a1bc3ae0c88b43 RNReanimated: 9c13c86454bfd54dab7505c1a054470bfecd2563
RNRootView: 895a4813dedeaca82db2fa868ca1c333d790e494 RNRootView: 895a4813dedeaca82db2fa868ca1c333d790e494
RNScreens: c526239bbe0e957b988dacc8d75ac94ec9cb19da RNScreens: c526239bbe0e957b988dacc8d75ac94ec9cb19da
RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4 RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4