(
+ fn: (db: typeof browserDB) => T,
+): T | typeof DB_NOT_READY_OR_DISABLED => {
if (!window.__dbIsReady) {
// Or, push to waiting queue
return DB_NOT_READY_OR_DISABLED
diff --git a/src/renderer/src/global.d.ts b/src/renderer/src/global.d.ts
index 6ba2f79ac..f442b950e 100644
--- a/src/renderer/src/global.d.ts
+++ b/src/renderer/src/global.d.ts
@@ -6,7 +6,7 @@ declare global {
export type ComponentType = {
className?: string
} & PropsWithChildren &
- P
+ P
export type Nullable = T | null | undefined
// BIZ ID
diff --git a/src/renderer/src/hooks/biz/useEntryActions.tsx b/src/renderer/src/hooks/biz/useEntryActions.tsx
index 59c57d24d..d8b4e269a 100644
--- a/src/renderer/src/hooks/biz/useEntryActions.tsx
+++ b/src/renderer/src/hooks/biz/useEntryActions.tsx
@@ -28,13 +28,7 @@ import type { ReactNode } from "react"
import { useCallback, useMemo } from "react"
import { toast } from "sonner"
-export const useEntryReadabilityToggle = ({
- id,
- url,
-}: {
- id: string
- url: string
-}) =>
+export const useEntryReadabilityToggle = ({ id, url }: { id: string; url: string }) =>
useCallback(async () => {
const status = getReadabilityStatus()[id]
const isTurnOn = status !== ReadabilityStatus.INITIAL && !!status
@@ -71,8 +65,7 @@ export const useEntryReadabilityToggle = ({
}, [id, url])
export const useCollect = (entry: Nullable) =>
useMutation({
- mutationFn: async () =>
- entry && entryActions.markStar(entry.entries.id, true),
+ mutationFn: async () => entry && entryActions.markStar(entry.entries.id, true),
onSuccess: () => {
toast.success("Starred.", {
@@ -83,8 +76,7 @@ export const useCollect = (entry: Nullable) =>
export const useUnCollect = (entry: Nullable) =>
useMutation({
- mutationFn: async () =>
- entry && entryActions.markStar(entry.entries.id, false),
+ mutationFn: async () => entry && entryActions.markStar(entry.entries.id, false),
onSuccess: () => {
toast.success("Unstarred.", {
@@ -177,10 +169,7 @@ export const useEntryActions = ({
(checkEagle.isLoading ? true : !checkEagle.data) ||
!populatedEntry.entries.media?.length,
onClick: async () => {
- if (
- !populatedEntry.entries.url ||
- !populatedEntry.entries.media?.length
- ) {
+ if (!populatedEntry.entries.url || !populatedEntry.entries.media?.length) {
return
}
const response = await tipcClient?.saveToEagle({
@@ -223,8 +212,7 @@ export const useEntryActions = ({
})
toast.success(
<>
- Saved to Readwise,
- {" "}
+ Saved to Readwise,{" "}
view
@@ -258,16 +246,13 @@ export const useEntryActions = ({
},
method: "POST",
headers: {
- Authorization: `Basic ${btoa(
- `${instapaperUsername}:${instapaperPassword}`,
- )}`,
+ Authorization: `Basic ${btoa(`${instapaperUsername}:${instapaperPassword}`)}`,
},
parseResponse: JSON.parse,
})
toast.success(
<>
- Saved to Instapaper,
- {" "}
+ Saved to Instapaper,{" "}
{
present({
title: "Edit Feed",
- content: ({ dismiss }) => (
-
- ),
+ content: ({ dismiss }) => ,
})
},
},
@@ -78,8 +73,8 @@ export const useFeedActions = ({
disabled: isEntryList,
click: () => subscriptionActions.markReadByFeedIds([feedId]),
},
- ...(!feed.ownerUserId && !!feed.id ?
- [
+ ...(!feed.ownerUserId && !!feed.id
+ ? [
{
type: "text" as const,
label: isEntryList ? "Claim Feed" : "Claim",
@@ -88,16 +83,16 @@ export const useFeedActions = ({
claimFeed()
},
},
- ] :
- []),
- ...(feed.ownerUserId === whoami()?.id ?
- [
+ ]
+ : []),
+ ...(feed.ownerUserId === whoami()?.id
+ ? [
{
type: "text" as const,
label: "This feed is owned by you",
},
- ] :
- []),
+ ]
+ : []),
{
type: "separator" as const,
disabled: isEntryList,
@@ -108,8 +103,7 @@ export const useFeedActions = ({
label: "Open feed in browser",
disabled: isEntryList,
shortcut: "O",
- click: () =>
- window.open(`${WEB_URL}/feed/${feedId}?view=${view}`, "_blank"),
+ click: () => window.open(`${WEB_URL}/feed/${feedId}?view=${view}`, "_blank"),
},
{
type: "text" as const,
diff --git a/src/renderer/src/hooks/biz/useNavigateEntry.ts b/src/renderer/src/hooks/biz/useNavigateEntry.ts
index 9bcceda02..2d6ddebf0 100644
--- a/src/renderer/src/hooks/biz/useNavigateEntry.ts
+++ b/src/renderer/src/hooks/biz/useNavigateEntry.ts
@@ -1,13 +1,6 @@
-import {
- getReadonlyRoute,
- getStableRouterNavigate,
-} from "@renderer/atoms/route"
+import { getReadonlyRoute, getStableRouterNavigate } from "@renderer/atoms/route"
import { setSidebarActiveView } from "@renderer/atoms/sidebar"
-import {
- ROUTE_ENTRY_PENDING,
- ROUTE_FEED_IN_FOLDER,
- ROUTE_FEED_PENDING,
-} from "@renderer/constants"
+import { ROUTE_ENTRY_PENDING, ROUTE_FEED_IN_FOLDER, ROUTE_FEED_PENDING } from "@renderer/constants"
import { FeedViewType } from "@renderer/lib/enum"
import { isUndefined } from "lodash-es"
@@ -55,8 +48,6 @@ export const navigateEntry = (options: NavigateEntryOptions) => {
}
return getStableRouterNavigate()?.(
- `/feeds/${finalFeedId}/${
- entryId || ROUTE_ENTRY_PENDING
- }?${nextSearchParams.toString()}`,
+ `/feeds/${finalFeedId}/${entryId || ROUTE_ENTRY_PENDING}?${nextSearchParams.toString()}`,
)
}
diff --git a/src/renderer/src/hooks/biz/useRouteParams.ts b/src/renderer/src/hooks/biz/useRouteParams.ts
index bce730f1b..4fbf5bffe 100644
--- a/src/renderer/src/hooks/biz/useRouteParams.ts
+++ b/src/renderer/src/hooks/biz/useRouteParams.ts
@@ -1,7 +1,4 @@
-import {
- getReadonlyRoute,
- useReadonlyRouteSelector,
-} from "@renderer/atoms/route"
+import { getReadonlyRoute, useReadonlyRouteSelector } from "@renderer/atoms/route"
import {
FEED_COLLECTION_LIST,
ROUTE_ENTRY_PENDING,
@@ -22,9 +19,8 @@ export const useRouteView = () => {
const view = search.get("view")
return (
- (view && FeedViewTypeValues.includes(view) ?
- +view :
- FeedViewType.Articles) || FeedViewType.Articles
+ (view && FeedViewTypeValues.includes(view) ? +view : FeedViewType.Articles) ||
+ FeedViewType.Articles
)
}
@@ -49,16 +45,12 @@ export interface BizRouteParams {
folderName?: string
}
-const parseRouteParams = (
- params: Params,
- search: URLSearchParams,
-): BizRouteParams => {
+const parseRouteParams = (params: Params, search: URLSearchParams): BizRouteParams => {
const _view = search.get("view")
const view =
- (_view && FeedViewTypeValues.includes(_view) ?
- +_view :
- FeedViewType.Articles) || FeedViewType.Articles
+ (_view && FeedViewTypeValues.includes(_view) ? +_view : FeedViewType.Articles) ||
+ FeedViewType.Articles
return {
view,
@@ -68,9 +60,9 @@ const parseRouteParams = (
isCollection: params.feedId === FEED_COLLECTION_LIST,
isAllFeeds: params.feedId === ROUTE_FEED_PENDING,
isPendingEntry: params.entryId === ROUTE_ENTRY_PENDING,
- folderName: params.feedId?.startsWith(ROUTE_FEED_IN_FOLDER) ?
- params.feedId.slice(ROUTE_FEED_IN_FOLDER.length) :
- undefined,
+ folderName: params.feedId?.startsWith(ROUTE_FEED_IN_FOLDER)
+ ? params.feedId.slice(ROUTE_FEED_IN_FOLDER.length)
+ : undefined,
}
}
@@ -85,11 +77,11 @@ export const useRouteParamsSelector = (
selector: (params: BizRouteParams) => T,
deps = noop,
): T =>
- useReadonlyRouteSelector((route) => {
- const { searchParams, params } = route
+ useReadonlyRouteSelector((route) => {
+ const { searchParams, params } = route
- return selector(parseRouteParams(params, searchParams))
- }, deps)
+ return selector(parseRouteParams(params, searchParams))
+ }, deps)
export const getRouteParams = () => {
const route = getReadonlyRoute()
diff --git a/src/renderer/src/hooks/biz/useSignOut.ts b/src/renderer/src/hooks/biz/useSignOut.ts
index 3f015b0f9..26405baf7 100644
--- a/src/renderer/src/hooks/biz/useSignOut.ts
+++ b/src/renderer/src/hooks/biz/useSignOut.ts
@@ -18,10 +18,7 @@ export const useSignOut = () =>
clearStorage()
window.posthog?.reset()
// clear local store data
- await Promise.allSettled([
- clearLocalPersistStoreData(),
- tipcClient?.cleanAuthSessionToken(),
- ])
+ await Promise.allSettled([clearLocalPersistStoreData(), tipcClient?.cleanAuthSessionToken()])
// Sign out
await signOut()
}, [])
diff --git a/src/renderer/src/hooks/biz/useSubscriptionActions.tsx b/src/renderer/src/hooks/biz/useSubscriptionActions.tsx
index 671b3dcec..26ec0343f 100644
--- a/src/renderer/src/hooks/biz/useSubscriptionActions.tsx
+++ b/src/renderer/src/hooks/biz/useSubscriptionActions.tsx
@@ -12,11 +12,7 @@ import { toast } from "sonner"
import { navigateEntry } from "./useNavigateEntry"
import { getRouteParams } from "./useRouteParams"
-export const useDeleteSubscription = ({
- onSuccess,
-}: {
- onSuccess?: () => void
-}) =>
+export const useDeleteSubscription = ({ onSuccess }: { onSuccess?: () => void }) =>
useMutation({
mutationFn: async (subscription: SubscriptionFlatModel) =>
subscriptionActions.unfollow(subscription.feedId).then((feed) => {
@@ -41,21 +37,20 @@ export const useDeleteSubscription = ({
toast.dismiss(toastId)
}
- const toastId = toast(
- ,
- {
- duration: 3000,
- action: {
- label: (
-
- Undo
- Meta+Z
-
- ),
- onClick: undo,
- },
+ const toastId = toast( , {
+ duration: 3000,
+ action: {
+ label: (
+
+ Undo
+
+ Meta+Z
+
+
+ ),
+ onClick: undo,
},
- )
+ })
}),
onSuccess: (_) => {
@@ -72,18 +67,14 @@ export const useDeleteSubscription = ({
},
})
-const UnfollowInfo = ({ title, undo }: { title: string, undo: () => any }) => {
+const UnfollowInfo = ({ title, undo }: { title: string; undo: () => any }) => {
useHotkeys("ctrl+z,meta+z", undo, {
scopes: HotKeyScopeMap.Home,
preventDefault: true,
})
return (
<>
- Feed
- {" "}
- {title}
- {" "}
- has been unfollowed.
+ Feed {title} has been unfollowed.
>
)
}
diff --git a/src/renderer/src/hooks/common/factory/createHTMLMediaHook.ts b/src/renderer/src/hooks/common/factory/createHTMLMediaHook.ts
index ee78377f1..a68b0500b 100644
--- a/src/renderer/src/hooks/common/factory/createHTMLMediaHook.ts
+++ b/src/renderer/src/hooks/common/factory/createHTMLMediaHook.ts
@@ -9,7 +9,7 @@ import { useEventCallback } from "usehooks-ts"
import { useSetState } from "../useSetState"
function parseTimeRanges(ranges: TimeRanges) {
- const result: { start: number, end: number }[] = []
+ const result: { start: number; end: number }[] = []
for (let i = 0; i < ranges.length; i++) {
result.push({
@@ -22,7 +22,7 @@ function parseTimeRanges(ranges: TimeRanges) {
}
export interface HTMLMediaProps
extends React.AudioHTMLAttributes,
- React.VideoHTMLAttributes {
+ React.VideoHTMLAttributes {
src: string
}
@@ -51,9 +51,9 @@ type MediaPropsWithRef = HTMLMediaProps & {
ref?: React.MutableRefObject
}
-export default function createHTMLMediaHook<
- T extends HTMLAudioElement | HTMLVideoElement,
->(tag: "audio" | "video") {
+export default function createHTMLMediaHook(
+ tag: "audio" | "video",
+) {
return (elOrProps: HTMLMediaProps | React.ReactElement) => {
let element: React.ReactElement> | undefined
let props: MediaPropsWithRef
@@ -129,11 +129,11 @@ export default function createHTMLMediaHook<
const target = e.currentTarget
const hasAudio =
- target.srcObject instanceof MediaStream ?
- target.srcObject.getAudioTracks().length > 0 :
- target.webkitAudioDecodedByteCount === undefined ?
- true :
- target.webkitAudioDecodedByteCount > 0
+ target.srcObject instanceof MediaStream
+ ? target.srcObject.getAudioTracks().length > 0
+ : target.webkitAudioDecodedByteCount === undefined
+ ? true
+ : target.webkitAudioDecodedByteCount > 0
setState({ hasAudio })
}
@@ -247,14 +247,14 @@ export default function createHTMLMediaHook<
if (tag === "audio") {
console.error(
"useAudio() ref to element is empty at mount. " +
- "It seem you have not rendered the audio element, which it " +
- "returns as the first argument const [audio] = useAudio(...).",
+ "It seem you have not rendered the audio element, which it " +
+ "returns as the first argument const [audio] = useAudio(...).",
)
} else if (tag === "video") {
console.error(
"useVideo() ref to element is empty at mount. " +
- "It seem you have not rendered the video element, which it " +
- "returns as the first argument const [video] = useVideo(...).",
+ "It seem you have not rendered the video element, which it " +
+ "returns as the first argument const [video] = useVideo(...).",
)
}
}
diff --git a/src/renderer/src/hooks/common/useBizQuery.ts b/src/renderer/src/hooks/common/useBizQuery.ts
index c2e82144c..87d8d0c7c 100644
--- a/src/renderer/src/hooks/common/useBizQuery.ts
+++ b/src/renderer/src/hooks/common/useBizQuery.ts
@@ -12,9 +12,7 @@ import { useInfiniteQuery, useQuery } from "@tanstack/react-query"
import type { FetchError } from "ofetch"
// TODO split normal define query and infinite define query for better type checking
-export type SafeReturnType = T extends (...args: any[]) => infer R
- ? R
- : never
+export type SafeReturnType = T extends (...args: any[]) => infer R ? R : never
export type CombinedObject = T & U
export function useAuthQuery<
@@ -24,14 +22,8 @@ export function useAuthQuery<
TData = TQueryFnData,
>(
query: TQuery,
- options: Omit<
- UseQueryOptions,
- "queryKey" | "queryFn"
- > = {},
-): CombinedObject<
- UseQueryResult,
- { key: TQuery["key"], fn: TQuery["fn"] }
- > {
+ options: Omit