Remove ee
This commit is contained in:
parent
7414e9afbf
commit
dc3eec8b16
|
@ -1,43 +0,0 @@
|
||||||
The Rocket.Chat Enterprise Edition (EE) license (the "EE License")
|
|
||||||
Copyright (c) 2015-2020 Rocket.Chat Technologies Corp.
|
|
||||||
|
|
||||||
With regard to the Rocket.Chat Software:
|
|
||||||
|
|
||||||
This software and associated documentation files (the "Software") may only be
|
|
||||||
used in production, if you (and any entity that you represent) have agreed to,
|
|
||||||
and are in compliance with, the Rocket.Chat Subscription Terms of Service,
|
|
||||||
available at https://rocket.chat/terms (the "EE Terms"), or other agreement
|
|
||||||
governing the use of the Software, as agreed by you and Rocket.Chat, and otherwise
|
|
||||||
have a valid Rocket.Chat Enterprise Edition subscription for the correct number
|
|
||||||
of user seats. Subject to the foregoing sentence, you are free to modify this
|
|
||||||
Software and publish patches to the Software. You agree that Rocket.Chat and/or
|
|
||||||
its licensors (as applicable) retain all right, title and interest in and to all
|
|
||||||
such modifications and/or patches, and all such modifications and/or patches may
|
|
||||||
only be used, copied, modified, displayed, distributed, or otherwise exploited
|
|
||||||
with a valid Rocket.Chat Enterprise Edition subscription for the correct number
|
|
||||||
of user seats. Notwithstanding the foregoing, you may copy and modify the Software
|
|
||||||
for development and testing purposes, without requiring a Subscription. You agree
|
|
||||||
that Rocket.Chat and/or its licensors (as applicable) retain all right, title and
|
|
||||||
interest in and to all such modifications. You are not granted any other rights
|
|
||||||
beyond what is expressly stated herein. Subject to the foregoing, it is forbidden
|
|
||||||
to copy, merge, publish, distribute, sublicense, and/or sell the Software.
|
|
||||||
|
|
||||||
This EE License applies only to the part of this Software that is not distributed
|
|
||||||
as part of Rocket.Chat Community Edition (CE). Any part of this Software distributed
|
|
||||||
as part of Rocket.Chat CE or is served client-side as an image, font, cascading
|
|
||||||
stylesheet (CSS), file which produces or is compiled, arranged, augmented, or combined
|
|
||||||
into client-side JavaScript, in whole or in part, is copyrighted under the MIT Expat
|
|
||||||
license. The full text of this EE License shall be included in all copies or substantial
|
|
||||||
portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
|
|
||||||
For all third-party components incorporated into the Rocket.Chat Software,
|
|
||||||
those components are licensed under the original license provided by the owner
|
|
||||||
of the applicable component.
|
|
|
@ -1,55 +0,0 @@
|
||||||
import * as types from '../../../actions/actionsTypes';
|
|
||||||
|
|
||||||
export function inquirySetEnabled(enabled) {
|
|
||||||
return {
|
|
||||||
type: types.INQUIRY.SET_ENABLED,
|
|
||||||
enabled
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function inquiryReset() {
|
|
||||||
return {
|
|
||||||
type: types.INQUIRY.RESET
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function inquiryQueueAdd(inquiry) {
|
|
||||||
return {
|
|
||||||
type: types.INQUIRY.QUEUE_ADD,
|
|
||||||
inquiry
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function inquiryQueueUpdate(inquiry) {
|
|
||||||
return {
|
|
||||||
type: types.INQUIRY.QUEUE_UPDATE,
|
|
||||||
inquiry
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function inquiryQueueRemove(inquiryId) {
|
|
||||||
return {
|
|
||||||
type: types.INQUIRY.QUEUE_REMOVE,
|
|
||||||
inquiryId
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function inquiryRequest() {
|
|
||||||
return {
|
|
||||||
type: types.INQUIRY.REQUEST
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function inquirySuccess(inquiries) {
|
|
||||||
return {
|
|
||||||
type: types.INQUIRY.SUCCESS,
|
|
||||||
inquiries
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function inquiryFailure(error) {
|
|
||||||
return {
|
|
||||||
type: types.INQUIRY.FAILURE,
|
|
||||||
error
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,84 +0,0 @@
|
||||||
import React, { memo, useState, useEffect } from 'react';
|
|
||||||
import {
|
|
||||||
View, Text, StyleSheet, Switch
|
|
||||||
} from 'react-native';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
import Touch from '../../../utils/touch';
|
|
||||||
import { CustomIcon } from '../../../lib/Icons';
|
|
||||||
import I18n from '../../../i18n';
|
|
||||||
import styles from '../../../views/RoomsListView/styles';
|
|
||||||
import { themes, SWITCH_TRACK_COLOR } from '../../../constants/colors';
|
|
||||||
import { withTheme } from '../../../theme';
|
|
||||||
import UnreadBadge from '../../../presentation/UnreadBadge';
|
|
||||||
import RocketChat from '../../../lib/rocketchat';
|
|
||||||
import { isOmnichannelStatusAvailable, changeLivechatStatus } from '../lib';
|
|
||||||
|
|
||||||
const OmnichannelStatus = memo(({
|
|
||||||
searching, goQueue, theme, queueSize, inquiryEnabled, user
|
|
||||||
}) => {
|
|
||||||
if (searching > 0 || !(RocketChat.isOmnichannelModuleAvailable() && user?.roles?.includes('livechat-agent'))) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const [status, setStatus] = useState(isOmnichannelStatusAvailable(user));
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setStatus(isOmnichannelStatusAvailable(user));
|
|
||||||
}, [user.statusLivechat]);
|
|
||||||
|
|
||||||
const toggleLivechat = async() => {
|
|
||||||
try {
|
|
||||||
setStatus(v => !v);
|
|
||||||
await changeLivechatStatus();
|
|
||||||
} catch {
|
|
||||||
setStatus(v => !v);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Touch
|
|
||||||
onPress={goQueue}
|
|
||||||
theme={theme}
|
|
||||||
style={{ backgroundColor: themes[theme].headerSecondaryBackground }}
|
|
||||||
>
|
|
||||||
<View
|
|
||||||
style={[
|
|
||||||
styles.dropdownContainerHeader,
|
|
||||||
{ borderBottomWidth: StyleSheet.hairlineWidth, borderColor: themes[theme].separatorColor }
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<CustomIcon style={[styles.queueIcon, { color: themes[theme].auxiliaryText }]} size={22} name='omnichannel' />
|
|
||||||
<Text style={[styles.queueToggleText, { color: themes[theme].auxiliaryText }]}>{I18n.t('Omnichannel')}</Text>
|
|
||||||
{inquiryEnabled
|
|
||||||
? (
|
|
||||||
<UnreadBadge
|
|
||||||
style={styles.queueIcon}
|
|
||||||
unread={queueSize}
|
|
||||||
theme={theme}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
: null}
|
|
||||||
<Switch
|
|
||||||
style={styles.omnichannelToggle}
|
|
||||||
value={status}
|
|
||||||
trackColor={SWITCH_TRACK_COLOR}
|
|
||||||
onValueChange={toggleLivechat}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
</Touch>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
OmnichannelStatus.propTypes = {
|
|
||||||
searching: PropTypes.bool,
|
|
||||||
goQueue: PropTypes.func,
|
|
||||||
queueSize: PropTypes.number,
|
|
||||||
inquiryEnabled: PropTypes.bool,
|
|
||||||
theme: PropTypes.string,
|
|
||||||
user: PropTypes.shape({
|
|
||||||
roles: PropTypes.array,
|
|
||||||
statusLivechat: PropTypes.string
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
export default withTheme(OmnichannelStatus);
|
|
|
@ -1,40 +0,0 @@
|
||||||
import subscribeInquiry from './subscriptions/inquiry';
|
|
||||||
import RocketChat from '../../../lib/rocketchat';
|
|
||||||
import EventEmitter from '../../../utils/events';
|
|
||||||
|
|
||||||
export const isOmnichannelStatusAvailable = user => user?.statusLivechat === 'available';
|
|
||||||
|
|
||||||
// RC 0.26.0
|
|
||||||
export const changeLivechatStatus = () => RocketChat.methodCallWrapper('livechat:changeLivechatStatus');
|
|
||||||
|
|
||||||
// RC 2.4.0
|
|
||||||
export const getInquiriesQueued = () => RocketChat.sdk.get('livechat/inquiries.queued');
|
|
||||||
|
|
||||||
// this inquiry is added to the db by the subscriptions stream
|
|
||||||
// and will be removed by the queue stream
|
|
||||||
// RC 2.4.0
|
|
||||||
export const takeInquiry = inquiryId => RocketChat.methodCallWrapper('livechat:takeInquiry', inquiryId);
|
|
||||||
|
|
||||||
class Omnichannel {
|
|
||||||
constructor() {
|
|
||||||
this.inquirySub = null;
|
|
||||||
EventEmitter.addEventListener('INQUIRY_SUBSCRIBE', this.subscribeInquiry);
|
|
||||||
EventEmitter.addEventListener('INQUIRY_UNSUBSCRIBE', this.unsubscribeInquiry);
|
|
||||||
}
|
|
||||||
|
|
||||||
subscribeInquiry = async() => {
|
|
||||||
console.log('[RCRN] Subscribing to inquiry');
|
|
||||||
this.inquirySub = await subscribeInquiry();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsubscribeInquiry = () => {
|
|
||||||
if (this.inquirySub) {
|
|
||||||
console.log('[RCRN] Unsubscribing from inquiry');
|
|
||||||
this.inquirySub.stop();
|
|
||||||
this.inquirySub = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
const omnichannel = new Omnichannel();
|
|
|
@ -1,95 +0,0 @@
|
||||||
import log from '../../../../utils/log';
|
|
||||||
import store from '../../../../lib/createStore';
|
|
||||||
import RocketChat from '../../../../lib/rocketchat';
|
|
||||||
import {
|
|
||||||
inquiryRequest,
|
|
||||||
inquiryQueueAdd,
|
|
||||||
inquiryQueueUpdate,
|
|
||||||
inquiryQueueRemove
|
|
||||||
} from '../../actions/inquiry';
|
|
||||||
|
|
||||||
const removeListener = listener => listener.stop();
|
|
||||||
|
|
||||||
let connectedListener;
|
|
||||||
let disconnectedListener;
|
|
||||||
let queueListener;
|
|
||||||
|
|
||||||
const streamTopic = 'stream-livechat-inquiry-queue-observer';
|
|
||||||
|
|
||||||
export default function subscribeInquiry() {
|
|
||||||
const handleConnection = () => {
|
|
||||||
store.dispatch(inquiryRequest());
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleQueueMessageReceived = (ddpMessage) => {
|
|
||||||
const [{ type, ...sub }] = ddpMessage.fields.args;
|
|
||||||
|
|
||||||
// added can be ignored, since it is handled by 'changed' event
|
|
||||||
if (/added/.test(type)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the sub isn't on the queue anymore
|
|
||||||
if (sub.status !== 'queued') {
|
|
||||||
// remove it from the queue
|
|
||||||
store.dispatch(inquiryQueueRemove(sub._id));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { queued } = store.getState().inquiry;
|
|
||||||
// check if this sub is on the current queue
|
|
||||||
const idx = queued.findIndex(item => item._id === sub._id);
|
|
||||||
if (idx >= 0) {
|
|
||||||
// if it is on the queue let's update
|
|
||||||
store.dispatch(inquiryQueueUpdate(sub));
|
|
||||||
} else {
|
|
||||||
// if it is not on the queue let's add
|
|
||||||
store.dispatch(inquiryQueueAdd(sub));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const stop = () => {
|
|
||||||
if (connectedListener) {
|
|
||||||
connectedListener.then(removeListener);
|
|
||||||
connectedListener = false;
|
|
||||||
}
|
|
||||||
if (disconnectedListener) {
|
|
||||||
disconnectedListener.then(removeListener);
|
|
||||||
disconnectedListener = false;
|
|
||||||
}
|
|
||||||
if (queueListener) {
|
|
||||||
queueListener.then(removeListener);
|
|
||||||
queueListener = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
connectedListener = RocketChat.onStreamData('connected', handleConnection);
|
|
||||||
disconnectedListener = RocketChat.onStreamData('close', handleConnection);
|
|
||||||
queueListener = RocketChat.onStreamData(streamTopic, handleQueueMessageReceived);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const { user } = store.getState().login;
|
|
||||||
RocketChat.getAgentDepartments(user.id).then((result) => {
|
|
||||||
if (result.success) {
|
|
||||||
const { departments } = result;
|
|
||||||
|
|
||||||
if (!departments.length || RocketChat.hasRole('livechat-manager')) {
|
|
||||||
RocketChat.subscribe(streamTopic, 'public').catch(e => console.log(e));
|
|
||||||
}
|
|
||||||
|
|
||||||
const departmentIds = departments.map(({ departmentId }) => departmentId);
|
|
||||||
departmentIds.forEach((departmentId) => {
|
|
||||||
// subscribe to all departments of the agent
|
|
||||||
RocketChat.subscribe(streamTopic, `department/${ departmentId }`).catch(e => console.log(e));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
stop: () => stop()
|
|
||||||
};
|
|
||||||
} catch (e) {
|
|
||||||
log(e);
|
|
||||||
return Promise.reject();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
import { INQUIRY } from '../../../actions/actionsTypes';
|
|
||||||
|
|
||||||
const initialState = {
|
|
||||||
enabled: false,
|
|
||||||
queued: [],
|
|
||||||
error: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function inquiry(state = initialState, action) {
|
|
||||||
switch (action.type) {
|
|
||||||
case INQUIRY.SUCCESS:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
queued: action.inquiries
|
|
||||||
};
|
|
||||||
case INQUIRY.FAILURE:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
error: action.error
|
|
||||||
};
|
|
||||||
case INQUIRY.SET_ENABLED:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
enabled: action.enabled
|
|
||||||
};
|
|
||||||
case INQUIRY.QUEUE_ADD:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
queued: [...state.queued, action.inquiry]
|
|
||||||
};
|
|
||||||
case INQUIRY.QUEUE_UPDATE:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
queued: state.queued.map((item) => {
|
|
||||||
if (item._id === action.inquiry._id) {
|
|
||||||
return action.inquiry;
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
})
|
|
||||||
};
|
|
||||||
case INQUIRY.QUEUE_REMOVE:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
queued: state.queued.filter(({ _id }) => _id !== action.inquiryId)
|
|
||||||
};
|
|
||||||
case INQUIRY.RESET:
|
|
||||||
return initialState;
|
|
||||||
default:
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
import { put, takeLatest, select } from 'redux-saga/effects';
|
|
||||||
|
|
||||||
import * as types from '../../../actions/actionsTypes';
|
|
||||||
import RocketChat from '../../../lib/rocketchat';
|
|
||||||
import EventEmitter from '../../../utils/events';
|
|
||||||
import { inquirySuccess, inquiryFailure, inquirySetEnabled } from '../actions/inquiry';
|
|
||||||
import { isOmnichannelStatusAvailable, getInquiriesQueued } from '../lib';
|
|
||||||
|
|
||||||
const handleRequest = function* handleRequest() {
|
|
||||||
try {
|
|
||||||
const routingConfig = yield RocketChat.getRoutingConfig();
|
|
||||||
const user = yield select(state => state.login.user);
|
|
||||||
// if routingConfig showQueue is enabled and omnichannel is enabled
|
|
||||||
const showQueue = routingConfig.showQueue && isOmnichannelStatusAvailable(user);
|
|
||||||
|
|
||||||
if (showQueue) {
|
|
||||||
// get all the current chats on the queue
|
|
||||||
const result = yield getInquiriesQueued();
|
|
||||||
if (result.success) {
|
|
||||||
const { inquiries } = result;
|
|
||||||
|
|
||||||
// subscribe to inquiry queue changes
|
|
||||||
EventEmitter.emit('INQUIRY_SUBSCRIBE');
|
|
||||||
|
|
||||||
// put request result on redux state
|
|
||||||
yield put(inquirySuccess(inquiries));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// set enabled to know if we should show the queue button
|
|
||||||
yield put(inquirySetEnabled(showQueue));
|
|
||||||
} catch (e) {
|
|
||||||
yield put(inquiryFailure(e));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const root = function* root() {
|
|
||||||
yield takeLatest(types.INQUIRY.REQUEST, handleRequest);
|
|
||||||
};
|
|
||||||
export default root;
|
|
|
@ -1,8 +0,0 @@
|
||||||
import { createSelector } from 'reselect';
|
|
||||||
|
|
||||||
const getInquiryQueue = state => state.inquiry.queued;
|
|
||||||
|
|
||||||
export const getInquiryQueueSelector = createSelector(
|
|
||||||
[getInquiryQueue],
|
|
||||||
queue => queue
|
|
||||||
);
|
|
|
@ -1,160 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { FlatList } from 'react-native';
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import isEqual from 'react-fast-compare';
|
|
||||||
|
|
||||||
import I18n from '../../../i18n';
|
|
||||||
import RoomItem, { ROW_HEIGHT } from '../../../presentation/RoomItem';
|
|
||||||
import { MAX_SIDEBAR_WIDTH } from '../../../constants/tablet';
|
|
||||||
import { isTablet, isIOS } from '../../../utils/deviceInfo';
|
|
||||||
import { getUserSelector } from '../../../selectors/login';
|
|
||||||
import { withTheme } from '../../../theme';
|
|
||||||
import { withDimensions } from '../../../dimensions';
|
|
||||||
import SafeAreaView from '../../../containers/SafeAreaView';
|
|
||||||
import { themes } from '../../../constants/colors';
|
|
||||||
import StatusBar from '../../../containers/StatusBar';
|
|
||||||
import { goRoom } from '../../../utils/goRoom';
|
|
||||||
import { CloseModalButton } from '../../../containers/HeaderButton';
|
|
||||||
import RocketChat from '../../../lib/rocketchat';
|
|
||||||
import { logEvent, events } from '../../../utils/log';
|
|
||||||
import { getInquiryQueueSelector } from '../selectors/inquiry';
|
|
||||||
|
|
||||||
const INITIAL_NUM_TO_RENDER = isTablet ? 20 : 12;
|
|
||||||
const getItemLayout = (data, index) => ({
|
|
||||||
length: ROW_HEIGHT,
|
|
||||||
offset: ROW_HEIGHT * index,
|
|
||||||
index
|
|
||||||
});
|
|
||||||
const keyExtractor = item => item.rid;
|
|
||||||
|
|
||||||
class QueueListView extends React.Component {
|
|
||||||
static navigationOptions = ({ navigation, isMasterDetail }) => {
|
|
||||||
const options = {
|
|
||||||
title: I18n.t('Queued_chats')
|
|
||||||
};
|
|
||||||
if (isMasterDetail) {
|
|
||||||
options.headerLeft = () => <CloseModalButton navigation={navigation} testID='directory-view-close' />;
|
|
||||||
}
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
user: PropTypes.shape({
|
|
||||||
id: PropTypes.string,
|
|
||||||
username: PropTypes.string,
|
|
||||||
token: PropTypes.string
|
|
||||||
}),
|
|
||||||
isMasterDetail: PropTypes.bool,
|
|
||||||
width: PropTypes.number,
|
|
||||||
queued: PropTypes.array,
|
|
||||||
server: PropTypes.string,
|
|
||||||
useRealName: PropTypes.bool,
|
|
||||||
navigation: PropTypes.object,
|
|
||||||
theme: PropTypes.string
|
|
||||||
}
|
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps) {
|
|
||||||
const { queued } = this.props;
|
|
||||||
if (!isEqual(nextProps.queued, queued)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressItem = (item = {}) => {
|
|
||||||
logEvent(events.QL_GO_ROOM);
|
|
||||||
const { navigation, isMasterDetail } = this.props;
|
|
||||||
if (isMasterDetail) {
|
|
||||||
navigation.navigate('DrawerNavigator');
|
|
||||||
} else {
|
|
||||||
navigation.navigate('RoomsListView');
|
|
||||||
}
|
|
||||||
|
|
||||||
goRoom({
|
|
||||||
item: {
|
|
||||||
...item,
|
|
||||||
// we're calling v as visitor on our mergeSubscriptionsRooms
|
|
||||||
visitor: item.v
|
|
||||||
},
|
|
||||||
isMasterDetail
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
getRoomTitle = item => RocketChat.getRoomTitle(item)
|
|
||||||
|
|
||||||
getRoomAvatar = item => RocketChat.getRoomAvatar(item)
|
|
||||||
|
|
||||||
getUidDirectMessage = room => RocketChat.getUidDirectMessage(room)
|
|
||||||
|
|
||||||
renderItem = ({ item }) => {
|
|
||||||
const {
|
|
||||||
user: {
|
|
||||||
id: userId,
|
|
||||||
username,
|
|
||||||
token
|
|
||||||
},
|
|
||||||
server,
|
|
||||||
useRealName,
|
|
||||||
theme,
|
|
||||||
isMasterDetail,
|
|
||||||
width
|
|
||||||
} = this.props;
|
|
||||||
const id = this.getUidDirectMessage(item);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<RoomItem
|
|
||||||
item={item}
|
|
||||||
theme={theme}
|
|
||||||
id={id}
|
|
||||||
type={item.t}
|
|
||||||
userId={userId}
|
|
||||||
username={username}
|
|
||||||
token={token}
|
|
||||||
baseUrl={server}
|
|
||||||
onPress={this.onPressItem}
|
|
||||||
testID={`queue-list-view-item-${ item.name }`}
|
|
||||||
width={isMasterDetail ? MAX_SIDEBAR_WIDTH : width}
|
|
||||||
useRealName={useRealName}
|
|
||||||
getRoomTitle={this.getRoomTitle}
|
|
||||||
getRoomAvatar={this.getRoomAvatar}
|
|
||||||
visitor={item.v}
|
|
||||||
swipeEnabled={false}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { queued, theme } = this.props;
|
|
||||||
return (
|
|
||||||
<SafeAreaView testID='queue-list-view' theme={theme} style={{ backgroundColor: themes[theme].backgroundColor }}>
|
|
||||||
<StatusBar theme={theme} />
|
|
||||||
<FlatList
|
|
||||||
ref={this.getScrollRef}
|
|
||||||
data={queued}
|
|
||||||
extraData={queued}
|
|
||||||
keyExtractor={keyExtractor}
|
|
||||||
style={{ backgroundColor: themes[theme].backgroundColor }}
|
|
||||||
renderItem={this.renderItem}
|
|
||||||
getItemLayout={getItemLayout}
|
|
||||||
removeClippedSubviews={isIOS}
|
|
||||||
keyboardShouldPersistTaps='always'
|
|
||||||
initialNumToRender={INITIAL_NUM_TO_RENDER}
|
|
||||||
windowSize={9}
|
|
||||||
onEndReached={this.onEndReached}
|
|
||||||
onEndReachedThreshold={0.5}
|
|
||||||
/>
|
|
||||||
</SafeAreaView>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
user: getUserSelector(state),
|
|
||||||
isMasterDetail: state.app.isMasterDetail,
|
|
||||||
server: state.server.server,
|
|
||||||
useRealName: state.settings.UI_Use_Real_Name,
|
|
||||||
queued: getInquiryQueueSelector(state)
|
|
||||||
});
|
|
||||||
export default connect(mapStateToProps)(withDimensions(withTheme(QueueListView)));
|
|
|
@ -18,8 +18,6 @@ import inviteLinks from './inviteLinks';
|
||||||
import createDiscussion from './createDiscussion';
|
import createDiscussion from './createDiscussion';
|
||||||
import enterpriseModules from './enterpriseModules';
|
import enterpriseModules from './enterpriseModules';
|
||||||
|
|
||||||
import inquiry from '../ee/omnichannel/reducers/inquiry';
|
|
||||||
|
|
||||||
export default combineReducers({
|
export default combineReducers({
|
||||||
settings,
|
settings,
|
||||||
login,
|
login,
|
||||||
|
@ -38,6 +36,5 @@ export default combineReducers({
|
||||||
usersTyping,
|
usersTyping,
|
||||||
inviteLinks,
|
inviteLinks,
|
||||||
createDiscussion,
|
createDiscussion,
|
||||||
inquiry,
|
|
||||||
enterpriseModules
|
enterpriseModules
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,8 +11,6 @@ import deepLinking from './deepLinking';
|
||||||
import inviteLinks from './inviteLinks';
|
import inviteLinks from './inviteLinks';
|
||||||
import createDiscussion from './createDiscussion';
|
import createDiscussion from './createDiscussion';
|
||||||
|
|
||||||
import inquiry from '../ee/omnichannel/sagas/inquiry';
|
|
||||||
|
|
||||||
const root = function* root() {
|
const root = function* root() {
|
||||||
yield all([
|
yield all([
|
||||||
init(),
|
init(),
|
||||||
|
@ -25,8 +23,7 @@ const root = function* root() {
|
||||||
state(),
|
state(),
|
||||||
deepLinking(),
|
deepLinking(),
|
||||||
inviteLinks(),
|
inviteLinks(),
|
||||||
createDiscussion(),
|
createDiscussion()
|
||||||
inquiry()
|
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,6 @@ import { localAuthenticate } from '../utils/localAuthentication';
|
||||||
import { setActiveUsers } from '../actions/activeUsers';
|
import { setActiveUsers } from '../actions/activeUsers';
|
||||||
import UserPreferences from '../lib/userPreferences';
|
import UserPreferences from '../lib/userPreferences';
|
||||||
|
|
||||||
import { inquiryRequest, inquiryReset } from '../ee/omnichannel/actions/inquiry';
|
|
||||||
import { isOmnichannelStatusAvailable } from '../ee/omnichannel/lib';
|
|
||||||
|
|
||||||
const getServer = state => state.server.server;
|
const getServer = state => state.server.server;
|
||||||
const loginWithPasswordCall = args => RocketChat.loginWithPassword(args);
|
const loginWithPasswordCall = args => RocketChat.loginWithPassword(args);
|
||||||
const loginCall = args => RocketChat.login(args);
|
const loginCall = args => RocketChat.login(args);
|
||||||
|
@ -87,12 +84,8 @@ const fetchUsersPresence = function* fetchUserPresence() {
|
||||||
RocketChat.subscribeUsersPresence();
|
RocketChat.subscribeUsersPresence();
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchEnterpriseModules = function* fetchEnterpriseModules({ user }) {
|
const fetchEnterpriseModules = function* fetchEnterpriseModules() {
|
||||||
yield RocketChat.getEnterpriseModules();
|
yield RocketChat.getEnterpriseModules();
|
||||||
|
|
||||||
if (isOmnichannelStatusAvailable(user) && RocketChat.isOmnichannelModuleAvailable()) {
|
|
||||||
yield put(inquiryRequest());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleLoginSuccess = function* handleLoginSuccess({ user }) {
|
const handleLoginSuccess = function* handleLoginSuccess({ user }) {
|
||||||
|
@ -221,14 +214,6 @@ const handleSetUser = function* handleSetUser({ user }) {
|
||||||
const userId = yield select(state => state.login.user.id);
|
const userId = yield select(state => state.login.user.id);
|
||||||
yield put(setActiveUsers({ [userId]: user }));
|
yield put(setActiveUsers({ [userId]: user }));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user?.statusLivechat && RocketChat.isOmnichannelModuleAvailable()) {
|
|
||||||
if (isOmnichannelStatusAvailable(user)) {
|
|
||||||
yield put(inquiryRequest());
|
|
||||||
} else {
|
|
||||||
yield put(inquiryReset());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const root = function* root() {
|
const root = function* root() {
|
||||||
|
|
|
@ -19,8 +19,6 @@ import { BASIC_AUTH_KEY, setBasicAuth } from '../utils/fetch';
|
||||||
import { appStart, ROOT_INSIDE, ROOT_OUTSIDE } from '../actions/app';
|
import { appStart, ROOT_INSIDE, ROOT_OUTSIDE } from '../actions/app';
|
||||||
import UserPreferences from '../lib/userPreferences';
|
import UserPreferences from '../lib/userPreferences';
|
||||||
|
|
||||||
import { inquiryReset } from '../ee/omnichannel/actions/inquiry';
|
|
||||||
|
|
||||||
const getServerInfo = function* getServerInfo({ server, raiseError = true }) {
|
const getServerInfo = function* getServerInfo({ server, raiseError = true }) {
|
||||||
try {
|
try {
|
||||||
const serverInfo = yield RocketChat.getServerInfo(server);
|
const serverInfo = yield RocketChat.getServerInfo(server);
|
||||||
|
@ -66,7 +64,6 @@ const getServerInfo = function* getServerInfo({ server, raiseError = true }) {
|
||||||
|
|
||||||
const handleSelectServer = function* handleSelectServer({ server, version, fetchVersion }) {
|
const handleSelectServer = function* handleSelectServer({ server, version, fetchVersion }) {
|
||||||
try {
|
try {
|
||||||
yield put(inquiryReset());
|
|
||||||
const serversDB = database.servers;
|
const serversDB = database.servers;
|
||||||
yield UserPreferences.setStringAsync(RocketChat.CURRENT_SERVER, server);
|
yield UserPreferences.setStringAsync(RocketChat.CURRENT_SERVER, server);
|
||||||
const userId = yield UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ server }`);
|
const userId = yield UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ server }`);
|
||||||
|
|
|
@ -58,8 +58,6 @@ import StatusView from '../views/StatusView';
|
||||||
import ShareView from '../views/ShareView';
|
import ShareView from '../views/ShareView';
|
||||||
import CreateDiscussionView from '../views/CreateDiscussionView';
|
import CreateDiscussionView from '../views/CreateDiscussionView';
|
||||||
|
|
||||||
import QueueListView from '../ee/omnichannel/views/QueueListView';
|
|
||||||
|
|
||||||
// ChatsStackNavigator
|
// ChatsStackNavigator
|
||||||
const ChatsStack = createStackNavigator();
|
const ChatsStack = createStackNavigator();
|
||||||
const ChatsStackNavigator = () => {
|
const ChatsStackNavigator = () => {
|
||||||
|
@ -167,11 +165,6 @@ const ChatsStackNavigator = () => {
|
||||||
component={ReadReceiptsView}
|
component={ReadReceiptsView}
|
||||||
options={ReadReceiptsView.navigationOptions}
|
options={ReadReceiptsView.navigationOptions}
|
||||||
/>
|
/>
|
||||||
<ChatsStack.Screen
|
|
||||||
name='QueueListView'
|
|
||||||
component={QueueListView}
|
|
||||||
options={QueueListView.navigationOptions}
|
|
||||||
/>
|
|
||||||
</ChatsStack.Navigator>
|
</ChatsStack.Navigator>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -54,8 +54,6 @@ import CreateDiscussionView from '../../views/CreateDiscussionView';
|
||||||
import { setKeyCommands, deleteKeyCommands } from '../../commands';
|
import { setKeyCommands, deleteKeyCommands } from '../../commands';
|
||||||
import ShareView from '../../views/ShareView';
|
import ShareView from '../../views/ShareView';
|
||||||
|
|
||||||
import QueueListView from '../../ee/omnichannel/views/QueueListView';
|
|
||||||
|
|
||||||
// ChatsStackNavigator
|
// ChatsStackNavigator
|
||||||
const ChatsStack = createStackNavigator();
|
const ChatsStack = createStackNavigator();
|
||||||
const ChatsStackNavigator = React.memo(() => {
|
const ChatsStackNavigator = React.memo(() => {
|
||||||
|
@ -154,11 +152,6 @@ const ModalStackNavigator = React.memo(({ navigation }) => {
|
||||||
component={DirectoryView}
|
component={DirectoryView}
|
||||||
options={props => DirectoryView.navigationOptions({ ...props, isMasterDetail: true })}
|
options={props => DirectoryView.navigationOptions({ ...props, isMasterDetail: true })}
|
||||||
/>
|
/>
|
||||||
<ModalStack.Screen
|
|
||||||
name='QueueListView'
|
|
||||||
component={QueueListView}
|
|
||||||
options={props => QueueListView.navigationOptions({ ...props, isMasterDetail: true })}
|
|
||||||
/>
|
|
||||||
<ModalStack.Screen
|
<ModalStack.Screen
|
||||||
name='NotificationPrefView'
|
name='NotificationPrefView'
|
||||||
component={NotificationPrefView}
|
component={NotificationPrefView}
|
||||||
|
|
|
@ -56,8 +56,6 @@ import SafeAreaView from '../../containers/SafeAreaView';
|
||||||
import { withDimensions } from '../../dimensions';
|
import { withDimensions } from '../../dimensions';
|
||||||
import { getHeaderTitlePosition } from '../../containers/Header';
|
import { getHeaderTitlePosition } from '../../containers/Header';
|
||||||
|
|
||||||
import { takeInquiry } from '../../ee/omnichannel/lib';
|
|
||||||
|
|
||||||
const stateAttrsUpdate = [
|
const stateAttrsUpdate = [
|
||||||
'joined',
|
'joined',
|
||||||
'lastOpen',
|
'lastOpen',
|
||||||
|
@ -688,13 +686,7 @@ class RoomView extends React.Component {
|
||||||
joinRoom = async() => {
|
joinRoom = async() => {
|
||||||
logEvent(events.ROOM_JOIN);
|
logEvent(events.ROOM_JOIN);
|
||||||
try {
|
try {
|
||||||
const { room } = this.state;
|
|
||||||
|
|
||||||
if (this.isOmnichannel) {
|
|
||||||
await takeInquiry(room._id);
|
|
||||||
} else {
|
|
||||||
await RocketChat.joinRoom(this.rid, this.t);
|
await RocketChat.joinRoom(this.rid, this.t);
|
||||||
}
|
|
||||||
this.internalSetState({
|
this.internalSetState({
|
||||||
joined: true
|
joined: true
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,31 +3,18 @@ import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import Sort from './Sort';
|
import Sort from './Sort';
|
||||||
|
|
||||||
import OmnichannelStatus from '../../../ee/omnichannel/containers/OmnichannelStatus';
|
|
||||||
|
|
||||||
const ListHeader = React.memo(({
|
const ListHeader = React.memo(({
|
||||||
searching,
|
searching,
|
||||||
sortBy,
|
sortBy,
|
||||||
toggleSort,
|
toggleSort
|
||||||
goQueue,
|
|
||||||
queueSize,
|
|
||||||
inquiryEnabled,
|
|
||||||
user
|
|
||||||
}) => (
|
}) => (
|
||||||
<>
|
|
||||||
<Sort searching={searching} sortBy={sortBy} toggleSort={toggleSort} />
|
<Sort searching={searching} sortBy={sortBy} toggleSort={toggleSort} />
|
||||||
<OmnichannelStatus searching={searching} goQueue={goQueue} inquiryEnabled={inquiryEnabled} queueSize={queueSize} user={user} />
|
|
||||||
</>
|
|
||||||
));
|
));
|
||||||
|
|
||||||
ListHeader.propTypes = {
|
ListHeader.propTypes = {
|
||||||
searching: PropTypes.bool,
|
searching: PropTypes.bool,
|
||||||
sortBy: PropTypes.string,
|
sortBy: PropTypes.string,
|
||||||
toggleSort: PropTypes.func,
|
toggleSort: PropTypes.func
|
||||||
goQueue: PropTypes.func,
|
|
||||||
queueSize: PropTypes.number,
|
|
||||||
inquiryEnabled: PropTypes.bool,
|
|
||||||
user: PropTypes.object
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ListHeader;
|
export default ListHeader;
|
||||||
|
|
|
@ -62,10 +62,6 @@ import { goRoom } from '../../utils/goRoom';
|
||||||
import SafeAreaView from '../../containers/SafeAreaView';
|
import SafeAreaView from '../../containers/SafeAreaView';
|
||||||
import Header, { getHeaderTitlePosition } from '../../containers/Header';
|
import Header, { getHeaderTitlePosition } from '../../containers/Header';
|
||||||
import { withDimensions } from '../../dimensions';
|
import { withDimensions } from '../../dimensions';
|
||||||
import { showErrorAlert, showConfirmationAlert } from '../../utils/info';
|
|
||||||
|
|
||||||
import { getInquiryQueueSelector } from '../../ee/omnichannel/selectors/inquiry';
|
|
||||||
import { changeLivechatStatus, isOmnichannelStatusAvailable } from '../../ee/omnichannel/lib';
|
|
||||||
|
|
||||||
const INITIAL_NUM_TO_RENDER = isTablet ? 20 : 12;
|
const INITIAL_NUM_TO_RENDER = isTablet ? 20 : 12;
|
||||||
const CHATS_HEADER = 'Chats';
|
const CHATS_HEADER = 'Chats';
|
||||||
|
@ -141,9 +137,7 @@ class RoomsListView extends React.Component {
|
||||||
isMasterDetail: PropTypes.bool,
|
isMasterDetail: PropTypes.bool,
|
||||||
rooms: PropTypes.array,
|
rooms: PropTypes.array,
|
||||||
width: PropTypes.number,
|
width: PropTypes.number,
|
||||||
insets: PropTypes.object,
|
insets: PropTypes.object
|
||||||
queueSize: PropTypes.number,
|
|
||||||
inquiryEnabled: PropTypes.bool
|
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -696,41 +690,6 @@ class RoomsListView extends React.Component {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
goQueue = () => {
|
|
||||||
logEvent(events.RL_GO_QUEUE);
|
|
||||||
const {
|
|
||||||
navigation, isMasterDetail, queueSize, inquiryEnabled, user
|
|
||||||
} = this.props;
|
|
||||||
|
|
||||||
// if not-available, prompt to change to available
|
|
||||||
if (!isOmnichannelStatusAvailable(user)) {
|
|
||||||
showConfirmationAlert({
|
|
||||||
message: I18n.t('Omnichannel_enable_alert'),
|
|
||||||
confirmationText: I18n.t('Yes'),
|
|
||||||
onPress: async() => {
|
|
||||||
try {
|
|
||||||
await changeLivechatStatus();
|
|
||||||
} catch {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!inquiryEnabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// prevent navigation to empty list
|
|
||||||
if (!queueSize) {
|
|
||||||
return showErrorAlert(I18n.t('Queue_is_empty'), I18n.t('Oops'));
|
|
||||||
}
|
|
||||||
if (isMasterDetail) {
|
|
||||||
navigation.navigate('ModalStackNavigator', { screen: 'QueueListView' });
|
|
||||||
} else {
|
|
||||||
navigation.navigate('QueueListView');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
goRoom = ({ item, isMasterDetail }) => {
|
goRoom = ({ item, isMasterDetail }) => {
|
||||||
logEvent(events.RL_GO_ROOM);
|
logEvent(events.RL_GO_ROOM);
|
||||||
const { item: currentItem } = this.state;
|
const { item: currentItem } = this.state;
|
||||||
|
@ -848,7 +807,7 @@ class RoomsListView extends React.Component {
|
||||||
renderListHeader = () => {
|
renderListHeader = () => {
|
||||||
const { searching } = this.state;
|
const { searching } = this.state;
|
||||||
const {
|
const {
|
||||||
sortBy, queueSize, inquiryEnabled, user
|
sortBy, user
|
||||||
} = this.props;
|
} = this.props;
|
||||||
return (
|
return (
|
||||||
<ListHeader
|
<ListHeader
|
||||||
|
@ -857,8 +816,6 @@ class RoomsListView extends React.Component {
|
||||||
toggleSort={this.toggleSort}
|
toggleSort={this.toggleSort}
|
||||||
goDirectory={this.goDirectory}
|
goDirectory={this.goDirectory}
|
||||||
goQueue={this.goQueue}
|
goQueue={this.goQueue}
|
||||||
queueSize={queueSize}
|
|
||||||
inquiryEnabled={inquiryEnabled}
|
|
||||||
user={user}
|
user={user}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -1026,9 +983,7 @@ const mapStateToProps = state => ({
|
||||||
useRealName: state.settings.UI_Use_Real_Name,
|
useRealName: state.settings.UI_Use_Real_Name,
|
||||||
appState: state.app.ready && state.app.foreground ? 'foreground' : 'background',
|
appState: state.app.ready && state.app.foreground ? 'foreground' : 'background',
|
||||||
StoreLastMessage: state.settings.Store_Last_Message,
|
StoreLastMessage: state.settings.Store_Last_Message,
|
||||||
rooms: state.room.rooms,
|
rooms: state.room.rooms
|
||||||
queueSize: getInquiryQueueSelector(state).length,
|
|
||||||
inquiryEnabled: state.inquiry.enabled
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
|
Loading…
Reference in New Issue