mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-14 01:41:05 +03:00
Refactoring
This commit is contained in:
parent
1c6d28b861
commit
d4ec1dd775
4 changed files with 18 additions and 7 deletions
|
@ -815,7 +815,7 @@ export default class RoomView extends React.Component<IProps, IState> {
|
|||
private handleConfetti = (ev) => {
|
||||
if (this.state.room.getUnreadNotificationCount() === 0) return;
|
||||
if (this.state.matrixClientIsReady) {
|
||||
effects.map(effect => {
|
||||
effects.forEach(effect => {
|
||||
if (containsEmoji(ev.getContent(), effect.emojis) || ev.getContent().msgtype === effect.msgType) {
|
||||
dis.dispatch({action: `effects.${effect.command}`});
|
||||
}
|
||||
|
|
|
@ -94,7 +94,6 @@ export default class Confetti implements ICanvasEffect {
|
|||
|
||||
public stop = async () => {
|
||||
this.isRunning = false;
|
||||
// this.particles = [];
|
||||
}
|
||||
|
||||
private resetParticle = (particle: ConfettiParticle, width: number, height: number): ConfettiParticle => {
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
import {_t, _td} from "../../../../languageHandler";
|
||||
|
||||
export default [
|
||||
type Effect = {
|
||||
emojis: Array<string>;
|
||||
msgType: string;
|
||||
command: string;
|
||||
description: () => string;
|
||||
fallbackMessage: () => string;
|
||||
}
|
||||
|
||||
const effects: Array<Effect> = [
|
||||
{
|
||||
emojis: ['🎊', '🎉'],
|
||||
msgType: 'nic.custom.confetti',
|
||||
|
@ -8,4 +16,8 @@ export default [
|
|||
description: () => _td("Sends the given message with confetti"),
|
||||
fallbackMessage: () => _t("sends confetti") + " 🎉",
|
||||
},
|
||||
]
|
||||
];
|
||||
|
||||
export default effects;
|
||||
|
||||
|
||||
|
|
|
@ -318,10 +318,10 @@ export default class SendMessageComposer extends React.Component {
|
|||
});
|
||||
}
|
||||
dis.dispatch({action: "message_sent"});
|
||||
effects.map( (effect) => {
|
||||
effects.forEach((effect) => {
|
||||
if (containsEmoji(content, effect.emojis)) {
|
||||
dis.dispatch({action: `effects.${effect.command}`});
|
||||
}
|
||||
dis.dispatch({action: `effects.${effect.command}`});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue