beatboxjs / ror-player

A pattern-based drumming machine based on TypeScript, beatbox.js, Vue.js and Bootstrap.
https://player.rhythms-of-resistance.org/
GNU Affero General Public License v3.0
11 stars 10 forks source link

Clicking on "show notes" opens the notes twice #42

Closed yahelmanor closed 3 months ago

yahelmanor commented 7 months ago

Issue

When clicking on "show notes" in any tune and break it opens the windows twice, once immediately and once after about a second (the time vary from machine to machine), i suspect this is a bug and not a feature and this also lead to long loading time.

How to replicate

Just open https://player.rhythms-of-resistance.org/#/listen/Sambasso/ for example, click on the "show notes" of any of the tune or break, you should see a windows pop up immediately and after about a second it disappear and another one appear instead.

Some investigation

It seems the problem stems from the following line don't working exactly like it was expected.

setTimeout(() => {
    hashChangeIgnored = false;
}, 0);

In the function setState

function setState(name: string, params: Params = { }) {
    if(setStateIgnored)
        return;

    hashChangeIgnored = true;
    setTimeout(() => {
        hashChangeIgnored = false;
    }, 0);

    if(name == "") {
        location.hash = "#";
        currentState = null;
    } else {
        location.hash = "#" + ROUTES_COMPILE[name](params);
        currentState = { name, params };
    }
}

I think this was supped to suppress the event in

window.addEventListener("hashchange", () => {
if(!hashChangeIgnored)
    resolve();
}, false);

But what happen as far as i understand is that the setTimeout happens first instead of the EvenListner.

Possible solution

Maybe in setState we can add some variable of the hash that should be skipped, and just skip it in the window.addEventListener but i really not sure.

cdauth commented 5 months ago

I wasn't able to reproduce the problem, but I have now finally installed a completely new version of the RoR Player that was in the making for a while but never completely finished. Could you verify whether the problem still occurs in the new version?

cdauth commented 3 months ago

Closing the issue for now, please reopen if the issue still occurs.