diff --git a/Library/0BDFDB.plugin.js b/Library/0BDFDB.plugin.js index b350c26dcb..130e9cc861 100644 --- a/Library/0BDFDB.plugin.js +++ b/Library/0BDFDB.plugin.js @@ -615,14 +615,13 @@ module.exports = (_ => { }, "Failed to clean up plugin!", plugin.name)(); }; BDFDB.PluginUtils.checkUpdate = function (pluginName, url) { - let updateStore = Object.assign({}, window.PluginUpdates && window.PluginUpdates.plugins, PluginStores.updateData.plugins); - if (pluginName && url && updateStore[url]) return new Promise(callback => { + if (pluginName && url && PluginStores.updateData.plugins[url]) return new Promise(callback => { LibraryRequires.request(url, (error, response, body) => { - if (error || !updateStore[url]) return callback(null); + if (error || !PluginStores.updateData.plugins[url]) return callback(null); let newName = (body.match(/"name"\s*:\s*"([^"]+)"/) || [])[1] || pluginName; let newVersion = (body.match(/['"][0-9]+\.[0-9]+\.[0-9]+['"]/i) || "").toString().replace(/['"]/g, ""); if (!newVersion) return callback(null); - if (pluginName == newName && BDFDB.NumberUtils.getVersionDifference(newVersion, updateStore[url].version) > 0.2) { + if (pluginName == newName && BDFDB.NumberUtils.getVersionDifference(newVersion, PluginStores.updateData.plugins[url].version) > 0.2) { BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_force_updated", pluginName), { type: "warning", disableInteractions: true @@ -630,7 +629,7 @@ module.exports = (_ => { BDFDB.PluginUtils.downloadUpdate(pluginName, url); return callback(2); } - else if (BDFDB.NumberUtils.compareVersions(newVersion, updateStore[url].version)) { + else if (BDFDB.NumberUtils.compareVersions(newVersion, PluginStores.updateData.plugins[url].version)) { if (PluginStores.updateData.plugins[url]) PluginStores.updateData.plugins[url].outdated = true; BDFDB.PluginUtils.showUpdateNotice(pluginName, url); return callback(1); @@ -643,16 +642,15 @@ module.exports = (_ => { }); return new Promise(callback => {callback(null);}); }; - BDFDB.PluginUtils.checkAllUpdates = function (all) { + BDFDB.PluginUtils.checkAllUpdates = function () { return new Promise(callback => { let finished = 0, amount = 0; - let updateStore = Object.assign({}, all && window.PluginUpdates && window.PluginUpdates.plugins, PluginStores.updateData.plugins); - for (let url in updateStore) { - let plugin = updateStore[url]; + for (let url in PluginStores.updateData.plugins) { + let plugin = PluginStores.updateData.plugins[url]; if (plugin) BDFDB.PluginUtils.checkUpdate(plugin.name, plugin.raw).then(state => { finished++; if (state == 1) amount++; - if (finished >= Object.keys(updateStore).length) callback(amount); + if (finished >= Object.keys(PluginStores.updateData.plugins).length) callback(amount); }); } }); @@ -772,11 +770,10 @@ module.exports = (_ => { }); } else { - let updateStore = Object.assign({}, window.PluginUpdates && window.PluginUpdates.plugins, PluginStores.updateData.plugins); let wasEnabled = BDFDB.BDUtils.isPluginEnabled(pluginName); let newName = (body.match(/"name"\s*:\s*"([^"]+)"/) || [])[1] || pluginName; let newVersion = body.match(/['"][0-9]+\.[0-9]+\.[0-9]+['"]/i).toString().replace(/['"]/g, ""); - let oldVersion = updateStore[url].version; + let oldVersion = PluginStores.updateData.plugins[url].version; let fileName = pluginName == "BDFDB" ? "0BDFDB" : pluginName; let newFileName = newName == "BDFDB" ? "0BDFDB" : newName; LibraryRequires.fs.writeFile(LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), newFileName + ".plugin.js"), body, _ => { @@ -7987,7 +7984,7 @@ module.exports = (_ => { currentLoadingString = currentLoadingString.endsWith(".....") ? loadingString : currentLoadingString + "."; toast.update(currentLoadingString); }, 500); - BDFDB.PluginUtils.checkAllUpdates(true).then(outdated => { + BDFDB.PluginUtils.checkAllUpdates().then(outdated => { toast.close(); if (outdated > 0) BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("update_check_complete_outdated", outdated), { type: "danger"