fix(customisation-sync): hide identical items with "Hide not applicable items"

The checkbox only toggled a CSS class for rows labelled "All the same or
non-existent", while `hideNotApplicable`, which filters the offered
devices by whether their copy can be applied, was hard-coded to false.
Items present on another device therefore stayed visible even when every
copy was the same.

Drive `hideNotApplicable` from the checkbox, so the comparison only runs
while it is on, and pass it to the reactive update so toggling it
re-evaluates the rows. The term selection moves into PluginTerms.ts so it
can be unit-tested.

Fixes #1193
This commit is contained in:
Immick committed 2026-09-15 22:03:51 +03:00
1 parent ba297d1233
commit f1746fa4b8
4 files changed
+102 -18

No files matched your search

+14 -17
View File
@@ -12,6 +12,7 @@
// import { askString } from "../../common/utils";
import { Menu } from "@/deps.ts";
import { $msg as translateMessage } from "@/common/translation";
import { selectSourceTerms } from "./PluginTerms.ts";
export let list: IPluginDataExDisplay[] = [];
export let thisTerm = "";
@@ -182,24 +183,20 @@
}
}
async function updateTerms(list: IPluginDataExDisplay[], selectNewest: boolean, isMaintenanceMode: boolean) {
async function updateTerms(
list: IPluginDataExDisplay[],
selectNewest: boolean,
isMaintenanceMode: boolean,
hideNotApplicable: boolean
) {
const local = list.find((e) => e.term == thisTerm);
// selected = "";
if (isMaintenanceMode) {
terms = [...new Set(list.map((e) => e.term))];
} else if (hideNotApplicable) {
const termsTmp = [];
const wk = [...new Set(list.map((e) => e.term))];
for (const termName of wk) {
const remote = list.find((e) => e.term == termName);
if ((await comparePlugin(local, remote)).canApply) {
termsTmp.push(termName);
}
}
terms = [...termsTmp];
} else {
terms = [...new Set(list.map((e) => e.term))].filter((e) => e != thisTerm);
}
terms = await selectSourceTerms(
list,
thisTerm,
{ isMaintenanceMode, hideNotApplicable },
async (local, remote) => (await comparePlugin(local, remote)).canApply
);
let newest: IPluginDataExDisplay | undefined = local;
if (selectNewest) {
for (const term of terms) {
@@ -230,7 +227,7 @@
}
// currentSelectNewest = selectNewest;
}
updateTerms(list, doSelectNewest, isMaintenanceMode);
updateTerms(list, doSelectNewest, isMaintenanceMode, hideNotApplicable);
currentSelectNewest = selectNewest;
}
$: {