Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2a48771e1 | ||
|
|
7bd6cf2466 | ||
|
|
ac9247fecb | ||
|
|
8439a1d100 | ||
|
|
b709245b46 | ||
|
|
52e30336ad |
38
dist/bookmarklet.js
vendored
38
dist/bookmarklet.js
vendored
File diff suppressed because one or more lines are too long
38
dist/chatbox.js
vendored
38
dist/chatbox.js
vendored
File diff suppressed because one or more lines are too long
36
dist/component.js
vendored
Normal file
36
dist/component.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "private-safesupport-chatbox",
|
"name": "private-safesupport-chatbox",
|
||||||
"version": "2.0.1",
|
"version": "2.1.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
12
package.json
12
package.json
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "private-safesupport-chatbox",
|
"name": "private-safesupport-chatbox",
|
||||||
"version": "2.0.1",
|
"version": "2.1.1",
|
||||||
"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/component.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "NODE_ENV=production webpack-cli --mode production",
|
"build": "NODE_ENV=production webpack-cli --mode production",
|
||||||
"build:profile": "webpack --mode production --config webpack.config.profile.js",
|
"build:profile": "webpack --mode production --config webpack.config.profile.js",
|
||||||
@@ -118,6 +118,8 @@
|
|||||||
"node-sass": "^4.13.1",
|
"node-sass": "^4.13.1",
|
||||||
"postcss-increase-specificity": "0.6.0",
|
"postcss-increase-specificity": "0.6.0",
|
||||||
"postcss-loader": "3.0.0",
|
"postcss-loader": "3.0.0",
|
||||||
|
"react": "^16.8.6",
|
||||||
|
"react-dom": "^16.8.6",
|
||||||
"sass-loader": "8.0.0",
|
"sass-loader": "8.0.0",
|
||||||
"style-loader": "1.1.2",
|
"style-loader": "1.1.2",
|
||||||
"wait-for-expect": "^3.0.2",
|
"wait-for-expect": "^3.0.2",
|
||||||
@@ -137,11 +139,13 @@
|
|||||||
"node-localstorage": "^2.1.5",
|
"node-localstorage": "^2.1.5",
|
||||||
"olm": "https://packages.matrix.org/npm/olm/olm-3.1.4.tgz",
|
"olm": "https://packages.matrix.org/npm/olm/olm-3.1.4.tgz",
|
||||||
"prop-types": "^15.6.2",
|
"prop-types": "^15.6.2",
|
||||||
"react": "^16.8.6",
|
|
||||||
"react-dom": "^16.8.6",
|
|
||||||
"react-onclickoutside": "^6.9.0",
|
"react-onclickoutside": "^6.9.0",
|
||||||
"react-test-renderer": "^16.13.0",
|
"react-test-renderer": "^16.13.0",
|
||||||
"react-transition-group": "^4.0.0",
|
"react-transition-group": "^4.0.0",
|
||||||
"uuidv4": "^6.0.2"
|
"uuidv4": "^6.0.2"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^16.8.6",
|
||||||
|
"react-dom": "^16.8.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,29 @@ 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',
|
||||||
|
},
|
||||||
|
externals: {
|
||||||
|
react: {
|
||||||
|
commonjs: "react",
|
||||||
|
commonjs2: "react",
|
||||||
|
amd: "React",
|
||||||
|
root: "React"
|
||||||
|
},
|
||||||
|
"react-dom": {
|
||||||
|
commonjs: "react-dom",
|
||||||
|
commonjs2: "react-dom",
|
||||||
|
amd: "ReactDOM",
|
||||||
|
root: "ReactDOM"
|
||||||
|
}
|
||||||
|
}
|
||||||
}];
|
}];
|
||||||
|
|||||||
Reference in New Issue
Block a user