Skip to content

Commit 97965c2

Browse files
gpousselgoniszewskiSparkenstein
authored
Fix issue #145: bookmarks without images (#156)
* chore: release v0.4.3 (#149) * chore: release v0.4.1-hotfix.3 * fix(data-migration): early return if no categories have parents (#128) Signed-off-by: Robert Goniszewski <robertgoniszewski@outlook.com> * Closes #130 (#131) Signed-off-by: Robert Goniszewski <robertgoniszewski@outlook.com> * fix(database): use dynamic path for SQLite database file Signed-off-by: Robert Goniszewski <robertgoniszewski@outlook.com> * docs(readme): use single README file for latest/preview version Signed-off-by: Robert Goniszewski <robertgoniszewski@outlook.com> * feat(ci): add manual deployment workflow and adjust tag conditions Signed-off-by: Robert Goniszewski <robertgoniszewski@outlook.com> * refactor(workflow): simplify manual-deploy GitHub Action Signed-off-by: Robert Goniszewski <robertgoniszewski@outlook.com> * fix(metadata): handle multiple image URLs in mainImageUrl field Signed-off-by: Robert Goniszewski <robertgoniszewski@outlook.com> * fix: auth error handling (#144) * refactor(api): migrate Swagger UI to external documentation and enhance health endpoint Signed-off-by: Robert Goniszewski <robertgoniszewski@outlook.com> * chore: release v0.4.3 --------- Signed-off-by: Robert Goniszewski <robertgoniszewski@outlook.com> Co-authored-by: Prabhanjan <zetabytes.pp@gmail.com> * Fix bookmark creation/update without image --------- Signed-off-by: Robert Goniszewski <robertgoniszewski@outlook.com> Co-authored-by: Robert Goniszewski <43510122+goniszewski@users.noreply.github.com> Co-authored-by: Prabhanjan <zetabytes.pp@gmail.com>
1 parent 5e31e77 commit 97965c2

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/routes/+page.server.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,15 @@ export const actions = {
7171
error: 'Failed to add bookmark'
7272
};
7373
}
74-
const { id: mainImageId } = await storage.storeImage(
75-
mainImageUrl,
76-
title,
77-
ownerId,
78-
bookmark.id
79-
);
80-
const { id: iconId } = await storage.storeImage(iconUrl, title, ownerId, bookmark.id);
74+
const mainImage = mainImageUrl
75+
? await storage.storeImage(mainImageUrl, title, ownerId, bookmark.id)
76+
: undefined;
77+
const icon = iconUrl
78+
? await storage.storeImage(iconUrl, title, ownerId, bookmark.id)
79+
: undefined;
8180
const updatedBookmark = await updateBookmark(bookmark.id, ownerId, {
82-
mainImageId,
83-
iconId
81+
...(mainImage ? { mainImageId: mainImage.id } : {}),
82+
...(icon ? { iconId: icon.id } : {})
8483
});
8584

8685
await upsertTagsForBookmark(bookmark.id, ownerId, tagNames);
@@ -149,8 +148,10 @@ export const actions = {
149148

150149
const tagNames = tags.map((tag: any) => tag.label);
151150

152-
const { id: mainImageId } = await storage.storeImage(mainImageUrl, title, ownerId, id);
153-
const { id: iconId } = await storage.storeImage(iconUrl, title, ownerId, id);
151+
const mainImage = mainImageUrl
152+
? await storage.storeImage(mainImageUrl, title, ownerId, id)
153+
: undefined;
154+
const icon = iconUrl ? await storage.storeImage(iconUrl, title, ownerId, id) : undefined;
154155

155156
const bookmarkData = {
156157
author,
@@ -169,8 +170,8 @@ export const actions = {
169170
title,
170171
url,
171172
read,
172-
...(mainImageId ? { mainImageId } : {}),
173-
...(iconId ? { iconId } : {})
173+
...(mainImage ? { mainImageId: mainImage.id } : {}),
174+
...(icon ? { iconId: icon.id } : {})
174175
};
175176

176177
const bookmark = await updateBookmark(id, ownerId, bookmarkData);

0 commit comments

Comments
 (0)