Skip to content

Commit

Permalink
fix: sort pictures + delete
Browse files Browse the repository at this point in the history
  • Loading branch information
ledouxm committed Oct 23, 2024
1 parent b87f25b commit 62f0968
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/frontend/src/features/InfoForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,22 +337,23 @@ const mergePictureArrays = (a: Tmp_pictures[], b: Pictures[]) => {
return new Date(a.createdAt!).getTime() - new Date(b.createdAt!).getTime();
};

for (const item of a.sort(sortByDate)) {
for (const item of a) {
map.set(item.id, item);
}

for (const item of b.sort(sortByDate)) {
for (const item of b) {
map.set(item.id, item);
}

return Array.from(map.values());
return Array.from(map.values()).sort(sortByDate);
};

const PictureThumbnail = ({ picture, index, status }: { picture: Pictures; index: number; status?: string }) => {
const deletePictureMutation = useMutation(async () => {
await deleteImageFromIdb(picture.id);
if (picture.url) await db.pictures.delete({ where: { id: picture.id } });
else await db.tmp_pictures.delete({ where: { id: picture.id } });
await db.tmp_pictures.delete({ where: { id: picture.id } }).catch(() => {});
await db.pictures.delete({ where: { id: picture.id } }).catch(() => {});

return "ok";
});

Expand Down

0 comments on commit 62f0968

Please sign in to comment.