Click on "start reading" now removes "want to read"
This commit is contained in:
@@ -64,6 +64,7 @@ function onWantReadIconClick() {
|
|||||||
async function onStartReadIconClick() {
|
async function onStartReadIconClick() {
|
||||||
if (!data.value.startReadDate) {
|
if (!data.value.startReadDate) {
|
||||||
data.value.startReadDate = today
|
data.value.startReadDate = today
|
||||||
|
data.value.wantread = false
|
||||||
putStartReadDate(props.id, data.value.startReadDate)
|
putStartReadDate(props.id, data.value.startReadDate)
|
||||||
} else if (!data.value.read) {
|
} else if (!data.value.read) {
|
||||||
data.value.startReadDate = null
|
data.value.startReadDate = null
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ async function userBookStartRead() {
|
|||||||
if (resp.ok) {
|
if (resp.ok) {
|
||||||
currentStartReadDate.value = today
|
currentStartReadDate.value = today
|
||||||
isRead.value = false
|
isRead.value = false
|
||||||
|
isWantRead.value = false
|
||||||
} else {
|
} else {
|
||||||
resp.json().then((json) => (error.value = json))
|
resp.json().then((json) => (error.value = json))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,19 +137,20 @@ func TestPutStartReadUserBooks_WrongDateFormat(t *testing.T) {
|
|||||||
`{
|
`{
|
||||||
"startDate": "19/11/2025"
|
"startDate": "19/11/2025"
|
||||||
}`
|
}`
|
||||||
bookId := "6"
|
bookId := "7"
|
||||||
testPutUserBooks(t, payload, bookId, http.StatusInternalServerError)
|
testPutUserBooks(t, payload, bookId, http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPutStartReadUserBooks_NewReadOk(t *testing.T) {
|
func TestPutStartReadUserBooks_UnsetWantReadOk(t *testing.T) {
|
||||||
payload :=
|
payload :=
|
||||||
`{
|
`{
|
||||||
"startDate": "2025-11-19"
|
"startDate": "2025-11-19"
|
||||||
}`
|
}`
|
||||||
bookId := "6"
|
bookId := "7"
|
||||||
testPutUserBooks(t, payload, bookId, http.StatusOK)
|
testPutUserBooks(t, payload, bookId, http.StatusOK)
|
||||||
book := testGetBook(t, bookId, http.StatusOK)
|
book := testGetBook(t, bookId, http.StatusOK)
|
||||||
assert.Equal(t, "2025-11-19", book.StartReadDate)
|
assert.Equal(t, "2025-11-19", book.StartReadDate)
|
||||||
|
assert.Equal(t, false, book.WantRead)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPutStartReadUserBooks_Unset(t *testing.T) {
|
func TestPutStartReadUserBooks_Unset(t *testing.T) {
|
||||||
@@ -157,7 +158,7 @@ func TestPutStartReadUserBooks_Unset(t *testing.T) {
|
|||||||
`{
|
`{
|
||||||
"startDate": "null"
|
"startDate": "null"
|
||||||
}`
|
}`
|
||||||
bookId := "6"
|
bookId := "7"
|
||||||
testPutUserBooks(t, payload, bookId, http.StatusOK)
|
testPutUserBooks(t, payload, bookId, http.StatusOK)
|
||||||
book := testGetBook(t, bookId, http.StatusOK)
|
book := testGetBook(t, bookId, http.StatusOK)
|
||||||
assert.Equal(t, "", book.StartReadDate)
|
assert.Equal(t, "", book.StartReadDate)
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ func PutUserBookHandler(ac appcontext.AppContext) {
|
|||||||
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if d != nil {
|
||||||
|
userbook.WantRead = false
|
||||||
|
}
|
||||||
userbook.StartReadDate = d
|
userbook.StartReadDate = d
|
||||||
}
|
}
|
||||||
if userBookPut.Rating != nil {
|
if userBookPut.Rating != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user