update admin app endpoint and ensure chatbox closes even if leaveRoom fails

This commit is contained in:
Sharon Kennedy 2021-01-20 22:44:53 -05:00
parent 40e968fcee
commit bf29508e8c
6 changed files with 33 additions and 30 deletions

10
dist/bookmarklet.js vendored

File diff suppressed because one or more lines are too long

10
dist/chatbox.js vendored

File diff suppressed because one or more lines are too long

2
dist/component.js vendored

File diff suppressed because one or more lines are too long

4
dist/index.html vendored
View File

@ -13,10 +13,8 @@
<script src="./chatbox.js"></script> <script src="./chatbox.js"></script>
<script> <script>
var config = { var config = {
settingsEndpoint: 'https://safesupport-admin.herokuapp.com/api/get-settings',
matrixServerUrl: 'https://matrix.safesupport.chat' matrixServerUrl: 'https://matrix.safesupport.chat'
} };
EmbeddableChatbox.mount(config); EmbeddableChatbox.mount(config);
</script> </script>

View File

@ -151,6 +151,7 @@ class ChatBox extends React.Component {
exitChat = async (resetState=true) => { exitChat = async (resetState=true) => {
if (this.state.client) { if (this.state.client) {
try {
await this.state.client.leave(this.state.roomId) await this.state.client.leave(this.state.roomId)
const auth = { const auth = {
@ -166,9 +167,13 @@ class ChatBox extends React.Component {
await this.state.client.deactivateAccount(auth, true) await this.state.client.deactivateAccount(auth, true)
await this.state.client.stopClient() await this.state.client.stopClient()
await this.state.client.clearStores() await this.state.client.clearStores()
} catch (err) {
console.log("Error exiting chat", err)
} finally {
this.setState({ client: null, ready: true }) // no more loading animation this.setState({ client: null, ready: true }) // no more loading animation
window.clearInterval(this.state.waitIntervalId) // no more waiting messages window.clearInterval(this.state.waitIntervalId) // no more waiting messages
} }
}
if (this.state.localStorage) { if (this.state.localStorage) {
this.state.localStorage.clear() this.state.localStorage.clear()

View File

@ -1 +1 @@
export const DEFAULT_SETTINGS_ENDPOINT = 'https://safesupport-admin.herokuapp.com/api/get-settings'; export const DEFAULT_SETTINGS_ENDPOINT = 'https://admin.safesupport.chat/api/get-settings';