Show error modal when reloading content
This commit is contained in:
parent
4cfa4ee466
commit
ff3ef34784
|
@ -85,8 +85,9 @@ export default class {
|
|||
|
||||
/**
|
||||
* Refresh locally stored content
|
||||
* @param {bool} suppressErrors Suppress any errors that occur during loading of content
|
||||
*/
|
||||
static async refreshContent() {
|
||||
static async refreshContent(suppressErrors = false) {
|
||||
if (!this.localContent.length) return this.loadAllContent();
|
||||
|
||||
try {
|
||||
|
@ -101,19 +102,45 @@ export default class {
|
|||
// Load if not
|
||||
await this.preloadContent(dir);
|
||||
} catch (err) {
|
||||
//We don't want every plugin/theme to fail loading when one does
|
||||
// We don't want every plugin/theme to fail loading when one does
|
||||
this.errors.push(new ErrorEvent({
|
||||
module: this.moduleName,
|
||||
message: `Failed to load ${dir}`,
|
||||
err
|
||||
}));
|
||||
|
||||
Logger.err(this.moduleName, err);
|
||||
}
|
||||
}
|
||||
|
||||
for (let content of this.localContent) {
|
||||
if (directories.includes(content.dirName)) continue;
|
||||
//Plugin/theme was deleted manually, stop it and remove any reference
|
||||
this.unloadContent(content);
|
||||
|
||||
try {
|
||||
// Plugin/theme was deleted manually, stop it and remove any reference
|
||||
await this.unloadContent(content);
|
||||
} catch (err) {
|
||||
this.errors.push(new ErrorEvent({
|
||||
module: this.moduleName,
|
||||
message: `Failed to unload ${dir}`,
|
||||
err
|
||||
}));
|
||||
|
||||
Logger.err(this.moduleName, err);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.errors.length && !suppressErrors) {
|
||||
Modals.error({
|
||||
header: `${this.moduleName} - ${this.errors.length} ${this.contentType}${this.errors.length !== 1 ? 's' : ''} failed to load`,
|
||||
module: this.moduleName,
|
||||
type: 'err',
|
||||
content: this.errors
|
||||
});
|
||||
this._errors = [];
|
||||
}
|
||||
|
||||
return this.localContent;
|
||||
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
|
|
|
@ -85,22 +85,31 @@ export default class {
|
|||
return this.add({ event }, ErrorModal);
|
||||
}
|
||||
|
||||
static showContentManagerErrors() {
|
||||
static showContentManagerErrors(clear = true) {
|
||||
// Get any errors from PluginManager and ThemeManager
|
||||
const errors = ([]).concat(PluginManager.errors).concat(ThemeManager.errors);
|
||||
if (errors.length) return this.error({
|
||||
header:
|
||||
(PluginManager.errors.length && ThemeManager.errors.length ? '' :
|
||||
(PluginManager.errors.length ? PluginManager.moduleName : ThemeManager.moduleName) + ' - ') +
|
||||
(PluginManager.errors.length ? `${PluginManager.errors.length} ${PluginManager.contentType}${PluginManager.errors.length !== 1 ? 's' : ''}` : '') +
|
||||
(PluginManager.errors.length && ThemeManager.errors.length ? ' and ' : '') +
|
||||
(ThemeManager.errors.length ? `${ThemeManager.errors.length} ${ThemeManager.contentType}${ThemeManager.errors.length !== 1 ? 's' : ''}` : '') +
|
||||
' failed to load',
|
||||
module: (PluginManager.errors.length && ThemeManager.errors.length ? 'Content Manager' :
|
||||
(PluginManager.errors.length ? PluginManager.moduleName : ThemeManager.moduleName)),
|
||||
type: 'err',
|
||||
content: errors
|
||||
});
|
||||
if (errors.length) {
|
||||
const modal = this.error({
|
||||
header:
|
||||
(PluginManager.errors.length && ThemeManager.errors.length ? '' :
|
||||
(PluginManager.errors.length ? PluginManager.moduleName : ThemeManager.moduleName) + ' - ') +
|
||||
(PluginManager.errors.length ? `${PluginManager.errors.length} ${PluginManager.contentType}${PluginManager.errors.length !== 1 ? 's' : ''}` : '') +
|
||||
(PluginManager.errors.length && ThemeManager.errors.length ? ' and ' : '') +
|
||||
(ThemeManager.errors.length ? `${ThemeManager.errors.length} ${ThemeManager.contentType}${ThemeManager.errors.length !== 1 ? 's' : ''}` : '') +
|
||||
' failed to load',
|
||||
module: (PluginManager.errors.length && ThemeManager.errors.length ? 'Content Manager' :
|
||||
(PluginManager.errors.length ? PluginManager.moduleName : ThemeManager.moduleName)),
|
||||
type: 'err',
|
||||
content: errors
|
||||
});
|
||||
|
||||
if (clear) {
|
||||
PluginManager._errors = [];
|
||||
ThemeManager._errors = [];
|
||||
}
|
||||
|
||||
return modal;
|
||||
}
|
||||
}
|
||||
|
||||
static settings(headertext, settings, schemes, settingsUpdated, settingUpdated, saveSettings) {
|
||||
|
|
Loading…
Reference in New Issue