Skip to content

Commit

Permalink
fix: title is never retrieved when adding bookmark (#664)
Browse files Browse the repository at this point in the history
* fix: title is never retrieved when adding bookmark

Fixes #654
  • Loading branch information
fmartingr committed Jul 21, 2023
1 parent 6c41661 commit 622d556
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/webserver/handler-api.go
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 622d556

Please sign in to comment.