Skip to content

Commit

Permalink
fix: do not stop observing for changes until score is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterNjeim committed Jan 13, 2024
1 parent 907a6d9 commit 5f98941
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 additions & 20 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ const main = (): void => {
) {
const btnOffList = new BtnList();
if (!isOfficial) {
observer.disconnect();
isOfficial = true;
btnOffList.add({
name:
i18next.t("download", { fileType: "PDF" }) +
Expand All @@ -89,6 +87,14 @@ const main = (): void => {
btnOffList.commit(BtnListMode.InPage, 2);
}
} else {
observer.disconnect();
if (isOfficial) {
document
.querySelector(".js-page")!
.shadowRoot!.querySelectorAll("#\\31, #\\32")
.forEach((e) => e.remove());
isOfficial = false;
}
btnList.add({
name: i18next.t("download", {
fileType: "PDF",
Expand All @@ -106,25 +112,28 @@ const main = (): void => {
});
}

btnList.add({
name: i18next.t("download", { fileType: "MIDI" }),
action: BtnAction.download(
() => getFileUrl(scoreinfo.id, "midi"),
fallback,
30 * 1000 /* 30s */
),
});
if (!isOfficial) {
isOfficial = true;
btnList.add({
name: i18next.t("download", { fileType: "MIDI" }),
action: BtnAction.download(
() => getFileUrl(scoreinfo.id, "midi"),
fallback,
30 * 1000 /* 30s */
),
});

btnList.add({
name: i18next.t("download", { fileType: "MP3" }),
action: BtnAction.download(
() => getFileUrl(scoreinfo.id, "mp3"),
fallback,
30 * 1000 /* 30s */
),
});
// eslint-disable-next-line @typescript-eslint/no-floating-promises
btnList.commit(BtnListMode.InPage, 1);
btnList.add({
name: i18next.t("download", { fileType: "MP3" }),
action: BtnAction.download(
() => getFileUrl(scoreinfo.id, "mp3"),
fallback,
30 * 1000 /* 30s */
),
});
// eslint-disable-next-line @typescript-eslint/no-floating-promises
btnList.commit(BtnListMode.InPage, 1);
}
});
observer.observe(
document.querySelector("#jmuse-scroller-component") ?? document,
Expand Down

0 comments on commit 5f98941

Please sign in to comment.