Click on "start reading" now removes "want to read"

This commit is contained in:
2026-03-26 20:07:26 +01:00
parent d8fc7396ff
commit 9c18206483
4 changed files with 10 additions and 4 deletions

View File

@@ -64,6 +64,7 @@ function onWantReadIconClick() {
async function onStartReadIconClick() {
if (!data.value.startReadDate) {
data.value.startReadDate = today
data.value.wantread = false
putStartReadDate(props.id, data.value.startReadDate)
} else if (!data.value.read) {
data.value.startReadDate = null

View File

@@ -94,6 +94,7 @@ async function userBookStartRead() {
if (resp.ok) {
currentStartReadDate.value = today
isRead.value = false
isWantRead.value = false
} else {
resp.json().then((json) => (error.value = json))
}

View File

@@ -137,19 +137,20 @@ func TestPutStartReadUserBooks_WrongDateFormat(t *testing.T) {
`{
"startDate": "19/11/2025"
}`
bookId := "6"
bookId := "7"
testPutUserBooks(t, payload, bookId, http.StatusInternalServerError)
}
func TestPutStartReadUserBooks_NewReadOk(t *testing.T) {
func TestPutStartReadUserBooks_UnsetWantReadOk(t *testing.T) {
payload :=
`{
"startDate": "2025-11-19"
}`
bookId := "6"
bookId := "7"
testPutUserBooks(t, payload, bookId, http.StatusOK)
book := testGetBook(t, bookId, http.StatusOK)
assert.Equal(t, "2025-11-19", book.StartReadDate)
assert.Equal(t, false, book.WantRead)
}
func TestPutStartReadUserBooks_Unset(t *testing.T) {
@@ -157,7 +158,7 @@ func TestPutStartReadUserBooks_Unset(t *testing.T) {
`{
"startDate": "null"
}`
bookId := "6"
bookId := "7"
testPutUserBooks(t, payload, bookId, http.StatusOK)
book := testGetBook(t, bookId, http.StatusOK)
assert.Equal(t, "", book.StartReadDate)

View File

@@ -62,6 +62,9 @@ func PutUserBookHandler(ac appcontext.AppContext) {
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
return
}
if d != nil {
userbook.WantRead = false
}
userbook.StartReadDate = d
}
if userBookPut.Rating != nil {