mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 10:58:20 -07:00
Fix suggestions
This commit is contained in:
parent
4cd83e6f73
commit
57fb43fb04
@ -11,13 +11,17 @@ import pluginManager from 'pluginManager';
|
||||
var manifestUrls = JSON.parse(appSettings.get(this.#settingsKey) || '[]');
|
||||
|
||||
var instance = this;
|
||||
return Promise.all(manifestUrls.map((u) => {
|
||||
return this.loadPackage(instance, u);
|
||||
})).then(() => {
|
||||
return Promise.all(manifestUrls.map((url) => {
|
||||
return this.loadPackage(url);
|
||||
}))
|
||||
.then(() => {
|
||||
console.debug('finished loading packages');
|
||||
return Promise.resolve();
|
||||
})
|
||||
.catch(() => {
|
||||
return Promise.resolve();
|
||||
}).finally(() => {
|
||||
console.groupEnd('loading packages');
|
||||
return Promise.resolve();
|
||||
}, () => {
|
||||
return Promise.resolve();
|
||||
});
|
||||
}
|
||||
|
||||
@ -26,7 +30,7 @@ import pluginManager from 'pluginManager';
|
||||
}
|
||||
|
||||
install(url) {
|
||||
return this.loadPackage(this, url, true).then((pkg) => {
|
||||
return this.loadPackage(url, true).then((pkg) => {
|
||||
var manifestUrls = JSON.parse(appSettings.get(this.#settingsKey) || '[]');
|
||||
|
||||
if (!manifestUrls.includes(url)) {
|
||||
@ -69,12 +73,12 @@ import pluginManager from 'pluginManager';
|
||||
return packageUrl;
|
||||
}
|
||||
|
||||
addPackage(packageManager, pkg) {
|
||||
packageManager.packagesList = packageManager.packagesList.filter((p) => {
|
||||
addPackage(pkg) {
|
||||
this.packagesList = this.packagesList.filter((p) => {
|
||||
return p.name !== pkg.name;
|
||||
});
|
||||
|
||||
packageManager.packagesList.push(pkg);
|
||||
this.packagesList.push(pkg);
|
||||
}
|
||||
|
||||
removeUrl(url) {
|
||||
@ -87,7 +91,7 @@ import pluginManager from 'pluginManager';
|
||||
appSettings.set(this.#settingsKey, JSON.stringify(manifestUrls));
|
||||
}
|
||||
|
||||
loadPackage(packageManager, url, throwError) {
|
||||
loadPackage(url, throwError = false) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var xhr = new XMLHttpRequest();
|
||||
var originalUrl = url;
|
||||
@ -105,19 +109,19 @@ import pluginManager from 'pluginManager';
|
||||
}
|
||||
};
|
||||
|
||||
xhr.onload = (e) => {
|
||||
xhr.onload = () => {
|
||||
if (this.status < 400) {
|
||||
var pkg = JSON.parse(this.response);
|
||||
pkg.url = originalUrl;
|
||||
|
||||
this.addPackage(packageManager, pkg);
|
||||
this.addPackage(pkg);
|
||||
|
||||
var plugins = pkg.plugins || [];
|
||||
if (pkg.plugin) {
|
||||
plugins.push(pkg.plugin);
|
||||
}
|
||||
var promises = plugins.map((pluginUrl) => {
|
||||
return pluginManager.loadPlugin(packageManager.mapPath(pkg, pluginUrl));
|
||||
return pluginManager.loadPlugin(this.mapPath(pkg, pluginUrl));
|
||||
});
|
||||
Promise.all(promises).then(resolve, resolve);
|
||||
} else {
|
||||
|
@ -2,6 +2,7 @@ define(["events", "playbackManager", "pluginManager", "inputManager", "connectio
|
||||
"use strict";
|
||||
|
||||
playbackManager = playbackManager.default || playbackManager;
|
||||
pluginManager = pluginManager.default || pluginManager;
|
||||
|
||||
function getMinIdleTime() {
|
||||
// Returns the minimum amount of idle time required before the screen saver can be displayed
|
||||
|
@ -470,6 +470,7 @@ function initClient() {
|
||||
|
||||
require(['apphost', 'css!assets/css/librarybrowser'], function (appHost) {
|
||||
loadPlugins(appHost, browser).then(function () {
|
||||
console.groupEnd('loading packages');
|
||||
onAppReady(browser);
|
||||
});
|
||||
});
|
||||
@ -494,12 +495,18 @@ function initClient() {
|
||||
list = list.concat(window.NativeShell.getPlugins());
|
||||
}
|
||||
|
||||
Promise.all(list.map(loadPlugin)).then(function () {
|
||||
console.groupEnd('loading installed plugins');
|
||||
require(['packageManager'], function (packageManager) {
|
||||
packageManager.default.init().then(resolve, reject);
|
||||
});
|
||||
}, reject);
|
||||
Promise.all(list.map(loadPlugin))
|
||||
.then(function () {
|
||||
console.debug('finished loading plugins');
|
||||
})
|
||||
.catch(() => reject)
|
||||
.finally(() => {
|
||||
console.groupEnd('loading installed plugins');
|
||||
require(['packageManager'], function (packageManager) {
|
||||
packageManager.default.init().then(resolve, reject);
|
||||
});
|
||||
})
|
||||
;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user