start fix for settingsmanager
This commit is contained in:
parent
ec46a237b7
commit
311f87bfc4
File diff suppressed because one or more lines are too long
|
@ -197,13 +197,13 @@ export default new class EmoteModule extends Builtin {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getBlacklist() {
|
async getBlacklist() {
|
||||||
return new Promise(resolve => {
|
const category = "blacklist";
|
||||||
request.get({url: Utilities.repoUrl(`data/emotes/blacklist.json`), json: true}, (err, resp, data) => {
|
const exists = DataStore.emotesExist(category);
|
||||||
if (err || resp.statusCode != 200) return resolve();
|
const valid = await this.isCacheValid(category);
|
||||||
resolve(blacklist.push(...data));
|
const useCache = (valid) || (!valid && exists && !this.shouldDownload);
|
||||||
});
|
const list = useCache ? DataStore.getEmoteData(category) : await this.downloadEmotes(category);
|
||||||
});
|
blacklist.push(...list);
|
||||||
}
|
}
|
||||||
|
|
||||||
isCacheValid(category) {
|
isCacheValid(category) {
|
||||||
|
@ -217,9 +217,10 @@ export default new class EmoteModule extends Builtin {
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadEmoteData() {
|
async loadEmoteData() {
|
||||||
|
Toasts.show(Strings.Emotes.loading, {type: "info"});
|
||||||
this.emotesLoaded = false;
|
this.emotesLoaded = false;
|
||||||
|
|
||||||
for (const category in Emotes) {
|
for (const category of this.categories) {
|
||||||
const exists = DataStore.emotesExist(category);
|
const exists = DataStore.emotesExist(category);
|
||||||
const valid = await this.isCacheValid(category);
|
const valid = await this.isCacheValid(category);
|
||||||
const useCache = (valid) || (!valid && exists && !this.shouldDownload);
|
const useCache = (valid) || (!valid && exists && !this.shouldDownload);
|
||||||
|
@ -231,16 +232,16 @@ export default new class EmoteModule extends Builtin {
|
||||||
if (hasData) data = cachedData;
|
if (hasData) data = cachedData;
|
||||||
}
|
}
|
||||||
if (!data) data = await this.downloadEmotes(category);
|
if (!data) data = await this.downloadEmotes(category);
|
||||||
// for (const emote in data) data[emote] = EmoteURLs[category].format({id: data[emote]});
|
|
||||||
Object.assign(Emotes[category], data);
|
Object.assign(Emotes[category], data);
|
||||||
|
await new Promise(r => setTimeout(r, 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emotesLoaded = true;
|
this.emotesLoaded = true;
|
||||||
Events.dispatch("emotes-loaded");
|
Events.dispatch("emotes-loaded");
|
||||||
|
Toasts.show(Strings.Emotes.loaded, {type: "success"});
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadEmotes(category) {
|
downloadEmotes(category) {
|
||||||
// Toasts.show(Strings.Emotes.downloading, {type: "info"});
|
|
||||||
const url = this.getRemoteFile(category);
|
const url = this.getRemoteFile(category);
|
||||||
this.log(`Downloading ${category} from ${url}`);
|
this.log(`Downloading ${category} from ${url}`);
|
||||||
const options = {url: url, timeout: 8000, json: true};
|
const options = {url: url, timeout: 8000, json: true};
|
||||||
|
@ -262,7 +263,6 @@ export default new class EmoteModule extends Builtin {
|
||||||
DataStore.setCacheHash("emotes", category, response.headers.etag);
|
DataStore.setCacheHash("emotes", category, response.headers.etag);
|
||||||
resolve(parsedData);
|
resolve(parsedData);
|
||||||
this.log(`Downloaded ${category}`);
|
this.log(`Downloaded ${category}`);
|
||||||
// Toasts.show(Strings.Emotes.downloaded, {type: "success"});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,8 +175,8 @@ export default {
|
||||||
donate: "Donate"
|
donate: "Donate"
|
||||||
},
|
},
|
||||||
Emotes: {
|
Emotes: {
|
||||||
downloading: "Downloading emotes in the background do not reload.",
|
loading: "Loading emotes in the background do not reload.",
|
||||||
downloaded: "All emotes successfully downloaded.",
|
loaded: "All emotes successfully loaded.",
|
||||||
clearEmotes: "Clear Emote Data",
|
clearEmotes: "Clear Emote Data",
|
||||||
favoriteAction: "Favorite!"
|
favoriteAction: "Favorite!"
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,8 +11,6 @@ export default class BuiltinModule {
|
||||||
get id() {return "None";}
|
get id() {return "None";}
|
||||||
|
|
||||||
async initialize() {
|
async initialize() {
|
||||||
console.log("Initialize for " + this.name);
|
|
||||||
console.log(Settings.get(this.collection, this.category, this.id), this.collection, this.category, this.id);
|
|
||||||
if (Settings.get(this.collection, this.category, this.id)) await this.enable();
|
if (Settings.get(this.collection, this.category, this.id)) await this.enable();
|
||||||
Events.on("setting-updated", (collection, category, id, enabled) => {
|
Events.on("setting-updated", (collection, category, id, enabled) => {
|
||||||
if (collection != this.collection || category !== this.category || id !== this.id) return;
|
if (collection != this.collection || category !== this.category || id !== this.id) return;
|
||||||
|
|
Loading…
Reference in New Issue