Skip to content

Commit

Permalink
Merge pull request #192 from mbret/develop
Browse files Browse the repository at this point in the history
release
  • Loading branch information
mbret authored Dec 2, 2024
2 parents 45e4bfb + a676864 commit d2b7607
Show file tree
Hide file tree
Showing 18 changed files with 1,680 additions and 2,270 deletions.
3,835 changes: 1,637 additions & 2,198 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"prettier": "^3.3.2",
"rollup-plugin-analyzer": "^4.0.0",
"typescript": "^5.5.4",
"vercel": "^38.0.0",
"vercel": "^39.1.0",
"vite": "^5.0.0",
"vite-plugin-dts": "^4.0.3",
"vite-plugin-pwa": "^0.21.0",
Expand Down
1 change: 1 addition & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@sentry/profiling-node": "^8.32.0"
},
"devDependencies": {
"@types/node": "^20",
"@types/aws-lambda": "^8.10.111",
"@types/http-errors": "^2.0.1",
"@types/jsonwebtoken": "^9.0.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/api/src/libs/archives/getRarArchive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { createExtractorFromData } from "node-unrar-js"

const wasmBinary = fs.readFileSync(
require.resolve("node-unrar-js/esm/js/unrar.wasm")
)
).buffer as ArrayBuffer

export const getRarArchive = async (filePath: string) => {
const buffer = fs.readFileSync(filePath)
const data = fs.readFileSync(filePath).buffer as ArrayBuffer
const extractor = await createExtractorFromData({
data: buffer,
data,
wasmBinary
})

Expand Down
1 change: 1 addition & 0 deletions packages/api/src/libs/httpErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ export const createHttpError = (
if (Array.isArray(error)) {
return createError(code, JSON.stringify({ errors: error }), opts)
}

return createError(code, JSON.stringify({ errors: [error] }), opts)
}
16 changes: 0 additions & 16 deletions packages/api/src/libs/middy/unexpectedErrorToHttpError.ts

This file was deleted.

11 changes: 8 additions & 3 deletions packages/api/src/libs/middy/withMiddy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import httpHeaderNormalizer from "@middy/http-header-normalizer"
import cors from "@middy/http-cors"
import { transpileSchema } from "@middy/validator/transpile"
import validator from "@middy/validator"
import { unexpectedErrorToHttpError } from "./unexpectedErrorToHttpError"

import * as Sentry from "@sentry/aws-serverless"
import { ObokuErrorCode } from "@oboku/shared"
// import { nodeProfilingIntegration } from "@sentry/profiling-node"

Sentry.init({
Expand Down Expand Up @@ -78,11 +78,16 @@ export const withMiddy = (
}
})
.use(
/**
* Non http response will be converted to http response and use
* the fallback message
*/
httpErrorHandler({
fallbackMessage: `An error occurred`
fallbackMessage: JSON.stringify({
errors: [{ code: ObokuErrorCode.UNKNOWN }]
})
})
)
.use(unexpectedErrorToHttpError())
// @todo eventually protect the api and only allow a subset of origins
.use(
withCors
Expand Down
12 changes: 0 additions & 12 deletions packages/web/src/books/bookList/BookList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,5 @@ export const BookList = memo(
{...rest}
/>
)

// return (
// <Stack flex={1}>
// <VirtualizedList
// data={data}
// rowRenderer={rowRenderer}
// itemsPerRow={itemsPerRow}
// style={style}
// {...rest}
// />
// </Stack>
// )
}
)
4 changes: 2 additions & 2 deletions packages/web/src/books/details/DataSourceSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const DataSourceSection = memo(({ bookId }: { bookId: string }) => {
px: [null, 3]
}}
>
Link
Provider
</ListSubheader>
}
>
Expand Down Expand Up @@ -70,7 +70,7 @@ export const DataSourceSection = memo(({ bookId }: { bookId: string }) => {
textOverflow: "ellipsis"
}
}}
secondary={`This book has been created from ${dataSourcePlugin.name}. Click to edit the data source`}
secondary={`This book is attached to ${dataSourcePlugin.name}. Click to edit the link`}
/>
<Stack width={50} alignItems="center" flexShrink={0}>
<MoreVertRounded />
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/books/details/MetadataSourcePane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const MetadataSourcePane: FC<{ bookId: string }> = ({ bookId }) => {
px: [null, 3]
}}
>
Metadata sources
Metadata Sources
</ListSubheader>
}
disablePadding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ import { useUpdateCollectionBooks } from "../useUpdateCollectionBooks"
import { useCollection } from "../useCollection"

export const CollectionActionsDrawer: FC<{}> = () => {
const { openedWith: collectionId } = useSignalValue(
const { openedWith, lastId: collectionId } = useSignalValue(
collectionActionDrawerState
)

const [
isEditCollectionDialogOpenedWithId,
setIsEditCollectionDialogOpenedWithId
Expand All @@ -47,15 +48,18 @@ export const CollectionActionsDrawer: FC<{}> = () => {
const { closeModalWithNavigation } = useModalNavigationControl(
{
onExit: () => {
collectionActionDrawerState.setValue({ openedWith: undefined })
collectionActionDrawerState.setValue({
openedWith: undefined,
lastId: collectionId
})

setIsEditCollectionDialogOpenedWithId(undefined)
setIsManageBookDialogOpened(false)
}
},
collectionId
openedWith
)
const { data: collection } = useCollection({ id: collectionId })
const opened = !!collectionId

const onRemoveCollection = (id: string) => {
closeModalWithNavigation()
Expand All @@ -70,13 +74,11 @@ export const CollectionActionsDrawer: FC<{}> = () => {
COLLECTION_METADATA_LOCK_MN
)

if (!collectionId) return null

return (
<>
<Drawer
anchor="bottom"
open={opened && !subActionOpened}
open={!!openedWith && !subActionOpened}
onClose={() => closeModalWithNavigation()}
>
<List>
Expand All @@ -94,7 +96,7 @@ export const CollectionActionsDrawer: FC<{}> = () => {
onClick={() => {
closeModalWithNavigation()
updateCollectionBooks({
id: collectionId,
id: collectionId ?? ``,
updateObj: {
$set: {
isNotInterested: true
Expand All @@ -112,7 +114,7 @@ export const CollectionActionsDrawer: FC<{}> = () => {
onClick={() => {
closeModalWithNavigation()
updateCollectionBooks({
id: collectionId,
id: collectionId ?? ``,
updateObj: {
$set: {
isNotInterested: false
Expand All @@ -139,7 +141,7 @@ export const CollectionActionsDrawer: FC<{}> = () => {
{collection?.type === "series" && (
<ListItemButton
onClick={() => {
refreshCollectionMetadata(collectionId)
refreshCollectionMetadata(collectionId ?? ``)
}}
disabled={isRefreshingMetadata}
>
Expand All @@ -158,7 +160,9 @@ export const CollectionActionsDrawer: FC<{}> = () => {
</List>
<Divider />
<List>
<ListItemButton onClick={() => onRemoveCollection(collectionId)}>
<ListItemButton
onClick={() => onRemoveCollection(collectionId ?? ``)}
>
<ListItemIcon>
<DeleteForeverRounded />
</ListItemIcon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { signal, useSignalValue } from "reactjrx"

export const collectionActionDrawerState = signal<{
openedWith: undefined | string
}>({ key: "collectionActionDrawerState", default: { openedWith: undefined } })
lastId?: undefined | string
}>({
key: "collectionActionDrawerState",
default: { openedWith: undefined, lastId: undefined }
})

export const collectionActionDrawerChangesState = signal<
undefined | [string, `delete`]
Expand All @@ -26,7 +30,7 @@ export const useCollectionActionsDrawer = (
const latestChangesEmittedRef = useRef(collectionActionDrawerChanges)

const open = useCallback(() => {
collectionActionDrawerState.setValue({ openedWith: id })
collectionActionDrawerState.setValue({ openedWith: id, lastId: id })
}, [id])

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useCollection } from "./useCollection"
export const ManageCollectionBooksDialog: FC<{
onClose: () => void
open: boolean
collectionId: string
collectionId?: string
}> = ({ onClose, open, collectionId }) => {
const { data: collection } = useCollection({
id: collectionId
Expand Down
3 changes: 2 additions & 1 deletion packages/web/src/constants.shared.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const sw: ServiceWorkerGlobalScope = self as any
const hostname =
typeof window === "object"
? window?.location?.hostname
: sw?.location?.hostname


export const STREAMER_URL_PREFIX = `streamer`
export const DOWNLOAD_PREFIX = `book-download`
export const SENTRY_DSN = `https://[email protected]/5554285`
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/reader/Reader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { memo, useRef } from "react"
import { readerSignal } from "./states"
import { TopBar } from "./navigation/TopBar"
import { BottomBar } from "./navigation/BottomBar"
import { useGestureHandler } from "./gestures/gestures"
import { useGestureHandler } from "./gestures/useGestureHandler"
import { BookLoading } from "./BookLoading"
import { useSyncBookProgress } from "./progress/useSyncBookProgress"
import { FloatingBottom } from "./navigation/FloatingBottom"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
import { useEffect } from "react"
import { useSignalValue, useSubscribe } from "reactjrx"
import { tap } from "rxjs"
import { isMenuShownStateSignal, readerSignal } from "../states"

export const useGestureHandler = () => {
const reader = useSignalValue(readerSignal)

useEffect(() => {
const deregister = reader?.gestures.hookManager.register(
"beforeTap",
({}) => {
return true
}
)

return () => {
deregister?.()
}
}, [reader])

useSubscribe(
() =>
reader?.gestures.unhandledEvent$.pipe(
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/search/SearchScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const SearchScreen = () => {
}
/>
<ListActionsToolbar />
<Box overflow="scroll">
<Box overflow="auto">
<Accordion
disableGutters
elevation={0}
Expand Down
3 changes: 0 additions & 3 deletions packages/web/src/tags/tagList/TagList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,5 @@ export const TagList = memo(
)

return <VirtuosoList rowRenderer={rowRenderer} itemsPerRow={1} {...rest} />
// return (
// <VirtualizedList rowRenderer={rowRenderer} itemsPerRow={1} {...rest} />
// )
}
)

0 comments on commit d2b7607

Please sign in to comment.