Improve styleloader, fix clearing emotes. (#506)

* improve styleloader for local development.

* fix clearing emotes
This commit is contained in:
Strencher 2020-12-09 22:44:11 +01:00 committed by GitHub
parent db84e73f50
commit 3ab655594b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -62,7 +62,7 @@ export default new class EmoteModule extends Builtin {
}
async enabled() {
Settings.registerCollection("emotes", "Emotes", EmoteConfig, {title: Strings.Emotes.clearEmotes, onClick: this.resetEmotes});
Settings.registerCollection("emotes", "Emotes", EmoteConfig, {title: Strings.Emotes.clearEmotes, onClick: this.resetEmotes.bind(this)});
await this.getBlocklist();
await this.loadEmoteData();

View File

@ -124,11 +124,16 @@ export default new class Core {
async loadDependencies() {
for (const data of this.dependencies) {
if (Config.local && Config.localPath && data.localPath) {
if (fs.existsSync(path.resolve(Config.localPath, data.localPath))) {
const css = fs.readFileSync(path.resolve(Config.localPath, data.localPath)).toString();
if (Config.local && Config.localPath && data.localPath && data.type == "style") {
const stylepath = path.resolve(Config.localPath, data.localPath);
if (fs.existsSync(stylepath)) {
Logger.log("Startup", `Loading local stylesheet from (${stylepath})`);
const css = fs.readFileSync(stylepath).toString();
DOMManager.injectStyle(data.name, css);
continue;
}
else {
Logger.warn("Startup", "Local stylesheet was not found, loading remote...");
}
}
const url = Utilities.formatString(data.url, {hash: Config.hash});