diff --git a/src/webpage/favorites.ts b/src/webpage/favorites.ts index f65f6cf..3ffb611 100644 --- a/src/webpage/favorites.ts +++ b/src/webpage/favorites.ts @@ -38,44 +38,7 @@ type favandfreqimp = Omit< | "heard_sound_frecency" | "played_sound_frecency" >; -Set.prototype.intersection ||= function (set: Set) { - const newSet = new Set(); - for (const elm of this) { - if (set.has(elm)) { - newSet.add(elm); - } - } - return newSet; -}; -Set.prototype.difference ||= function (set: Set) { - const newSet = new Set(); - for (const elm of this) { - if (!set.has(elm)) { - newSet.add(elm); - } - } - return newSet; -}; -Set.prototype.symmetricDifference ||= function (set: Set) { - const newSet = new Set(); - for (const elm of this) { - if (!set.has(elm)) { - newSet.add(elm); - } - } - for (const elm of set) { - if (!this.has(elm)) { - newSet.add(elm); - } - } - return newSet; -}; -Set.prototype.isDisjointFrom ||= function (set: Set) { - return this.symmetricDifference(set).size === 0; -}; -Set.prototype.union ||= function (set: Set) { - return new Set([...this, ...set]); -}; + export class Favorites { owner: Localuser; // ----- stuff that needs to store ---- diff --git a/src/webpage/index.ts b/src/webpage/index.ts index 425dd38..e436822 100644 --- a/src/webpage/index.ts +++ b/src/webpage/index.ts @@ -6,6 +6,7 @@ import {MarkDown} from "./markdown.js"; import {Message} from "./message.js"; import {File} from "./file.js"; import {I18n} from "./i18n.js"; +import "./utils/pollyfills.js"; if (window.location.pathname === "/app") { window.location.pathname = "/channels/@me"; } diff --git a/src/webpage/utils/pollyfills.ts b/src/webpage/utils/pollyfills.ts new file mode 100644 index 0000000..961018b --- /dev/null +++ b/src/webpage/utils/pollyfills.ts @@ -0,0 +1,38 @@ +Set.prototype.intersection ||= function (set: Set) { + const newSet = new Set(); + for (const elm of this) { + if (set.has(elm)) { + newSet.add(elm); + } + } + return newSet; +}; +Set.prototype.difference ||= function (set: Set) { + const newSet = new Set(); + for (const elm of this) { + if (!set.has(elm)) { + newSet.add(elm); + } + } + return newSet; +}; +Set.prototype.symmetricDifference ||= function (set: Set) { + const newSet = new Set(); + for (const elm of this) { + if (!set.has(elm)) { + newSet.add(elm); + } + } + for (const elm of set) { + if (!this.has(elm)) { + newSet.add(elm); + } + } + return newSet; +}; +Set.prototype.isDisjointFrom ||= function (set: Set) { + return this.symmetricDifference(set).size === 0; +}; +Set.prototype.union ||= function (set: Set) { + return new Set([...this, ...set]); +};