refactor: rename actived to active
This commit is contained in:
parent
c0e3a10568
commit
59d81df5ba
|
|
@ -1,5 +1,4 @@
|
|||
import { useEntries } from "@renderer/lib/queries/entries"
|
||||
import { ActiveList, ActivedEntry } from "@renderer/lib/types"
|
||||
import { m } from "framer-motion"
|
||||
import { cn } from "@renderer/lib/utils"
|
||||
import { ArticleItem } from "./article-item"
|
||||
|
|
@ -14,7 +13,7 @@ import { useMainLayoutContext } from "@renderer/contexts/outlet/main-layout"
|
|||
const gridMode = [2, 3]
|
||||
|
||||
export function EntryColumn() {
|
||||
const { activeList, setActiveEntry: setActivedEntry } = useMainLayoutContext()
|
||||
const { activeList, setActiveEntry } = useMainLayoutContext()
|
||||
const entries = useEntries({
|
||||
level: activeList?.level,
|
||||
id: activeList?.id,
|
||||
|
|
@ -43,7 +42,7 @@ export function EntryColumn() {
|
|||
}
|
||||
|
||||
return (
|
||||
<div className="px-2" onClick={() => setActivedEntry(null)}>
|
||||
<div className="px-2" onClick={() => setActiveEntry(null)}>
|
||||
<div className="ml-9 mb-5">
|
||||
<div className="font-bold text-lg">{activeList?.name}</div>
|
||||
<div className="text-xs font-medium text-zinc-400">
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@ export function EntryItemWrapper({
|
|||
entry,
|
||||
})
|
||||
|
||||
const { activeEntry, setActiveEntry: setActivedEntry } =
|
||||
useMainLayoutContext()
|
||||
const { activeEntry, setActiveEntry } = useMainLayoutContext()
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
@ -32,7 +31,7 @@ export function EntryItemWrapper({
|
|||
)}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
setActivedEntry(entry.id)
|
||||
setActiveEntry(entry.id)
|
||||
}}
|
||||
onContextMenu={(e) => {
|
||||
e.preventDefault()
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { parseHtml } from "@renderer/lib/parse-html"
|
||||
import { ActivedEntry } from "@renderer/lib/types"
|
||||
import { ActiveEntry } from "@renderer/lib/types"
|
||||
import { useEffect, useState } from "react"
|
||||
import { m } from "framer-motion"
|
||||
import { EntryShare } from "./share"
|
||||
import { useEntry } from "@renderer/lib/queries/entries"
|
||||
|
||||
export function EntryContent({ entryId }: { entryId: ActivedEntry }) {
|
||||
export function EntryContent({ entryId }: { entryId: ActiveEntry }) {
|
||||
const entry = useEntry({
|
||||
id: entryId,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -25,12 +25,7 @@ export function FeedCategory({
|
|||
view?: number
|
||||
expansion: boolean
|
||||
}) {
|
||||
const {
|
||||
activeList,
|
||||
setActiveEntry: setActivedEntry,
|
||||
setActiveList,
|
||||
activeEntry,
|
||||
} = useMainLayoutContext()
|
||||
const { activeList, setActiveList } = useMainLayoutContext()
|
||||
|
||||
const [open, setOpen] = useState(!data.name)
|
||||
const [dialogOpen, setDialogOpen] = useState(false)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export function FeedList({
|
|||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
view !== undefined &&
|
||||
setActiveList({
|
||||
setActiveList?.({
|
||||
level: levels.view,
|
||||
id: view,
|
||||
name: views[view].name,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import type { ActiveList, ActivedEntry } from "@renderer/lib/types"
|
||||
import type { ActiveList, ActiveEntry } from "@renderer/lib/types"
|
||||
import { Outlet, useOutletContext } from "react-router-dom"
|
||||
|
||||
export interface MainLayoutContextType {
|
||||
activeList: ActiveList
|
||||
setActiveEntry: (value: ActivedEntry) => void
|
||||
setActiveEntry: (value: ActiveEntry) => void
|
||||
|
||||
activeEntry: ActivedEntry
|
||||
setActiveList: (value: ActiveList) => void
|
||||
activeEntry: ActiveEntry
|
||||
setActiveList: ((value: ActiveList) => void) | undefined
|
||||
}
|
||||
|
||||
export const useMainLayoutContext = () =>
|
||||
|
|
|
|||
|
|
@ -72,4 +72,4 @@ export type DataResponse<T> = {
|
|||
data?: T
|
||||
}
|
||||
|
||||
export type ActivedEntry = string | null
|
||||
export type ActiveEntry = string | null
|
||||
|
|
|
|||
|
|
@ -8,13 +8,9 @@ import { useEffect } from "react"
|
|||
const wideMode = [1, 2, 3, 4]
|
||||
|
||||
export function Component() {
|
||||
const {
|
||||
activeList,
|
||||
activeEntry,
|
||||
setActiveEntry: setActivedEntry,
|
||||
} = useMainLayoutContext()
|
||||
const { activeList, activeEntry, setActiveEntry } = useMainLayoutContext()
|
||||
useEffect(() => {
|
||||
setActivedEntry(null)
|
||||
setActiveEntry(null)
|
||||
}, [activeList])
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -5,12 +5,8 @@ import {
|
|||
} from "@renderer/contexts/outlet/main-layout"
|
||||
|
||||
export function Component() {
|
||||
const {
|
||||
activeEntry,
|
||||
activeList,
|
||||
setActiveList,
|
||||
setActiveEntry: setActivedEntry,
|
||||
} = useMainLayoutContext()
|
||||
const { activeEntry, activeList, setActiveList, setActiveEntry } =
|
||||
useMainLayoutContext()
|
||||
return (
|
||||
<div className="flex h-full">
|
||||
<div className="w-64 pt-10 border-r shrink-0 bg-native">
|
||||
|
|
@ -21,7 +17,7 @@ export function Component() {
|
|||
activeList,
|
||||
activeEntry,
|
||||
setActiveList,
|
||||
setActiveEntry: setActivedEntry,
|
||||
setActiveEntry,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ export function Component() {
|
|||
return (
|
||||
<Outlet
|
||||
context={{
|
||||
activedList: null,
|
||||
activedEntry: null,
|
||||
setActivedEntry: () => {},
|
||||
setActivedList: null,
|
||||
activeList: null,
|
||||
activeEntry: null,
|
||||
setActiveEntry: () => {},
|
||||
setActiveList: null,
|
||||
}}
|
||||
/>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { useEffect, useState } from "react"
|
||||
import { ActiveList, ActivedEntry } from "@renderer/lib/types"
|
||||
import { Outlet } from "react-router-dom"
|
||||
import { ActiveList, ActiveEntry } from "@renderer/lib/types"
|
||||
import { useNavigate } from "react-router-dom"
|
||||
import { useSession } from "@hono/auth-js/react"
|
||||
import { MainLayoutOutlet } from "@renderer/contexts/outlet/main-layout"
|
||||
|
|
@ -14,7 +13,7 @@ export function Component() {
|
|||
name: "Articles",
|
||||
view: 0,
|
||||
})
|
||||
const [activeEntry, setActiveEntry] = useState<ActivedEntry>(null)
|
||||
const [activeEntry, setActiveEntry] = useState<ActiveEntry>(null)
|
||||
|
||||
useEffect(() => {
|
||||
setActiveEntry(null)
|
||||
|
|
|
|||
Loading…
Reference in New Issue