Skip to content

Commit

Permalink
Fix the new list editing isuses (#3065)
Browse files Browse the repository at this point in the history
Co-authored-by: miko <[email protected]>
  • Loading branch information
keikari and miko authored Feb 22, 2024
1 parent cbbd328 commit 51aed67
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ui/redux/actions/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,11 @@ const doFetchCollectionItems = (items: Array<any>, pageSize?: number) => async (
if (itemsWereFetching) {
const resolvingIds = selectResolvingIds(state);
const resolvingUris = selectResolvingUris(state);
if (resolvingIds.length === 0 && resolvingUris.length === 0) {
if (uriBatches.length === 0 && idBatches.length > 0 && resolvingIds.length === 0) {
itemsWereFetching = false;
} else if (idBatches.length === 0 && uriBatches.length > 0 && resolvingUris.length === 0) {
itemsWereFetching = false;
} else if (resolvingUris.length === 0 && resolvingIds.length === 0) {
itemsWereFetching = false;
}
}
Expand Down Expand Up @@ -377,7 +381,7 @@ export const doFetchItemsInCollection =
collectionItems = await promisedCollectionItemsFetch;
}

if (!collectionItems || collectionItems.length === 0) {
if (!collectionItems || collectionItems?.length === undefined) {
return dispatch({ type: ACTIONS.COLLECTION_ITEMS_RESOLVE_FAIL, data: collectionId });
}

Expand Down Expand Up @@ -533,13 +537,13 @@ export const doCollectionEdit =
}

const isPublic = Boolean(selectResolvedCollectionForId(state, collectionId));

const isPrivateVersion = selectHasPrivateCollectionForId(state, collectionId);
const { uris, remove, replace, order, type, isPreview } = params;

await dispatch(doFetchItemsInCollection({ collectionId }));
state = getState();
const hasItemsResolved = selectCollectionHasItemsResolvedForId(state, collectionId);
if (!hasItemsResolved) {
if (!hasItemsResolved && !isPrivateVersion) {
return dispatch(doToast({ message: __('Failed to resolve collection items. Please try again.'), isError: true }));
}

Expand Down

0 comments on commit 51aed67

Please sign in to comment.