fix: address latest coderabbit review

This commit is contained in:
2026-03-25 21:10:43 -07:00
parent 23815945bf
commit 39b2ccad8e
5 changed files with 96 additions and 8 deletions

View File

@@ -68,6 +68,8 @@ test('texthooker precheck no-ops for texthooker command', () => {
test('texthooker precheck transitions for youtube playback startup prereqs', () => {
let mode = true;
let prereqs = 0;
let warmups = 0;
let logs = 0;
const handlePrecheck = createHandleTexthookerOnlyModeTransitionHandler({
isTexthookerOnlyMode: () => mode,
setTexthookerOnlyMode: (enabled) => {
@@ -77,12 +79,18 @@ test('texthooker precheck transitions for youtube playback startup prereqs', ()
ensureOverlayStartupPrereqs: () => {
prereqs += 1;
},
startBackgroundWarmups: () => {},
logInfo: () => {},
startBackgroundWarmups: () => {
warmups += 1;
},
logInfo: () => {
logs += 1;
},
});
handlePrecheck({ youtubePlay: 'https://youtube.com/watch?v=abc', texthooker: false } as never);
assert.equal(mode, false);
assert.equal(prereqs, 1);
assert.equal(warmups, 1);
assert.equal(logs, 1);
});

View File

@@ -144,13 +144,13 @@ export function createPrepareYoutubePlaybackInMpvHandler(deps: YoutubePlaybackLa
// Continue polling until media tracks are actually available.
}
}
const pathChanged = currentPath !== previousPath;
const pathDiffersFromInitial = currentPath !== previousPath;
const matchesChangedTarget =
currentPath === targetUrl ||
(isYoutubeMediaPath(currentPath) &&
isYoutubeMediaPath(targetUrl) &&
pathMatchesYoutubeTarget(currentPath, targetUrl));
if (pathChanged && matchesChangedTarget) {
if (pathDiffersFromInitial && matchesChangedTarget) {
if (deps.requestProperty) {
try {
const trackList = await deps.requestProperty('track-list');