diff --git a/main.js b/main.js
index 42136c9..441e7da 100644
--- a/main.js
+++ b/main.js
@@ -436,6 +436,8 @@ function updateTray(unread = 0) {
tray.setContextMenu(contextmenu);
});
} else {
+ if (!tray) return;
+
tray.destroy();
tray = null;
}
diff --git a/package.json b/package.json
index ea75ff0..58fd271 100644
--- a/package.json
+++ b/package.json
@@ -54,6 +54,7 @@
"linux": {
"icon": "../resource",
"category": "Chat",
+ "executableName": "weweChat",
"target": [
"deb",
"rpm",
diff --git a/src/js/components/Avatar/index.js b/src/js/components/Avatar/index.js
index 54e7fcf..f752a6d 100644
--- a/src/js/components/Avatar/index.js
+++ b/src/js/components/Avatar/index.js
@@ -29,9 +29,10 @@ export default class Avatar extends Component {
this.handleError(e)}
onLoad={e => this.handleLoad(e)}
- src={this.props.src} />
+ onError={e => this.handleError(e)}
+ src={this.props.src}
+ />
);
}
}
diff --git a/src/js/components/MessageInput/index.js b/src/js/components/MessageInput/index.js
index 0622e4e..d40292c 100644
--- a/src/js/components/MessageInput/index.js
+++ b/src/js/components/MessageInput/index.js
@@ -24,12 +24,11 @@ export default class MessageInput extends Component {
canisend() {
var user = this.props.user;
- if (this.blocking) {
- return false;
- }
-
- if (user.length === 1
- && user.slice(-1).pop().UserName === this.props.me.UserName) {
+ if (
+ true
+ && user.length === 1
+ && user.slice(-1).pop().UserName === this.props.me.UserName
+ ) {
this.props.showMessage('Can\'t send message to yourself.');
return false;
}
@@ -37,38 +36,41 @@ export default class MessageInput extends Component {
return true;
}
- // Prevent duplicate message
- blocking = false;
-
async handleEnter(e) {
var message = this.refs.input.value.trim();
var user = this.props.user;
var batch = user.length > 1;
- if (!this.canisend()
+ if (
+ false
+ || !this.canisend()
|| !message
- || e.charCode !== 13) return;
-
- this.blocking = true;
+ || e.charCode !== 13
+ ) return;
// You can not send message to yourself
- await Promise.all(
- user.filter(e => e.UserName !== this.props.me.UserName).map(async e => {
- let res = await this.props.sendMessage(e, {
- content: message,
- type: 1,
- }, true);
-
- this.refs.input.value = '';
-
- if (!res) {
- await this.props.showMessage(batch ? `Send message to ${e.NickName} is failed!` : 'Failed to send message.');
+ Promise.all(
+ user.filter(e => e.UserName !== this.props.me.UserName).map(
+ async e => {
+ let res = await this.props.sendMessage(
+ e,
+ {
+ content: message,
+ type: 1,
+ },
+ true
+ );
+
+ if (!res) {
+ await this.props.showMessage(batch ? `Send message to ${e.NickName} is failed!` : 'Failed to send message.');
+ }
+
+ return true;
}
-
- return true;
- })
+ )
);
- this.blocking = false;
+
+ this.refs.input.value = '';
}
state = {
@@ -76,9 +78,7 @@ export default class MessageInput extends Component {
};
toggleEmoji(show = !this.state.showEmoji) {
- this.setState({
- showEmoji: show,
- });
+ this.setState({ showEmoji: show });
}
writeEmoji(emoji) {
@@ -141,38 +141,66 @@ export default class MessageInput extends Component {
}
}
+ componentWillReceiveProps(nextProps) {
+ var input = this.refs.input;
+
+ // When user has changed clear the input
+ if (
+ true
+ && input
+ && input.value
+ && this.props.user.map(e => e.UserName).join() !== nextProps.user.map(e => e.UserName).join()
+ ) {
+ input.value = '';
+ }
+ }
+
render() {
var canisend = !!this.props.user.length;
return (
-
+ src={e.HeadImgUrl}
+ onError={e => (e.target.src = 'assets/images/user-fallback.png')}
+ />