a workaround to make ocnfetti work on recipient side.
changed the implementation of on.Event.decrypted functionpull/21833/head
parent
4527755f7e
commit
5753c96431
|
@ -1029,15 +1029,16 @@ export const Commands = [
|
|||
args: '<message>',
|
||||
runFn: function(roomId, args) {
|
||||
return success((async () => {
|
||||
const cli = MatrixClientPeg.get();
|
||||
const userId = cli.getUserId();
|
||||
const userName = userId.slice(1).split(":").slice(0, 1);
|
||||
const isChatEffectsDisabled = SettingsStore.getValue('dontShowChatEffects');
|
||||
if ((!args) || (!args && isChatEffectsDisabled)) {
|
||||
args = _t("* %(userName)s sends confetti", {userName});
|
||||
args = _t("sends confetti");
|
||||
MatrixClientPeg.get().sendEmoteMessage(roomId, args);
|
||||
} else {
|
||||
MatrixClientPeg.get().sendHtmlMessage(roomId, args);
|
||||
}
|
||||
if (!isChatEffectsDisabled) {
|
||||
dis.dispatch({action: 'confetti'});
|
||||
}
|
||||
cli.sendHtmlMessage(roomId, args,
|
||||
dis.dispatch({action: 'confetti'}));
|
||||
})());
|
||||
},
|
||||
category: CommandCategories.actions,
|
||||
|
|
|
@ -511,7 +511,6 @@ 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);
|
||||
|
@ -753,16 +752,16 @@ export default createReactClass({
|
|||
}
|
||||
}
|
||||
if (!SettingsStore.getValue('dontShowChatEffects')) {
|
||||
this.context.on('Event.decrypted', this.onEventDecrypted);
|
||||
this.context.on("Event.decrypted", (ev) => {
|
||||
if (ev.isBeingDecrypted() || ev.isDecryptionFailure()) return;
|
||||
this.handleConfetti(ev);
|
||||
});
|
||||
}
|
||||
},
|
||||
onEventDecrypted(ev) {
|
||||
if (ev.isBeingDecrypted() || ev.isDecryptionFailure()) return;
|
||||
this.handleConfetti(ev);
|
||||
},
|
||||
handleConfetti(ev) {
|
||||
if (this.context.isInitialSyncComplete()) {
|
||||
if (isConfettiEmoji(ev.getContent())) {
|
||||
const messageBody = _t('sends confetti');
|
||||
if (isConfettiEmoji(ev.getContent()) || ev.getContent().body === messageBody) {
|
||||
dis.dispatch({action: 'confetti'});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue