mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 08:23:12 +09:00
Add ModInfo.id getter
Provide a simple unique identifier for mods consisting of the name followed by an underscore and then the version.
This commit is contained in:
1 parent
ddba58ca99
commit
867bb0c646
4 files changed
+13
-5
No files matched your search
@@ -867,7 +867,7 @@ modPackCommands.add(new lib.Command({
|
|||||||
}],
|
}],
|
||||||
handler: async function(args: { modPack: string }, control: Control) {
|
handler: async function(args: { modPack: string }, control: Control) {
|
||||||
let mods = new Map(
|
let mods = new Map(
|
||||||
(await control.send(new lib.ModListRequest())).map(m => [`${m.name}_${m.version}`, m])
|
(await control.send(new lib.ModListRequest())).map(m => [m.id, m])
|
||||||
);
|
);
|
||||||
let modPack = await control.send(
|
let modPack = await control.send(
|
||||||
new lib.ModPackGetRequest(await lib.resolveModPack(control, args.modPack))
|
new lib.ModPackGetRequest(await lib.resolveModPack(control, args.modPack))
|
||||||
|
|||||||
@@ -16,6 +16,14 @@ import { integerModVersion, integerFactorioVersion, modVersionRegExp } from "./v
|
|||||||
* details of the invidiual fields sourced from info.json.
|
* details of the invidiual fields sourced from info.json.
|
||||||
*/
|
*/
|
||||||
export default class ModInfo {
|
export default class ModInfo {
|
||||||
|
/**
|
||||||
|
* String containing {mod.name}_{mod.version}, uniquely identifies this
|
||||||
|
* mod.
|
||||||
|
*/
|
||||||
|
get id() {
|
||||||
|
return `${this.name}_${this.version}`;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal name of this mod.
|
* Internal name of this mod.
|
||||||
* This is the name of the zip file as well as the name that appears in
|
* This is the name of the zip file as well as the name that appears in
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ function ModsTable(props: ModsTableProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const modListMap = new Map(modList.map(mod => [`${mod.name}_${mod.version}`, mod]));
|
const modListMap = new Map(modList.map(mod => [mod.id, mod]));
|
||||||
const mods = [...props.modPack.mods.values(), ...deletedMods.values()].map(
|
const mods = [...props.modPack.mods.values(), ...deletedMods.values()].map(
|
||||||
(mod: lib.ModRecord|lib.ModInfo): lib.ModInfo|lib.ModRecord => {
|
(mod: lib.ModRecord|lib.ModInfo): lib.ModInfo|lib.ModRecord => {
|
||||||
const candidate = modListMap.get(`${mod.name}_${mod.version}`);
|
const candidate = modListMap.get(`${mod.name}_${mod.version}`);
|
||||||
@@ -481,8 +481,8 @@ function SettingsTable(props: SettingsTableProps) {
|
|||||||
const [modList] = useModList();
|
const [modList] = useModList();
|
||||||
const modsInPack = new Set([...props.modPack.mods.values()].map(mod => `${mod.name}_${mod.version}`));
|
const modsInPack = new Set([...props.modPack.mods.values()].map(mod => `${mod.name}_${mod.version}`));
|
||||||
const modTitles = new Map(modList
|
const modTitles = new Map(modList
|
||||||
.filter(mod => modsInPack.has(`${mod.name}_${mod.version}`))
|
.filter(mod => modsInPack.has(mod.id))
|
||||||
.map(mod => [`${mod.name}`, mod.title])
|
.map(mod => [mod.name, mod.title])
|
||||||
);
|
);
|
||||||
|
|
||||||
const types = ["bool-setting", "int-setting", "double-setting", "string-setting"];
|
const types = ["bool-setting", "int-setting", "double-setting", "string-setting"];
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ export default function ModsPage() {
|
|||||||
}}
|
}}
|
||||||
dataSource={modList}
|
dataSource={modList}
|
||||||
pagination={false}
|
pagination={false}
|
||||||
rowKey={mod => `${mod.name}_${mod.version}`}
|
rowKey={mod => mod.id}
|
||||||
/>
|
/>
|
||||||
<PluginExtra component="ModsPage" />
|
<PluginExtra component="ModsPage" />
|
||||||
</PageLayout>;
|
</PageLayout>;
|
||||||
|
|||||||
Reference in new issue
Block a user