Skip to content

Commit 438d59b

Browse files
author
Rob Rogers
committed
Fix freeze caused by progress bar firing onDone during asset transitions
1 parent 265a890 commit 438d59b

2 files changed

Lines changed: 20 additions & 18 deletions

File tree

immichFrame.Web/src/lib/components/elements/progress-bar.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
2929
const onChange = async (progressDuration: number) => {
3030
progress = setDuration(progressDuration);
31-
await play();
31+
if (status === ProgressBarStatus.Playing) {
32+
await play();
33+
}
3234
};
3335
3436
let progress = setDuration(duration);

immichFrame.Web/src/lib/components/home-page/home-page.svelte

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -149,24 +149,24 @@
149149
}
150150
}
151151
152-
let isHandlingAssetTransition = false;
152+
let transitionLock: Promise<void> = Promise.resolve();
153+
153154
const handleDone = async (previous: boolean = false, instant: boolean = false) => {
154-
if (isHandlingAssetTransition) {
155-
return;
156-
}
157-
isHandlingAssetTransition = true;
158-
try {
159-
userPaused = false;
160-
progressBar.restart(false);
161-
$instantTransition = instant;
162-
if (previous) await getPreviousAssets();
163-
else await getNextAssets();
164-
await tick();
165-
await assetComponent?.play?.();
166-
progressBar.play();
167-
} finally {
168-
isHandlingAssetTransition = false;
169-
}
155+
transitionLock = transitionLock
156+
.then(async () => {
157+
userPaused = false;
158+
progressBar.restart(false);
159+
$instantTransition = instant;
160+
if (previous) await getPreviousAssets();
161+
else await getNextAssets();
162+
await tick();
163+
await assetComponent?.play?.();
164+
progressBar.play();
165+
})
166+
.catch((err) => {
167+
console.error('handleDone transition failed:', err);
168+
});
169+
await transitionLock;
170170
};
171171
172172
async function getNextAssets() {

0 commit comments

Comments
 (0)