fix(Moyai): not playing sound when reacting
This commit is contained in:
parent
ba5c4fe706
commit
400398829e
2 changed files with 9 additions and 3 deletions
|
|
@ -13,6 +13,6 @@
|
||||||
],
|
],
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"vendetta": {
|
"vendetta": {
|
||||||
"icon": "ic_speaker"
|
"icon": "VoiceNormalIcon"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,15 +64,20 @@ function onMessage(event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const recentReactions = new Set<string>();
|
||||||
|
|
||||||
function onReaction(event) {
|
function onReaction(event) {
|
||||||
try {
|
try {
|
||||||
if (
|
if (
|
||||||
(storage.allowReactions ?? true) &&
|
(storage.allowReactions ?? true) &&
|
||||||
event.channelId == SelectedChannelStore.getChannelId() &&
|
event.channelId == SelectedChannelStore.getChannelId()
|
||||||
!event.optimistic
|
|
||||||
) {
|
) {
|
||||||
const name = event.emoji?.name;
|
const name = event.emoji?.name;
|
||||||
if (name === "🗿" || (name && /moy?ai/i.test(name))) {
|
if (name === "🗿" || (name && /moy?ai/i.test(name))) {
|
||||||
|
const key = `${event.messageId}:${name}`;
|
||||||
|
if (recentReactions.has(key)) return;
|
||||||
|
recentReactions.add(key);
|
||||||
|
setTimeout(() => recentReactions.delete(key), 500);
|
||||||
playSound();
|
playSound();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -97,6 +102,7 @@ export default {
|
||||||
onUnload: () => {
|
onUnload: () => {
|
||||||
FluxDispatcher.unsubscribe("MESSAGE_CREATE", onMessage);
|
FluxDispatcher.unsubscribe("MESSAGE_CREATE", onMessage);
|
||||||
FluxDispatcher.unsubscribe("MESSAGE_REACTION_ADD", onReaction);
|
FluxDispatcher.unsubscribe("MESSAGE_REACTION_ADD", onReaction);
|
||||||
|
recentReactions.clear();
|
||||||
},
|
},
|
||||||
settings: MoyaiSettings,
|
settings: MoyaiSettings,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue