fix: keep autoplay fallback from saving mute

(cherry picked from commit f373bb9ce7)
This commit is contained in:
thePR0M3TH3AN committed 2026-07-26 12:33:57 -04:00
1 parent 0513c7fcd8
commit d8e5113efd
7 files changed
+96 -10

No files matched your search

+27
View File
@@ -151,3 +151,30 @@ test("login does not eagerly load DM history; it is deferred", async () => {
"the lightweight unread DM indicator should still run so the badge stays accurate",
);
});
test("login reloads the open video comment thread", async () => {
globalThis.window.location = { search: "", href: "http://localhost/" };
const coord = makeCoordinator({
loadDirectMessages: async () => ({ ok: true }),
refreshUnreadDmIndicator: async () => {},
});
const activeVideo = { id: "b".repeat(64), title: "Open video" };
const loadedVideos = [];
coord.videoModal = { getCurrentVideo: () => activeVideo };
coord.commentController = {
load: (video) => loadedVideos.push(video),
refreshAuthState: () => {
throw new Error("an open thread should be reloaded, not only refreshed");
},
};
await coord.handleAuthLogin({
pubkey: ACTIVE_PUBKEY,
identityChanged: true,
postLogin: { profile: { name: "tester" } },
postLoginPromise: Promise.resolve({ profile: { name: "tester" } }),
});
assert.deepEqual(loadedVideos, [activeVideo]);
});
+12 -6
View File
@@ -44,21 +44,27 @@ describe("PlaybackService", () => {
const service = new PlaybackService();
const video = document.createElement("video");
// Default: muted (unless localStorage says unmuted)
// Default: sound on unless the viewer explicitly chose mute.
localStorage.removeItem("unmutedAutoplay");
service.prepareVideoElement(video);
assert.equal(video.muted, true);
assert.equal(video.muted, false);
assert.equal(video.dataset.autoplayBound, "true");
// Simulate volume change
video.muted = false;
// Simulate an explicit mute choice.
video.muted = true;
video.dispatchEvent(new window.Event("volumechange"));
assert.equal(localStorage.getItem("unmutedAutoplay"), "true");
assert.equal(localStorage.getItem("unmutedAutoplay"), "false");
// Test respecting stored value
const video2 = document.createElement("video");
service.prepareVideoElement(video2);
assert.equal(video2.muted, false);
assert.equal(video2.muted, true);
// A browser-policy fallback is temporary and must not become a saved mute.
localStorage.setItem("unmutedAutoplay", "true");
video2.muted = false;
service.muteForAutoplayFallback(video2);
assert.equal(localStorage.getItem("unmutedAutoplay"), "true");
});
test("registerUrlPlaybackWatchdogs triggers onFallback on error", () => {