a workaround to make ocnfetti work on recipient side.
changed the implementation of on.Event.decrypted function
This commit is contained in:
parent
4527755f7e
commit
5753c96431
2 changed files with 13 additions and 13 deletions
|
@ -1029,15 +1029,16 @@ export const Commands = [
|
||||||
args: '<message>',
|
args: '<message>',
|
||||||
runFn: function(roomId, args) {
|
runFn: function(roomId, args) {
|
||||||
return success((async () => {
|
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');
|
const isChatEffectsDisabled = SettingsStore.getValue('dontShowChatEffects');
|
||||||
if ((!args) || (!args && isChatEffectsDisabled)) {
|
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,
|
category: CommandCategories.actions,
|
||||||
|
|
|
@ -511,7 +511,6 @@ 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);
|
||||||
|
@ -753,16 +752,16 @@ export default createReactClass({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!SettingsStore.getValue('dontShowChatEffects')) {
|
if (!SettingsStore.getValue('dontShowChatEffects')) {
|
||||||
this.context.on('Event.decrypted', this.onEventDecrypted);
|
this.context.on("Event.decrypted", (ev) => {
|
||||||
}
|
|
||||||
},
|
|
||||||
onEventDecrypted(ev) {
|
|
||||||
if (ev.isBeingDecrypted() || ev.isDecryptionFailure()) return;
|
if (ev.isBeingDecrypted() || ev.isDecryptionFailure()) return;
|
||||||
this.handleConfetti(ev);
|
this.handleConfetti(ev);
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleConfetti(ev) {
|
handleConfetti(ev) {
|
||||||
if (this.context.isInitialSyncComplete()) {
|
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'});
|
dis.dispatch({action: 'confetti'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue