Skip to content

Fixed slow-mode timer on twitch#611

Closed
simensBat wants to merge 4 commits into
SevenTV:masterfrom
simensBat:fix-slow-mode-timer-on-twitch
Closed

Fixed slow-mode timer on twitch#611
simensBat wants to merge 4 commits into
SevenTV:masterfrom
simensBat:fix-slow-mode-timer-on-twitch

Conversation

@simensBat
Copy link
Copy Markdown

@simensBat simensBat commented May 17, 2023

Fixed #475.

There was a problem with the watcher in the component. src/site/twitch.tv/modules/chat/ChatList.vue

// Keep track of props
// The message handler is hooked to render messages and prevent
// the native twitch renderer from rendering them
watch(
	messageHandler,
	(handler, old) => {
		if (handler !== old && old) {
			unsetPropertyHook(old, "handleMessage");
		} else if (handler) {
			defineFunctionHook(handler, "handleMessage", function (old, msg: Twitch.AnyMessage) {
				const ok = onMessage(msg);
				// this same problems
				if (ok) return old?.call(this, msg); // message was rendered by the extension
				// message was not rendered by the extension
				unhandled.set(msg.id, msg);
				return old?.call(this, msg);
			});
		}
	},
	{ immediate: true },
);

In a standard situation, we render messages in a chat using extensions, apparently at this moment the context is lost and the functionality with the work of the slow mod begins to break. The data before the display component simply does not come.

I tried explicitly returning return old?.call(this, msg); instead of return "" And this solved the problem of displaying the slow mode text.

I looked at the work of the chat and did not find any failures in the messages.

As it was before:

screencast-newtab-2023.05.17-19_50_33.webm

How is it now:

screencast-newtab-2023.05.17-19_53_12.webm

@simensBat simensBat marked this pull request as ready for review May 17, 2023 16:55
@simensBat
Copy link
Copy Markdown
Author

@AnatoleAM Сan you take a look here too please

defineFunctionHook(handler, "handleMessage", function (old, msg: Twitch.AnyMessage) {
const ok = onMessage(msg);
if (ok) return ""; // message was rendered by the extension
if (ok) return old?.call(this, msg); // message was rendered by the extension
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a valid situation as it would lead to messages being rendered by native chat in the background, severely decreasing performance.

@AnatoleAM
Copy link
Copy Markdown
Contributor

If a more suitale solution is found open a new pull request.

@AnatoleAM AnatoleAM closed this Jun 26, 2023
@lucas-teks
Copy link
Copy Markdown

Hi, thanks for the fix but this issue is still appearing in latest 7TV version both nightly and stable releases, both on latest version of Chrome and Firefox with default configuration.
Slow mode bar doesn't show up, and entering a message before the delay will "fake" send it, the server returning in the chatbox I'm not allowed to chat yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Slow-Mode Timer on Twitch

3 participants