Skip to content

Commit 13f0044

Browse files
rohit-singh-bishtskeptrunedev
authored andcommitted
bugfix: card collections should bubble up after creation
1 parent 637d4cd commit 13f0044

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

search/src/components/BookmarkPopover.tsx

+11-10
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface BookmarkPopoverProps {
2424
totalCollectionPages: number;
2525
setLoginModal: Setter<boolean>;
2626
bookmarks: CardBookmarksDTO[];
27+
setCardCollections: Setter<CardCollectionDTO[]>;
2728
}
2829

2930
const BookmarkPopover = (props: BookmarkPopoverProps) => {
@@ -138,17 +139,17 @@ const BookmarkPopover = (props: BookmarkPopoverProps) => {
138139
});
139140
});
140141

141-
setLocalCardCollections(() => {
142-
const deDupedPrev = data.collections.filter((collection) => {
143-
return (
144-
collectionsToAdd.find(
145-
(collectionToAdd) => collectionToAdd.id == collection.id,
146-
) == undefined
147-
);
148-
});
149-
150-
return [...collectionsToAdd, ...deDupedPrev];
142+
const deDupedPrev = data.collections.filter((collection) => {
143+
return (
144+
collectionsToAdd.find(
145+
(collectionToAdd) => collectionToAdd.id == collection.id,
146+
) == undefined
147+
);
151148
});
149+
150+
const updatedCollections = [...collectionsToAdd, ...deDupedPrev];
151+
setLocalCardCollections(updatedCollections);
152+
props.setCardCollections(updatedCollections);
152153
}
153154
});
154155
}

search/src/components/ResultsPage.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ const ResultsPage = (props: ResultsPageProps) => {
175175
setOnDelete={setOnDelete}
176176
setShowConfirmModal={setShowConfirmDeleteModal}
177177
showExpand={clientSideRequestFinished()}
178+
setCardCollections={setCardCollections}
178179
/>
179180
</div>
180181
)}

search/src/components/ScoreCard.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export interface ScoreCardProps {
4141
initialExpanded?: boolean;
4242
bookmarks: CardBookmarksDTO[];
4343
showExpand?: boolean;
44+
setCardCollections: Setter<CardCollectionDTO[]>;
4445
}
4546

4647
const ScoreCard = (props: ScoreCardProps) => {
@@ -236,6 +237,7 @@ const ScoreCard = (props: ScoreCardProps) => {
236237
bookmarks={props.bookmarks.filter(
237238
(bookmark) => bookmark.card_uuid === props.card.id,
238239
)}
240+
setCardCollections={props.setCardCollections}
239241
/>
240242
</div>
241243
<div class="flex w-full items-start">

search/src/components/ScoreCardArray.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
import type { Setter } from "solid-js";
12
import { Show, createSignal } from "solid-js";
2-
import type { CardMetadataWithVotes } from "../../utils/apiTypes";
3+
import type {
4+
CardMetadataWithVotes,
5+
CardCollectionDTO,
6+
} from "../../utils/apiTypes";
37
import type { ScoreCardProps } from "./ScoreCard";
48
import { FiChevronLeft, FiChevronRight } from "solid-icons/fi";
59
import ScoreCard from "./ScoreCard";
610

711
export type ScoreCardAraryProps = Omit<ScoreCardProps, "card"> & {
812
cards: CardMetadataWithVotes[];
13+
setCardCollections: Setter<CardCollectionDTO[]>;
914
};
1015

1116
export const ScoreCardArray = (props: ScoreCardAraryProps) => {

0 commit comments

Comments
 (0)