checking for unreadMessages before sending confetti

throwing the confetti on the sender's side
change sendHtmlMessage to sendTextMessage in slashCommands
pull/21833/head
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"); args = _t("sends confetti");
MatrixClientPeg.get().sendEmoteMessage(roomId, args); MatrixClientPeg.get().sendEmoteMessage(roomId, args);
} else { } else {
MatrixClientPeg.get().sendHtmlMessage(roomId, args); MatrixClientPeg.get().sendTextMessage(roomId, args);
} }
if (!isChatEffectsDisabled) { if (!isChatEffectsDisabled) {
dis.dispatch({action: 'confetti'}); dis.dispatch({action: 'confetti'});

View File

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

View File

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