Unverified Commit 1ea698c6 authored by Renato Becker's avatar Renato Becker Committed by GitHub

[FIX] Connecting status (#198)

* Update changelog file.

* Revert "Update changelog file."

This reverts commit cea434f4.

* update changelog file

* Fix CircleCI config

* Fix some issues related to status of connecting agents.
parent 2b34d552
......@@ -29,4 +29,4 @@ jobs:
- run: yarn build
- run: yarn gh-release -y
- run: yarn release -y
......@@ -2,5 +2,8 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## 1.0.0 - 2019-03-13
* Release Livechat client as a community feature
## 0.0.1-1 - 2019-03-12
* Initial release
......@@ -175,13 +175,11 @@ export class ChatContainer extends Component {
const { alerts, dispatch, room: { _id: rid } = {} } = this.props;
if (!rid) {
return;
}
await dispatch({ loading: true });
try {
await Livechat.closeChat({ rid });
if (rid) {
await Livechat.closeChat({ rid });
}
} catch (error) {
console.error(error);
const alert = { id: createToken(), children: 'Error closing chat.', error: true, timeout: 0 };
......@@ -223,8 +221,8 @@ export class ChatContainer extends Component {
}
canFinishChat = () => {
const { room } = this.props;
return room !== undefined;
const { room, connecting } = this.props;
return (room !== undefined) || connecting;
}
canRemoveUserData = () => {
......@@ -236,8 +234,17 @@ export class ChatContainer extends Component {
this.canSwitchDepartment() || this.canFinishChat() || this.canRemoveUserData()
)
checkConnecting() {
const { dispatch, agent, connecting, showConnecting } = this.props;
const connectingStatus = !!(agent && showConnecting);
if (connecting !== connectingStatus) {
dispatch({ connecting: connectingStatus });
}
}
componentDidMount() {
this.loadMessages();
this.checkConnecting();
}
async componentWillReceiveProps({ messages: nextMessages, visible: nextVisible, minimized: nextMinimized }) {
......
......@@ -35,7 +35,8 @@ const doPlaySound = async(message) => {
};
export const initRoom = async() => {
const { room, config: { settings: showConnecting } } = store.state;
const { state } = store;
const { room, config: { settings: { showConnecting } } = {} } = state;
if (!room) {
return;
......@@ -43,7 +44,7 @@ export const initRoom = async() => {
Livechat.unsubscribeAll();
const { token, agent, room: { _id: rid, servedBy } } = store.state;
const { token, agent, room: { _id: rid, servedBy } } = state;
Livechat.subscribeRoom(rid);
let roomAgent = agent;
......@@ -53,7 +54,6 @@ export const initRoom = async() => {
store.setState({ roomAgent });
await store.setState({ agent: roomAgent });
}
const connecting = !!(!roomAgent && showConnecting);
store.setState({ connecting });
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment