mirror of https://github.com/VERT-sh/VERT.git
fix: video conversion e.get error (#215)
not entirely sure because i can't reproduce it, but this seems like the only logical reason this could be happening
This commit is contained in:
parent
5088040112
commit
838a6c7e0b
|
|
@ -290,7 +290,15 @@ export class VertdConverter extends Converter {
|
|||
}
|
||||
|
||||
private blocked(hash: string): boolean {
|
||||
const blockedHashes = Settings.instance.settings.vertdBlockedHashes;
|
||||
let blockedHashes = Settings.instance.settings.vertdBlockedHashes;
|
||||
|
||||
// ensure it's a map
|
||||
// this might fix the "e.get" isn't a function error, but i can't reproduce it
|
||||
if (!(blockedHashes instanceof Map) || blockedHashes === null) {
|
||||
blockedHashes = new Map(Object.entries(blockedHashes || {}));
|
||||
Settings.instance.settings.vertdBlockedHashes = blockedHashes;
|
||||
Settings.instance.save();
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
const dates = blockedHashes.get(hash) || [];
|
||||
|
|
@ -311,7 +319,15 @@ export class VertdConverter extends Converter {
|
|||
}
|
||||
|
||||
private failure(hash: string): void {
|
||||
const blockedHashes = Settings.instance.settings.vertdBlockedHashes;
|
||||
let blockedHashes = Settings.instance.settings.vertdBlockedHashes;
|
||||
|
||||
// same as above (blocked())
|
||||
if (!(blockedHashes instanceof Map) || blockedHashes === null) {
|
||||
blockedHashes = new Map(Object.entries(blockedHashes || {}));
|
||||
Settings.instance.settings.vertdBlockedHashes = blockedHashes;
|
||||
Settings.instance.save();
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
const dates = blockedHashes.get(hash) || [];
|
||||
dates.push(now);
|
||||
|
|
|
|||
|
|
@ -60,21 +60,26 @@ export class Settings {
|
|||
}
|
||||
|
||||
public load() {
|
||||
VertdInstance.instance.load();
|
||||
const ls = localStorage.getItem("settings");
|
||||
if (!ls) return;
|
||||
const settings: ISettings = JSON.parse(ls);
|
||||
const vertdBlockedHashes = new Map<string, Date[]>(
|
||||
Object.entries(
|
||||
settings.vertdBlockedHashes || this.settings.vertdBlockedHashes,
|
||||
),
|
||||
);
|
||||
try {
|
||||
VertdInstance.instance.load();
|
||||
const ls = localStorage.getItem("settings");
|
||||
if (!ls) return;
|
||||
const settings: ISettings = JSON.parse(ls);
|
||||
const vertdBlockedHashes = new Map<string, Date[]>(
|
||||
Object.entries(
|
||||
settings.vertdBlockedHashes ||
|
||||
this.settings.vertdBlockedHashes,
|
||||
),
|
||||
);
|
||||
|
||||
settings.vertdBlockedHashes = vertdBlockedHashes;
|
||||
settings.vertdBlockedHashes = vertdBlockedHashes;
|
||||
|
||||
this.settings = {
|
||||
...this.settings,
|
||||
...settings,
|
||||
};
|
||||
this.settings = {
|
||||
...this.settings,
|
||||
...settings,
|
||||
};
|
||||
} catch {
|
||||
// ignore errors, use default settings
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue