diff --git a/app/i18n/locales/en.js b/app/i18n/locales/en.js
index 9d9e10765..c973245be 100644
--- a/app/i18n/locales/en.js
+++ b/app/i18n/locales/en.js
@@ -334,6 +334,7 @@ export default {
No_available_agents_to_transfer: 'No available agents to transfer',
Offline: 'Offline',
Oops: 'Oops!',
+ Omnichannel: 'Omnichannel',
Onboarding_description: 'A workspace is your team or organization’s space to collaborate. Ask the workspace admin for address to join or create one for your team.',
Onboarding_join_workspace: 'Join a workspace',
Onboarding_subtitle: 'Beyond Team Collaboration',
diff --git a/app/lib/methods/subscriptions/rooms.js b/app/lib/methods/subscriptions/rooms.js
index 722f6337a..52e474f14 100644
--- a/app/lib/methods/subscriptions/rooms.js
+++ b/app/lib/methods/subscriptions/rooms.js
@@ -14,6 +14,7 @@ import buildMessage from '../helpers/buildMessage';
import RocketChat from '../../rocketchat';
import EventEmitter from '../../../utils/events';
import { removedRoom } from '../../../actions/room';
+import { setUser } from '../../../actions/login';
import { INAPP_NOTIFICATION_EMITTER } from '../../../containers/InAppNotification';
const removeListener = listener => listener.stop();
@@ -241,6 +242,10 @@ export default function subscribeRooms() {
}
const [type, data] = ddpMessage.fields.args;
const [, ev] = ddpMessage.fields.eventName.split('/');
+ if (/userData/.test(ev)) {
+ const [{ diff }] = ddpMessage.fields.args;
+ store.dispatch(setUser({ statusLivechat: diff?.statusLivechat }));
+ }
if (/subscriptions/.test(ev)) {
if (type === 'removed') {
try {
diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js
index 246527a7a..60fd9f766 100644
--- a/app/lib/rocketchat.js
+++ b/app/lib/rocketchat.js
@@ -401,6 +401,7 @@ const RocketChat = {
status: result.me.status,
statusText: result.me.statusText,
customFields: result.me.customFields,
+ statusLivechat: result.me.statusLivechat,
emails: result.me.emails,
roles: result.me.roles
};
@@ -809,6 +810,10 @@ const RocketChat = {
// RC 2.2.0
return this.sdk.get('livechat/custom-fields');
},
+ changeLivechatStatus() {
+ // RC 0.26.0
+ return this.methodCall('livechat:changeLivechatStatus');
+ },
getUidDirectMessage(room) {
const { id: userId } = reduxStore.getState().login.user;
diff --git a/app/sagas/room.js b/app/sagas/room.js
index d910af56f..c7402f93a 100644
--- a/app/sagas/room.js
+++ b/app/sagas/room.js
@@ -74,12 +74,12 @@ const handleDeleteRoom = function* handleDeleteRoom({ rid, t }) {
};
const handleCloseRoom = function* handleCloseRoom({ rid }) {
+ const isMasterDetail = yield select(state => state.app.isMasterDetail);
const requestComment = yield select(state => state.settings.Livechat_request_comment_when_closing_conversation);
const closeRoom = async(comment = '') => {
try {
await RocketChat.closeLivechat(rid, comment);
- const isMasterDetail = await select(state => state.app.isMasterDetail);
if (isMasterDetail) {
Navigation.navigate('DrawerNavigator');
} else {
diff --git a/app/views/SettingsView/index.js b/app/views/SettingsView/index.js
index b5ba2afbe..e7de7f302 100644
--- a/app/views/SettingsView/index.js
+++ b/app/views/SettingsView/index.js
@@ -70,10 +70,20 @@ class SettingsView extends React.Component {
isMasterDetail: PropTypes.bool,
logout: PropTypes.func.isRequired,
selectServerRequest: PropTypes.func,
- token: PropTypes.string,
+ user: PropTypes.shape({
+ roles: PropTypes.array,
+ statusLivechat: PropTypes.string
+ }),
appStart: PropTypes.func
}
+ get showLivechat() {
+ const { user } = this.props;
+ const { roles } = user;
+
+ return roles.includes('livechat-agent');
+ }
+
handleLogout = () => {
showConfirmationAlert({
message: I18n.t('You_will_be_logged_out_of_this_application'),
@@ -114,6 +124,14 @@ class SettingsView extends React.Component {
}
}
+ toggleLivechat = async() => {
+ try {
+ await RocketChat.changeLivechatStatus();
+ } catch {
+ // Do nothing
+ }
+ }
+
navigateToScreen = (screen) => {
const { navigation } = this.props;
navigation.navigate(screen);
@@ -172,6 +190,18 @@ class SettingsView extends React.Component {
);
}
+ renderLivechatSwitch = () => {
+ const { user } = this.props;
+ const { statusLivechat } = user;
+ return (
+
+ );
+ }
+
render() {
const { server, isMasterDetail, theme } = this.props;
return (
@@ -292,6 +322,18 @@ class SettingsView extends React.Component {
+ {this.showLivechat ? (
+ <>
+ this.renderLivechatSwitch()}
+ theme={theme}
+ />
+
+ >
+ ) : null}
+
({
server: state.server,
- token: getUserSelector(state).token,
+ user: getUserSelector(state),
allowCrashReport: state.crashReport.allowCrashReport,
isMasterDetail: state.app.isMasterDetail
});
diff --git a/package.json b/package.json
index 28416cc58..2c95f8283 100644
--- a/package.json
+++ b/package.json
@@ -81,7 +81,7 @@
"react-native-keyboard-tracking-view": "5.7.0",
"react-native-keycommands": "2.0.3",
"react-native-localize": "1.4.0",
- "react-native-mime-types": "^2.2.1",
+ "react-native-mime-types": "2.3.0",
"react-native-modal": "11.5.6",
"react-native-navigation-bar-color": "2.0.1",
"react-native-notifications": "2.1.7",
diff --git a/patches/@rocket.chat+sdk+1.0.0-dj.15.patch b/patches/@rocket.chat+sdk+1.0.0-dj.15.patch
index cf698fd94..35dbeaaed 100644
--- a/patches/@rocket.chat+sdk+1.0.0-dj.15.patch
+++ b/patches/@rocket.chat+sdk+1.0.0-dj.15.patch
@@ -81,3 +81,17 @@ index 17c2c2b..cb094e8 100644
/** Check result data for success, allowing override to ignore some errors */
success (result: any, ignore?: RegExp) {
return (
+diff --git a/node_modules/@rocket.chat/sdk/lib/drivers/ddp.ts b/node_modules/@rocket.chat/sdk/lib/drivers/ddp.ts
+index 247ce8b..2687abc 100644
+--- a/node_modules/@rocket.chat/sdk/lib/drivers/ddp.ts
++++ b/node_modules/@rocket.chat/sdk/lib/drivers/ddp.ts
+@@ -538,7 +538,8 @@ export class DDPDriver extends EventEmitter implements ISocket, IDriver {
+ 'notification',
+ 'rooms-changed',
+ 'subscriptions-changed',
+- 'uiInteraction'
++ 'uiInteraction',
++ 'userData'
+ ].map(event => this.subscribe(topic, `${this.userId}/${event}`, false)))
+ }
+
diff --git a/yarn.lock b/yarn.lock
index 8979a715c..57deed3da 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -11877,7 +11877,7 @@ react-native-localize@1.4.0:
resolved "https://registry.yarnpkg.com/react-native-localize/-/react-native-localize-1.4.0.tgz#4653596d066d0941c48f5404dc1c0d08b6950443"
integrity sha512-W2MQxm6hzD549ZbZcbWzWtYJseY7S7WR2WgsNhm9ULmbwP7tXFfOTbkJjQoqgPXYSXogKN3srXhntVsNZL0Ksw==
-react-native-mime-types@^2.2.1:
+react-native-mime-types@2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/react-native-mime-types/-/react-native-mime-types-2.3.0.tgz#1278602c3da94ffb47c6400ef861901c4ebac420"
integrity sha512-9l/kkT1QM0i0xAKkOADkP6jIMhqiS+R/eSKBS/lsUmuMYMqboClyrwTFFZwUcaVIN0SpeH4wOKhYTqCnFgRsEw==