Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
Fix missing download button
Browse files Browse the repository at this point in the history
  • Loading branch information
bytedream committed Oct 14, 2023
1 parent 792daac commit 85aa8ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/entries/contentScript/player/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getElementMounted } from '~/entries/contentScript/player/utils';
import { MountComponent } from '~/entries/contentScript/render';
import DownloadButton from '~/entries/contentScript/player/elements/DownloadButton.svelte';
import { settings } from '~/entries/contentScript/player/settings';
import { sleep } from '~/lib/utils';

export let id = '';

Expand All @@ -26,6 +27,9 @@ async function onMessage(message: MessageEvent) {
}

const player = document.getElementById('vilos') as HTMLDivElement;
// sleep a bit to give the player time to render the new controls container when accessing the
// player via client site routing
await sleep(100);
const controlsContainer = await getElementMounted(
(p) => p.querySelector('#vilosControlsContainer'),
player,
Expand Down
4 changes: 4 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ export async function waitForCallback<V, T, C extends (value: V) => T | undefine

return promise;
}

export async function sleep(ms: number): Promise<void> {
return new Promise((r) => setTimeout(r, ms));
}

0 comments on commit 85aa8ec

Please sign in to comment.