Skip to content

Commit

Permalink
add new fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Sep 23, 2023
1 parent faedb30 commit 3286cb5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/dispatcher/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const createDispatcher = () => {
let currentTitleIndex = 0;
let currentTitleTemplateIndex = 0;
let currentMetaIndex = 0;
let isBlocked = false;

// A process can be debounced by one frame timing,
// since microticks could potentially interfere with how
Expand All @@ -86,6 +87,7 @@ export const createDispatcher = () => {

return () => {
clearTimeout(timeout);
isBlocked = true;
timeout = setTimeout(() => {
timeout = null;
const visited = new Set();
Expand All @@ -102,6 +104,7 @@ export const createDispatcher = () => {
}
});

isBlocked = false;
currentTitleIndex = currentTitleTemplateIndex = currentMetaIndex = 0;
}, 1000 / 60 /* One second divided by the max browser fps. */);
};
Expand Down Expand Up @@ -136,10 +139,12 @@ export const createDispatcher = () => {
const index = queue.indexOf(payload as string);
queue.splice(index, 1);

let currentIndex =
type === TITLE ? currentTitleIndex : currentTitleTemplateIndex;
if (currentIndex === index) {
currentIndex--;
if (isBlocked) {
if (type === TITLE) {
currentTitleIndex--;
} else {
currentTitleTemplateIndex--;
}
}

if (index === 0)
Expand All @@ -160,7 +165,7 @@ export const createDispatcher = () => {
(m.charset || m[m.keyword] === oldMeta[m.keyword])
);

if (currentMetaIndex === index) {
if (isBlocked) {
currentMetaIndex--;
}

Expand Down

0 comments on commit 3286cb5

Please sign in to comment.