Skip to content

Commit

Permalink
improved loading midi over midi button
Browse files Browse the repository at this point in the history
  • Loading branch information
ingui-n committed Mar 5, 2024
1 parent 96b9783 commit 3a0538d
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/content/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,17 +442,30 @@ const loadMidiDataWithClick = async () => {

button.click();

await new Promise(resolve => {
const isMidiPartLoaded = await new Promise(resolve => {
if (window.location.pathname.endsWith('/piano-tutorial')) {
resolve();
return;
resolve(true);
}

navigation.addEventListener("navigate", () => resolve());
const interval = setInterval(() => {
if (window.location.pathname.endsWith('/piano-tutorial')) {
clearInterval(interval);
resolve(true);
}
}, 50);

setTimeout(() => {
clearInterval(interval);
resolve(false);
}, 2000);
});

button.click();
return true;
if (isMidiPartLoaded) {
button.click();
return true;
}

return false;
};

const loadImagesDiv = async () => {
Expand Down

0 comments on commit 3a0538d

Please sign in to comment.