From 4ee64ae8def9092853dbd224ec431ccb8880823d Mon Sep 17 00:00:00 2001 From: Felipe M Date: Fri, 21 Jul 2023 12:41:02 +0200 Subject: [PATCH 1/2] fix: title is never retrieved when adding bookmark Fixes #654 --- internal/webserver/handler-api.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/webserver/handler-api.go b/internal/webserver/handler-api.go index 92da0f4a9..7c19c6ed9 100644 --- a/internal/webserver/handler-api.go +++ b/internal/webserver/handler-api.go @@ -221,6 +221,7 @@ func (h *Handler) ApiInsertBookmark(w http.ResponseWriter, r *http.Request, ps h panic(fmt.Errorf("failed to clean URL: %v", err)) } + userHasDefinedTitle := book.Title == "" // Make sure bookmark's title not empty if book.Title == "" { book.Title = book.URL @@ -236,7 +237,7 @@ func (h *Handler) ApiInsertBookmark(w http.ResponseWriter, r *http.Request, ps h if payload.Async { go func() { - bookmark, err := downloadBookmarkContent(book, h.DataDir, r, book.Title != "", book.Excerpt != "") + bookmark, err := downloadBookmarkContent(book, h.DataDir, r, !userHasDefinedTitle, book.Excerpt != "") if err != nil { log.Printf("error downloading boorkmark: %s", err) return @@ -248,7 +249,7 @@ func (h *Handler) ApiInsertBookmark(w http.ResponseWriter, r *http.Request, ps h } else { // Workaround. Download content after saving the bookmark so we have the proper database // id already set in the object regardless of the database engine. - book, err = downloadBookmarkContent(book, h.DataDir, r, book.Title != "", book.Excerpt != "") + book, err = downloadBookmarkContent(book, h.DataDir, r, !userHasDefinedTitle, book.Excerpt != "") if err != nil { log.Printf("error downloading boorkmark: %s", err) } else if _, err := h.DB.SaveBookmarks(ctx, false, *book); err != nil { From 0f19765842a96ec48172305889ab5e2888791d92 Mon Sep 17 00:00:00 2001 From: Felipe M Date: Fri, 21 Jul 2023 12:57:43 +0200 Subject: [PATCH 2/2] typo: logic --- internal/webserver/handler-api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/webserver/handler-api.go b/internal/webserver/handler-api.go index 7c19c6ed9..8362a835f 100644 --- a/internal/webserver/handler-api.go +++ b/internal/webserver/handler-api.go @@ -221,7 +221,7 @@ func (h *Handler) ApiInsertBookmark(w http.ResponseWriter, r *http.Request, ps h panic(fmt.Errorf("failed to clean URL: %v", err)) } - userHasDefinedTitle := book.Title == "" + userHasDefinedTitle := book.Title != "" // Make sure bookmark's title not empty if book.Title == "" { book.Title = book.URL