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 f027788
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 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 Expand Up @@ -209,9 +214,11 @@ export const createDispatcher = () => {
metaQueue = [];
linkQueue = [];
titleTemplateQueue = [];
currentMetaIndex = 0;
currentTitleIndex = 0;
currentTitleTemplateIndex = 0;
currentTitleTemplateIndex =
currentTitleIndex =
currentMetaIndex =
0;
isBlocked = false;
}
: // istanbul ignore next
undefined,
Expand Down

0 comments on commit f027788

Please sign in to comment.