Fix wrong selection in PublishModal
This commit is contained in:
parent
bf716627a1
commit
6b32cafeeb
@ -170,6 +170,8 @@ export function PublishModal({
|
||||
CurseForgeFile[]
|
||||
>([]);
|
||||
|
||||
const [canSelect, setCanSelect] = useState(false);
|
||||
|
||||
const loadExisting = useCallback(async () => {
|
||||
setLoadingExisting(true);
|
||||
try {
|
||||
@ -304,6 +306,8 @@ export function PublishModal({
|
||||
}))
|
||||
.sort((a, b) => compareParsed(a.parsed, b.parsed))
|
||||
.map((e) => e.row);
|
||||
|
||||
if (!loadingExisting) setCanSelect(true);
|
||||
|
||||
return [...pending, ...existing];
|
||||
}, [publishVersions, modrinthExistingVersions, matchedMrNames, config.modrinth.version]);
|
||||
@ -381,7 +385,7 @@ export function PublishModal({
|
||||
}
|
||||
}, [open]);
|
||||
useEffect(() => {
|
||||
if (!loadingExisting && publishVersions.length > 0 && !initRef.current) {
|
||||
if (canSelect && publishVersions.length > 0 && !initRef.current) {
|
||||
initRef.current = true;
|
||||
setSelectedModrinth(
|
||||
publishVersions.filter((v) => !v.existsModrinth).map((v) => v.key),
|
||||
@ -390,7 +394,7 @@ export function PublishModal({
|
||||
publishVersions.filter((v) => !v.existsCurseforge).map((v) => v.key),
|
||||
);
|
||||
}
|
||||
}, [loadingExisting, publishVersions]);
|
||||
}, [canSelect, publishVersions]);
|
||||
|
||||
// --------------- Steps handling ---------------
|
||||
|
||||
|
||||
@ -87,7 +87,9 @@ export async function compareVersions(
|
||||
|
||||
// ── Modrinth:按 version 模板生成 version_number 后匹配 ──
|
||||
const modrinth: Record<string, VersionMatch> = {};
|
||||
const modrinthTmpl = new Template(config.modrinth.version);
|
||||
const modrinthTmpl = new Template(config.modrinth.version, {
|
||||
filename_format: config.filename_format,
|
||||
});
|
||||
|
||||
for (const mc_version of mc_versions) {
|
||||
const generatedVersion = modrinthTmpl.format({ version, mc_version });
|
||||
@ -101,7 +103,9 @@ export async function compareVersions(
|
||||
|
||||
// ── CurseForge:按 filename_format 模板生成文件名后匹配 ──
|
||||
const curseforge: Record<string, FileMatch> = {};
|
||||
const curseforgeTmpl = new Template(config.filename_format);
|
||||
const curseforgeTmpl = new Template(config.curseforge.version_name, {
|
||||
filename_format: config.filename_format,
|
||||
});
|
||||
|
||||
for (const mc_version of mc_versions) {
|
||||
const generatedFilename = curseforgeTmpl.format({ version, mc_version });
|
||||
|
||||
Loading…
Reference in New Issue
Block a user