Skip to content

Commit

Permalink
fix: type error
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Jul 12, 2024
1 parent 42b68a4 commit 5ae0548
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/renderer/src/atoms/sidebar.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,42 @@
import { getRouteParams } from "@renderer/hooks/biz/useRouteParams"
import type { FeedViewType } from "@renderer/lib/enum"
import { FeedViewType } from "@renderer/lib/enum"
import { createAtomHooks } from "@renderer/lib/jotai"
import { atom } from "jotai"

const defaultFeedView = FeedViewType.Articles
const viewAtom = atom<FeedViewType | -1>(-1)
const [
,
useSidebarActiveView,
useSidebarActiveViewValue,
useSidebarActiveViewValue_,
useSetSidebarActiveView,
getSidebarActiveView,
_getSidebarActiveView,
setSidebarActiveView,
] = createAtomHooks(viewAtom)

const getSidebarActiveView = (): FeedViewType => {
const view = _getSidebarActiveView()
if (view === -1) {
return defaultFeedView
}
return view
}

const useSidebarActiveViewValue = (): FeedViewType => {
const view = useSidebarActiveViewValue_()
if (view === -1) {
return defaultFeedView
}
return view
}

export {
getSidebarActiveView,
setSidebarActiveView,
useSetSidebarActiveView,
/**
* Get original value of sidebar active view
*/
useSidebarActiveView,
useSidebarActiveViewValue,
}
Expand Down

0 comments on commit 5ae0548

Please sign in to comment.