Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import updateState, { isIdValid } from "./modUpdateState";
const PRESET_OPTIONS = [
{ value: "has-update", label: "Update available" },
{ value: "missing-meta", label: "Missing Meta ID" },
{ value: "multi-version", label: "Multiple versions installed" },
];

interface IConnectedProps {
Expand Down Expand Up @@ -79,7 +80,7 @@ class VersionFilter implements ITableFilter {
public raw = true;
public dataId = "$";

public matches(filter: any, value: any): boolean {
public matches(filter: any, value: any, state: any): boolean {
if (value === undefined) {
return undefined;
}
Expand All @@ -96,6 +97,20 @@ class VersionFilter implements ITableFilter {
return true;
}

if (filter.includes("multi-version")) {
const modId = getSafe(value, ["attributes", "modId"], undefined);
if (modId !== undefined) {
const gameId = activeGameId(state);
const mods = gameId !== undefined ? getSafe(state, ["persistent", "mods", gameId], {}) : {};
const count = Object.values(mods).filter(
(mod: IMod) => getSafe(mod, ["attributes", "modId"], undefined) === modId,
).length;
if (count > 1) {
return true;
}
}
}

const versionFilters = filter
.filter((f: string) => f.startsWith("v:"))
.map((f: string) => f.slice(2));
Expand Down