Skip to content

Commit

Permalink
fix: fixed ts
Browse files Browse the repository at this point in the history
  • Loading branch information
mbret committed Nov 26, 2024
1 parent 906d11c commit 56e416d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
28 changes: 17 additions & 11 deletions packages/enhancer-bookmarks/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Reader, waitForSwitch } from "@prose-reader/core"
import { animationFrameScheduler, BehaviorSubject, merge, Subject, timer } from "rxjs"
import { animationFrameScheduler, BehaviorSubject, combineLatest, merge, of, Subject, timer } from "rxjs"
import { filter, map, share, switchMap, takeUntil, tap, withLatestFrom } from "rxjs/operators"
import { SerializableBookmark, EnhancerOutput, RuntimeBookmark, Command } from "./types"
import { consolidateBookmark } from "./bookmarks/consolidateBookmark"
Expand Down Expand Up @@ -33,16 +33,22 @@ export const bookmarksEnhancer =
}

const pages$ = reader.spine.spineLayout.layout$.pipe(
map(({ pages }) => {
return pages.map((page) => {
const item = reader.spine.spineItemsManager.get(page.itemIndex)

return {
...page,
isBookmarkable: item?.isReady,
}
})
}),
switchMap(({ pages }) =>
combineLatest(
pages.map((page) => {
const item = reader.spine.spineItemsManager.get(page.itemIndex)

const isReady$ = item ? item.isReady$ : of(false)

return isReady$.pipe(
map((isReady) => ({
...page,
isBookmarkable: isReady,
})),
)
}),
),
),
)

const removeBookmark$ = commandSubject.pipe(
Expand Down
2 changes: 1 addition & 1 deletion packages/enhancer-pdf/src/renderer/PdfRenderer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { catchError, delay, EMPTY, finalize, from, map, mergeMap, Observable, of, switchMap, tap } from "rxjs"
import { catchError, EMPTY, finalize, from, map, Observable, of, switchMap, tap } from "rxjs"
import { PDFPageProxy, RenderingCancelledException, RenderTask, TextLayer } from "pdfjs-dist"
import { DocumentRenderer, injectCSS, removeCSS, waitForFrameReady, waitForSwitch } from "@prose-reader/core"
import { copyCanvasToFrame, createPdfFrameElement } from "./frames"
Expand Down

0 comments on commit 56e416d

Please sign in to comment.