Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG-nightly.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 3.1.15.2000

- Fixed an issue that caused duplicate messages to be modified without the bypass option enabled

### 3.1.15.1000

- Added required Firefox built-in consent metadata to the manifest
Expand Down
14 changes: 14 additions & 0 deletions src/site/twitch.tv/modules/chat-input/ChatSpam.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ const emit = defineEmits<{

const chatModule = getModuleRef<"TWITCH", "chat">("chat");
const rootEl = toRef(props.instance.domNodes, "root");

const aprilFoolsDisabled = useConfig<boolean>("chat.font-april-fools", false);
const aprilFoolsDismissed = useConfig<boolean>("chat.font-april-fools-dismissed", false);
const shouldBypassDuplicateCheck = useConfig("chat_input.spam.bypass_duplicate");

const suggestContainer = useFloatScreen(rootEl, {
enabled: () => props.suggest,
Expand Down Expand Up @@ -81,6 +83,7 @@ function handleAprilFoolsAnswer(answer: string): void {
}
aprilFoolsDismissed.value = true;
}

let prevMessage = "";
function handleDuplicateMessage(content: string): string {
if (typeof content === "string" && content === prevMessage) {
Expand All @@ -106,12 +109,23 @@ watch(
chatModule,
(mod) => {
if (!mod || !mod.instance) return;
if (!shouldBypassDuplicateCheck.value) return;

mod.instance.messageSendMiddleware.set("handle-dupe", handleDuplicateMessage);
},
{ immediate: true },
);

watch(shouldBypassDuplicateCheck, (shouldBypass) => {
if (!chatModule.value?.instance) return;

if (shouldBypass) {
chatModule.value.instance.messageSendMiddleware.set("handle-dupe", handleDuplicateMessage);
} else {
chatModule.value.instance.messageSendMiddleware.delete("handle-dupe");
}
});

onUnmounted(() => {
if (!chatModule.value?.instance) return;

Expand Down