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