mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-04-13 07:17:12 +03:00
Fix viewer compatibility with older browsers and (hopefully) Safari
Closes #260
This commit is contained in:
parent
2d55ca4013
commit
f54465e5fe
@ -1,6 +1,7 @@
|
||||
import discord from "./discord.mjs";
|
||||
import gui from "./gui.mjs";
|
||||
import state from "./state.mjs";
|
||||
import "./polyfills.mjs";
|
||||
|
||||
window.DISCORD = discord;
|
||||
|
||||
|
35
app/Resources/Viewer/scripts/polyfills.mjs
Normal file
35
app/Resources/Viewer/scripts/polyfills.mjs
Normal file
@ -0,0 +1,35 @@
|
||||
// https://gist.github.com/MattiasBuelens/496fc1d37adb50a733edd43853f2f60e/088f061ab79b296f29225467ae9ba86ff990195d
|
||||
|
||||
ReadableStream.prototype.values ??= function({ preventCancel = false } = {}) {
|
||||
const reader = this.getReader();
|
||||
return {
|
||||
async next() {
|
||||
try {
|
||||
const result = await reader.read();
|
||||
if (result.done) {
|
||||
reader.releaseLock();
|
||||
}
|
||||
return result;
|
||||
} catch (e) {
|
||||
reader.releaseLock();
|
||||
throw e;
|
||||
}
|
||||
},
|
||||
async return(value) {
|
||||
if (!preventCancel) {
|
||||
const cancelPromise = reader.cancel(value);
|
||||
reader.releaseLock();
|
||||
await cancelPromise;
|
||||
}
|
||||
else {
|
||||
reader.releaseLock();
|
||||
}
|
||||
return { done: true, value };
|
||||
},
|
||||
[Symbol.asyncIterator]() {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
ReadableStream.prototype[Symbol.asyncIterator] ??= ReadableStream.prototype.values;
|
Loading…
x
Reference in New Issue
Block a user