diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php
index 277334ac9..b15b403e8 100644
--- a/classes/pref/prefs.php
+++ b/classes/pref/prefs.php
@@ -1357,20 +1357,14 @@ class Pref_Prefs extends Handler_Protected {
}
}
- private function _get_available_plugins(array $installed = []) {
+ private function _get_available_plugins() {
if ($_SESSION["access_level"] >= 10 && Config::get(Config::ENABLE_PLUGIN_INSTALLER)) {
- $obj = json_decode(UrlHelper::fetch(['url' => 'https://tt-rss.org/plugins.json']), true);
-
- // TODO: filter installed, we'll need class names in the plugins.json
-
- return $obj;
+ return json_decode(UrlHelper::fetch(['url' => 'https://tt-rss.org/plugins.json']), true);
}
}
function getAvailablePlugins() {
- $installed = $_REQUEST['installed'];
-
if ($_SESSION["access_level"] >= 10) {
- print json_encode($this->_get_available_plugins($installed));
+ print json_encode($this->_get_available_plugins());
}
}
diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js
index 6012d2d02..5ee84f258 100644
--- a/js/PrefHelpers.js
+++ b/js/PrefHelpers.js
@@ -374,6 +374,7 @@ const Helpers = {
need_refresh: false,
entries: false,
search_query: "",
+ installed_plugins: [],
onHide: function() {
if (this.need_refresh) {
Helpers.Prefs.refresh();
@@ -449,6 +450,9 @@ const Helpers = {
.filter((stoken) => (stoken.length > 0 ? stoken : null));
dialog.entries.forEach((plugin) => {
+ const is_installed = (dialog.installed_plugins
+ .filter((p) => plugin.topics.map((t) => t.replace(/-/, "_")).includes(p))).length > 0;
+
if (search_tokens.length == 0 ||
Object.values(plugin).filter((pval) =>
search_tokens.filter((stoken) =>
@@ -458,8 +462,9 @@ const Helpers = {
++results_rendered;
container.innerHTML += `
-
- ${App.FormFields.button_tag(__('Install'), "", {class: 'alt-primary pull-right',
+
+ ${App.FormFields.button_tag(is_installed ? __("Already installed") : __('Install'), "", {class: 'alt-primary pull-right',
+ disabled: is_installed,
onclick: `App.dialogOf(this).performInstall("${App.escapeHtml(plugin.name)}")`})}
${plugin.name}
@@ -487,9 +492,7 @@ const Helpers = {
const container = dialog.domNode.querySelector(".contents");
container.innerHTML = `
${__("Looking for plugins...")}`;
- const installed = [...document.querySelectorAll('*[data-plugin-name]')].map((p) => p.getAttribute('data-plugin-name'));
-
- xhr.json("backend.php", {op: "pref-prefs", method: "getAvailablePlugins", 'installed[]': installed}, (reply) => {
+ xhr.json("backend.php", {op: "pref-prefs", method: "getAvailablePlugins"}, (reply) => {
dialog.entries = reply;
dialog.render_contents();
});
@@ -502,7 +505,7 @@ const Helpers = {
-
+