Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the new list editing isuses #3065

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Changes from all commits
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
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) {
infinite-persistence marked this conversation as resolved.
Show resolved Hide resolved
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
Loading