luci-app-opkg: honor installed flag to skip half-installed packages
[project/luci.git] / applications / luci-app-opkg / htdocs / luci-static / resources / view / opkg.js
index 4a36b0a3c32d89e0d99c5e4b4b379d6287c23ceb..9f10b2fafc060ff2e9a03979b13e8743c661eccb 100644 (file)
@@ -134,7 +134,12 @@ function display(pattern)
                var btn, ver;
 
                if (currentDisplayMode === 'updates') {
-                       var avail = packages.available.pkgs[name];
+                       var avail = packages.available.pkgs[name],
+                           inst  = packages.installed.pkgs[name];
+
+                       if (!inst || !inst.installed)
+                               continue;
+
                        if (!avail || compareVersion(avail.version, pkg.version) <= 0)
                                continue;
 
@@ -149,6 +154,9 @@ function display(pattern)
                        }, _('Upgradeā€¦'));
                }
                else if (currentDisplayMode === 'installed') {
+                       if (!pkg.installed)
+                               continue;
+
                        ver = truncateVersion(pkg.version || '-');
                        btn = E('div', {
                                'class': 'btn cbi-button-negative',
@@ -157,15 +165,17 @@ function display(pattern)
                        }, _('Remove'));
                }
                else {
+                       var inst = packages.installed.pkgs[name];
+
                        ver = truncateVersion(pkg.version || '-');
 
-                       if (!packages.installed.pkgs[name])
+                       if (!inst || !inst.installed)
                                btn = E('div', {
                                        'class': 'btn cbi-button-action',
                                        'data-package': name,
                                        'click': handleInstall
                                }, _('Installā€¦'));
-                       else if (packages.installed.pkgs[name].version != pkg.version)
+                       else if (inst.installed && inst.version != pkg.version)
                                btn = E('div', {
                                        'class': 'btn cbi-button-positive',
                                        'data-package': name,