Skip to content

Commit 88d479e

Browse files
committed
[#88] Ensure player is initialized even on slow connections
Nebula appears to first display only a subset of the buttons, until information from the video has loaded, so a slow connection can make it so we don't ever initialize
1 parent 8a0b140 commit 88d479e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/scripts/page/player.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,11 @@ export const getAPlayer = (maxiter: number | null = 10) => new Promise<Player>((
131131
}
132132
}, 100);
133133
});
134-
const waitForButtonsAndSetIds = (maxiter: number | null = 10) => new Promise((resolve, reject) => {
134+
let buttonInterval: number = 0;
135+
const waitForButtonsAndSetIds = (maxiter: number | null = 1000) => new Promise((resolve, reject) => {
135136
let iter = 0;
136-
const i = window.setInterval(() => {
137+
window.clearInterval(buttonInterval);
138+
const i = buttonInterval = window.setInterval(() => {
137139
try {
138140
setDefaultIds();
139141
window.clearInterval(i);
@@ -143,6 +145,8 @@ const waitForButtonsAndSetIds = (maxiter: number | null = 10) => new Promise((re
143145
window.clearInterval(i);
144146
reject(err);
145147
return;
148+
} else {
149+
console.dev.warn('Skipping:', err);
146150
}
147151
}
148152
}, 100);

0 commit comments

Comments
 (0)