Compare commits
9 Commits
bot_signal
...
v2.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac9247fecb | ||
|
|
8439a1d100 | ||
|
|
b709245b46 | ||
|
|
52e30336ad | ||
|
|
bee884c52f | ||
|
|
2ffa63d583 | ||
|
|
a0d08f8f88 | ||
|
|
09cc934fbd | ||
|
|
5a0ed5d36d |
4
dist/bookmarklet.js
vendored
4
dist/bookmarklet.js
vendored
File diff suppressed because one or more lines are too long
4
dist/chatbox.js
vendored
4
dist/chatbox.js
vendored
File diff suppressed because one or more lines are too long
60
dist/component.js
vendored
Normal file
60
dist/component.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
dist/index.html
vendored
2
dist/index.html
vendored
@@ -25,7 +25,7 @@
|
|||||||
anonymousDisplayName: 'Anonymous',
|
anonymousDisplayName: 'Anonymous',
|
||||||
position: 'bottom right',
|
position: 'bottom right',
|
||||||
size: 'large',
|
size: 'large',
|
||||||
maxWaitTime: 6000*3,
|
maxWaitTime: 1000*60*3, // 3 minutes
|
||||||
}
|
}
|
||||||
|
|
||||||
EmbeddableChatbox.mount(config);
|
EmbeddableChatbox.mount(config);
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "private-safesupport-chatbox",
|
"name": "private-safesupport-chatbox",
|
||||||
"version": "1.2.2",
|
"version": "2.1.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "private-safesupport-chatbox",
|
"name": "private-safesupport-chatbox",
|
||||||
"version": "1.2.2",
|
"version": "2.1.0",
|
||||||
"description": "A secure and private embeddable chatbox that connects to Riot",
|
"description": "A secure and private embeddable chatbox that connects to Riot",
|
||||||
"main": "dist/chatbox.js",
|
"main": "dist/chatbox.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ 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()
|
||||||
this.setState({ client: null })
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,38 +461,15 @@ class ChatBox extends React.Component {
|
|||||||
const decryptionErrors = {...this.state.decryptionErrors}
|
const decryptionErrors = {...this.state.decryptionErrors}
|
||||||
delete decryptionErrors[message.id]
|
delete decryptionErrors[message.id]
|
||||||
|
|
||||||
const isOfflineNotice = message.content.msgtype === "m.notice" && message.content.body === CHAT_IS_OFFLINE_NOTICE
|
|
||||||
|
|
||||||
let newMessage = message
|
|
||||||
|
|
||||||
// when the bot sends a notice that the chat is offline
|
|
||||||
// replace the message with the client-configured message
|
|
||||||
// for now we're treating m.notice and m.text messages the same
|
|
||||||
if (isOfflineNotice) {
|
|
||||||
newMessage = {
|
|
||||||
...message,
|
|
||||||
content: {
|
|
||||||
...message.content,
|
|
||||||
body: this.props.chatOfflineMessage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.handleChatOffline()
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
messages: {
|
messages: {
|
||||||
...this.state.messages,
|
...this.state.messages,
|
||||||
[message.id]: newMessage,
|
[message.id]: message,
|
||||||
},
|
},
|
||||||
decryptionErrors
|
decryptionErrors
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChatOffline = () => {
|
|
||||||
this.exitChat(false) // close the chat connection but keep chatbox state
|
|
||||||
this.setState({ ready: true }) // no more loading animation
|
|
||||||
}
|
|
||||||
|
|
||||||
handleKeyDown = (e) => {
|
handleKeyDown = (e) => {
|
||||||
switch (e.keyCode) {
|
switch (e.keyCode) {
|
||||||
case 27:
|
case 27:
|
||||||
@@ -584,6 +561,9 @@ class ChatBox extends React.Component {
|
|||||||
case 'END_CHAT':
|
case 'END_CHAT':
|
||||||
this.displayBotMessage({ body: this.props.exitMessage })
|
this.displayBotMessage({ body: this.props.exitMessage })
|
||||||
return this.exitChat(false); // keep chat state
|
return this.exitChat(false); // keep chat state
|
||||||
|
case 'CHAT_OFFLINE':
|
||||||
|
this.displayBotMessage({ body: this.props.chatOfflineMessage })
|
||||||
|
return this.exitChat(false); // keep chat state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
3
src/outputs/component.js
Normal file
3
src/outputs/component.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import Chatbox from '../components/chatbox';
|
||||||
|
|
||||||
|
export default Chatbox;
|
||||||
@@ -94,4 +94,15 @@ module.exports = [{
|
|||||||
publicPath: '/',
|
publicPath: '/',
|
||||||
filename: 'bookmarklet.js',
|
filename: 'bookmarklet.js',
|
||||||
},
|
},
|
||||||
|
}, {
|
||||||
|
...defaultConfig,
|
||||||
|
entry: './src/outputs/component.js',
|
||||||
|
output: {
|
||||||
|
path: distDir,
|
||||||
|
publicPath: '/',
|
||||||
|
filename: 'component.js',
|
||||||
|
library: 'Chatbox',
|
||||||
|
libraryExport: 'default',
|
||||||
|
libraryTarget: 'commonjs2',
|
||||||
|
},
|
||||||
}];
|
}];
|
||||||
|
|||||||
Reference in New Issue
Block a user