Start reading cancel read: move logic to backend
This commit is contained in:
@@ -72,7 +72,6 @@ async function onStartReadIconClick() {
|
||||
}
|
||||
if (data.value.read) {
|
||||
data.value.read = false
|
||||
putUnreadBook(props.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,17 +86,12 @@ async function onUserBookStartRead() {
|
||||
|
||||
async function userBookStartRead() {
|
||||
const res = await putStartRead(props.id)
|
||||
if (!res.ok) {
|
||||
res.json().then((json) => (error.value = json))
|
||||
return
|
||||
}
|
||||
const resp = await putUnreadBook(props.id)
|
||||
if (resp.ok) {
|
||||
if (res.ok) {
|
||||
currentStartReadDate.value = today
|
||||
isRead.value = false
|
||||
isWantRead.value = false
|
||||
} else {
|
||||
resp.json().then((json) => (error.value = json))
|
||||
res.json().then((json) => (error.value = json))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -153,6 +153,18 @@ func TestPutStartReadUserBooks_UnsetWantReadOk(t *testing.T) {
|
||||
assert.Equal(t, false, book.WantRead)
|
||||
}
|
||||
|
||||
func TestPutStartReadUserBooks_UnsetReadOk(t *testing.T) {
|
||||
payload :=
|
||||
`{
|
||||
"startDate": "2025-12-20"
|
||||
}`
|
||||
bookId := "13"
|
||||
testPutUserBooks(t, payload, bookId, http.StatusOK)
|
||||
book := testGetBook(t, bookId, http.StatusOK)
|
||||
assert.Equal(t, "2025-12-20", book.StartReadDate)
|
||||
assert.Equal(t, false, book.Read)
|
||||
}
|
||||
|
||||
func TestPutStartReadUserBooks_Unset(t *testing.T) {
|
||||
payload :=
|
||||
`{
|
||||
|
||||
@@ -63,6 +63,7 @@ func PutUserBookHandler(ac appcontext.AppContext) {
|
||||
return
|
||||
}
|
||||
if d != nil {
|
||||
userbook.Read = false
|
||||
userbook.WantRead = false
|
||||
}
|
||||
userbook.StartReadDate = d
|
||||
|
||||
Reference in New Issue
Block a user