Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: lib/user-presence improvements #15046

Merged
merged 2 commits into from Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/assets/javascripts/discourse/app/lib/user-presence.js
Expand Up @@ -119,6 +119,10 @@ export function setTestPresence(value) {
testPresence = value;
}

export function clearPresenceCallbacks() {
callbacks.splice(0, callbacks.length);
Copy link
Contributor

Choose a reason for hiding this comment

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

I've also done callbacks.length = 0 which works too.

}

if (!isTesting()) {
// Some of these events occur very frequently. Therefore seenUser() is as fast as possible.
document.addEventListener("touchmove", seenUser, { passive: true });
Expand Down
Expand Up @@ -54,7 +54,10 @@ import { resetLastEditNotificationClick } from "discourse/models/post-stream";
import { clearAuthMethods } from "discourse/models/login-method";
import { clearTopicFooterDropdowns } from "discourse/lib/register-topic-footer-dropdown";
import { clearTopicFooterButtons } from "discourse/lib/register-topic-footer-button";
import { setTestPresence } from "discourse/lib/user-presence";
import {
clearPresenceCallbacks,
setTestPresence,
} from "discourse/lib/user-presence";

const LEGACY_ENV = !setupApplicationTest;

Expand Down Expand Up @@ -299,6 +302,9 @@ export function acceptance(name, optionsOrCallback) {
resetLastEditNotificationClick();
clearAuthMethods();
setTestPresence(true);
if (!LEGACY_ENV) {
clearPresenceCallbacks();
}

app._runInitializer("instanceInitializers", (_, initializer) => {
initializer.teardown?.();
Expand Down