checking for unreadMessages before sending confetti

throwing the confetti on the sender's side
change sendHtmlMessage to sendTextMessage in slashCommands
This commit is contained in:
nurjinn jafar 2020-08-26 18:56:23 +02:00
parent 5753c96431
commit 95051a42b1
3 changed files with 18 additions and 8 deletions

View file

@ -1034,7 +1034,7 @@ export const Commands = [
args = _t("sends confetti");
MatrixClientPeg.get().sendEmoteMessage(roomId, args);
} else {
MatrixClientPeg.get().sendHtmlMessage(roomId, args);
MatrixClientPeg.get().sendTextMessage(roomId, args);
}
if (!isChatEffectsDisabled) {
dis.dispatch({action: 'confetti'});

View file

@ -189,6 +189,7 @@ export default createReactClass({
this.context.on("deviceVerificationChanged", this.onDeviceVerificationChanged);
this.context.on("userTrustStatusChanged", this.onUserVerificationChanged);
this.context.on("crossSigning.keysChanged", this.onCrossSigningKeysChanged);
this.context.on("Event.decrypted", this.onEventDecrypted);
// Start listening for RoomViewStore updates
this._roomStoreToken = RoomViewStore.addListener(this._onRoomViewStoreUpdate);
this._rightPanelStoreToken = RightPanelStore.getSharedInstance().addListener(this._onRightPanelStoreUpdate);
@ -511,6 +512,7 @@ export default createReactClass({
this.context.removeListener("deviceVerificationChanged", this.onDeviceVerificationChanged);
this.context.removeListener("userTrustStatusChanged", this.onUserVerificationChanged);
this.context.removeListener("crossSigning.keysChanged", this.onCrossSigningKeysChanged);
this.context.removeListener("Event.decrypted", this.onEventDecrypted);
}
window.removeEventListener('beforeunload', this.onPageUnload);
@ -751,15 +753,16 @@ export default createReactClass({
});
}
}
if (!SettingsStore.getValue('dontShowChatEffects')) {
this.context.on("Event.decrypted", (ev) => {
if (ev.isBeingDecrypted() || ev.isDecryptionFailure()) return;
this.handleConfetti(ev);
});
}
},
onEventDecrypted(ev) {
if (!SettingsStore.getValue('dontShowChatEffects')) {
if (ev.isBeingDecrypted() || ev.isDecryptionFailure() ||
this.state.room.getUnreadNotificationCount() === 0) return;
this.handleConfetti(ev);
}
},
handleConfetti(ev) {
if (this.context.isInitialSyncComplete()) {
if (this.state.matrixClientIsReady) {
const messageBody = _t('sends confetti');
if (isConfettiEmoji(ev.getContent()) || ev.getContent().body === messageBody) {
dis.dispatch({action: 'confetti'});

View file

@ -44,6 +44,8 @@ import MatrixClientContext from "../../../contexts/MatrixClientContext";
import {MatrixClientPeg} from "../../../MatrixClientPeg";
import RateLimitedFunc from '../../../ratelimitedfunc';
import {Action} from "../../../dispatcher/actions";
import {isConfettiEmoji} from "../elements/Confetti";
import SettingsStore from "../../../settings/SettingsStore";
function addReplyToMessageContent(content, repliedToEvent, permalinkCreator) {
const replyContent = ReplyThread.makeReplyMixIn(repliedToEvent);
@ -313,6 +315,11 @@ export default class SendMessageComposer extends React.Component {
});
}
dis.dispatch({action: "message_sent"});
if (!SettingsStore.getValue('dontShowChatEffects')) {
if (isConfettiEmoji(content)) {
dis.dispatch({action: 'confetti'});
}
}
}
this.sendHistoryManager.save(this.model);