Replace canSelect state with derived dataReady check
This commit is contained in:
parent
6b32cafeeb
commit
7c10e4b168
@ -170,8 +170,6 @@ export function PublishModal({
|
||||
CurseForgeFile[]
|
||||
>([]);
|
||||
|
||||
const [canSelect, setCanSelect] = useState(false);
|
||||
|
||||
const loadExisting = useCallback(async () => {
|
||||
setLoadingExisting(true);
|
||||
try {
|
||||
@ -306,8 +304,6 @@ 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]);
|
||||
@ -384,8 +380,12 @@ export function PublishModal({
|
||||
initRef.current = false;
|
||||
}
|
||||
}, [open]);
|
||||
const dataReady =
|
||||
!loadingExisting &&
|
||||
modrinthMcVersions.length > 0 &&
|
||||
curseforgeMcVersions.length > 0;
|
||||
useEffect(() => {
|
||||
if (canSelect && publishVersions.length > 0 && !initRef.current) {
|
||||
if (dataReady && publishVersions.length > 0 && !initRef.current) {
|
||||
initRef.current = true;
|
||||
setSelectedModrinth(
|
||||
publishVersions.filter((v) => !v.existsModrinth).map((v) => v.key),
|
||||
@ -393,8 +393,9 @@ export function PublishModal({
|
||||
setSelectedCurseforge(
|
||||
publishVersions.filter((v) => !v.existsCurseforge).map((v) => v.key),
|
||||
);
|
||||
console.log(selectedModrinth, selectedCurseforge);
|
||||
}
|
||||
}, [canSelect, publishVersions]);
|
||||
}, [dataReady, publishVersions]);
|
||||
|
||||
// --------------- Steps handling ---------------
|
||||
|
||||
@ -595,7 +596,7 @@ export function PublishModal({
|
||||
}
|
||||
rowSelection={{
|
||||
selectedRowKeys: selectedModrinth,
|
||||
onChange: (keys) => setSelectedModrinth(keys as string[]),
|
||||
onChange: (keys) => {setSelectedModrinth(keys as string[]); console.log(selectedModrinth);},
|
||||
getCheckboxProps: (r: ModrinthTableRow) => ({
|
||||
disabled:
|
||||
r.kind === "existing" ||
|
||||
@ -630,7 +631,7 @@ export function PublishModal({
|
||||
}
|
||||
rowSelection={{
|
||||
selectedRowKeys: selectedCurseforge,
|
||||
onChange: (keys) => setSelectedCurseforge(keys as string[]),
|
||||
onChange: (keys) => {setSelectedCurseforge(keys as string[]); console.log(selectedCurseforge);},
|
||||
getCheckboxProps: (r: CurseforgeTableRow) => ({
|
||||
disabled:
|
||||
r.kind === "existing" ||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user