mirror of
https://github.com/p-stream/p-stream.git
synced 2026-03-11 17:55:33 +00:00
append collection bookmarks so they arent removed from other groups
This commit is contained in:
parent
f81bd73d72
commit
9b02bf794a
1 changed files with 18 additions and 1 deletions
|
|
@ -111,6 +111,8 @@ export function CollectionOverlay({
|
|||
}: CollectionOverlayProps) {
|
||||
const { t } = useTranslation();
|
||||
const { showModal } = useOverlayStack();
|
||||
const bookmarks = useBookmarkStore((s) => s.bookmarks);
|
||||
const modifyBookmarks = useBookmarkStore((s) => s.modifyBookmarks);
|
||||
const addBookmarkWithGroups = useBookmarkStore(
|
||||
(s) => s.addBookmarkWithGroups,
|
||||
);
|
||||
|
|
@ -177,6 +179,8 @@ export function CollectionOverlay({
|
|||
// Format the group name with the random icon
|
||||
const groupName = `[${randomIcon}]${collectionName}`;
|
||||
|
||||
const existingIds: string[] = [];
|
||||
|
||||
collection.parts.forEach((movie) => {
|
||||
const year = movie.release_date
|
||||
? new Date(movie.release_date).getFullYear()
|
||||
|
|
@ -185,8 +189,15 @@ export function CollectionOverlay({
|
|||
// Skip movies without a release year
|
||||
if (year === undefined) return;
|
||||
|
||||
const movieId = movie.id.toString();
|
||||
|
||||
if (bookmarks[movieId]) {
|
||||
existingIds.push(movieId);
|
||||
return;
|
||||
}
|
||||
|
||||
const meta = {
|
||||
tmdbId: movie.id.toString(),
|
||||
tmdbId: movieId,
|
||||
type: "movie" as const,
|
||||
title: movie.title,
|
||||
releaseYear: year,
|
||||
|
|
@ -195,6 +206,12 @@ export function CollectionOverlay({
|
|||
|
||||
addBookmarkWithGroups(meta, [groupName]);
|
||||
});
|
||||
|
||||
if (existingIds.length > 0) {
|
||||
modifyBookmarks(existingIds, {
|
||||
addGroups: [groupName],
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleShowDetails = (media: MediaItem) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue