Skip to content

Commit

Permalink
feat: prevent back to reading book already fnished
Browse files Browse the repository at this point in the history
  • Loading branch information
mbret committed Apr 10, 2024
1 parent 71ef6ad commit 509e073
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/web/src/reading/BackToReadingDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { latestDatabase$ } from "../rxdb/useCreateDatabase"
import { from, switchMap } from "rxjs"
import { CancelError } from "../common/errors/errors"
import { catchCancelError } from "../common/errors/catchCancelError"
import { ReadingStateState } from "@oboku/shared"

const BASE_READER_ROUTE = ROUTES.READER.replace(`/:id`, ``)

Expand Down Expand Up @@ -39,7 +40,11 @@ export const BackToReadingDialog = memo(

return book$.pipe(
switchMap((book) => {
if (!book) throw new CancelError()
if (
!book ||
book.readingStateCurrentState === ReadingStateState.Finished
)
throw new CancelError()

const { title } = getMetadataFromBook(book.toJSON())

Expand Down

0 comments on commit 509e073

Please sign in to comment.