+1
-1
@@ -56,6 +56,7 @@
|
||||
"@tanstack/react-query": "5.49.0",
|
||||
"@tanstack/react-query-persist-client": "5.49.0",
|
||||
"@use-gesture/react": "10.3.1",
|
||||
"@yornaath/batshit": "0.10.1",
|
||||
"class-variance-authority": "0.7.0",
|
||||
"click-to-react-component": "1.1.0",
|
||||
"clsx": "2.1.1",
|
||||
@@ -79,7 +80,6 @@
|
||||
"lethargy": "1.0.9",
|
||||
"lodash-es": "4.17.21",
|
||||
"lowdb": "7.0.1",
|
||||
|
||||
"markdown-it": "14.1.0",
|
||||
"markdown-it-container": "4.0.0",
|
||||
"ofetch": "1.3.4",
|
||||
|
||||
Generated
+15
@@ -106,6 +106,9 @@ importers:
|
||||
'@use-gesture/react':
|
||||
specifier: 10.3.1
|
||||
version: 10.3.1(react@18.3.1)
|
||||
'@yornaath/batshit':
|
||||
specifier: 0.10.1
|
||||
version: 0.10.1
|
||||
class-variance-authority:
|
||||
specifier: 0.7.0
|
||||
version: 0.7.0
|
||||
@@ -2235,6 +2238,12 @@ packages:
|
||||
resolution: {integrity: sha512-2WALfTl4xo2SkGCYRt6rDTFfk9R1czmBvUQy12gK2KuRKIpWEhcbbzy8EZXtz/jkRqHX8bFEc6FC1HjX4TUWYw==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
|
||||
'@yornaath/batshit-devtools@1.7.1':
|
||||
resolution: {integrity: sha512-AyttV1Njj5ug+XqEWY1smV45dTWMlWKtj1B8jcFYgBKUFyUlF/qEhD+iP1E5UaRYW6hQRYD9T2WNDwFTrOMWzQ==}
|
||||
|
||||
'@yornaath/batshit@0.10.1':
|
||||
resolution: {integrity: sha512-WGZ1WNoiVN6CLf28O73+6SCf+2lUn4U7TLGM9f4zOad0pn9mdoXIq8cwu3Kpf7N2OTYgWGK4eQPTflwFlduDGA==}
|
||||
|
||||
acorn-jsx@5.3.2:
|
||||
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
|
||||
peerDependencies:
|
||||
@@ -7480,6 +7489,12 @@ snapshots:
|
||||
|
||||
'@xmldom/xmldom@0.8.10': {}
|
||||
|
||||
'@yornaath/batshit-devtools@1.7.1': {}
|
||||
|
||||
'@yornaath/batshit@0.10.1':
|
||||
dependencies:
|
||||
'@yornaath/batshit-devtools': 1.7.1
|
||||
|
||||
acorn-jsx@5.3.2(acorn@8.11.3):
|
||||
dependencies:
|
||||
acorn: 8.11.3
|
||||
|
||||
@@ -7,7 +7,7 @@ const createDefaultSettings = () => ({
|
||||
|
||||
// mark unread
|
||||
scrollMarkUnread: true,
|
||||
|
||||
hoverMarkUnread: true,
|
||||
})
|
||||
export const {
|
||||
useSettingKey: useGeneralSettingKey,
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { apiClient } from "@renderer/lib/api-fetch"
|
||||
import { entryActions } from "@renderer/store/entry"
|
||||
import { create, keyResolver, windowScheduler } from "@yornaath/batshit"
|
||||
|
||||
type EntryId = string
|
||||
type FeedId = string
|
||||
const unread = create({
|
||||
fetcher: async (ids: [FeedId, EntryId][]) => {
|
||||
await apiClient.reads.$post({ json: { entryIds: ids.map((i) => i[1]) } })
|
||||
for (const [feedId, entryId] of ids) {
|
||||
entryActions.markRead(feedId, entryId, true)
|
||||
}
|
||||
return []
|
||||
},
|
||||
resolver: keyResolver("id"),
|
||||
scheduler: windowScheduler(1000),
|
||||
})
|
||||
|
||||
export const batchMarkUnread = unread.fetch
|
||||
@@ -64,6 +64,7 @@ import type { ListRange, VirtuosoHandle, VirtuosoProps } from "react-virtuoso"
|
||||
import { Virtuoso, VirtuosoGrid } from "react-virtuoso"
|
||||
import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
import { batchMarkUnread } from "./helper"
|
||||
import { EntryItem } from "./item"
|
||||
|
||||
const unreadOnlyAtom = atomWithStorage<boolean>(
|
||||
@@ -108,11 +109,8 @@ export function EntryColumn() {
|
||||
}
|
||||
|
||||
if (batchLikeIds.length > 0) {
|
||||
const entryIds = batchLikeIds.map(([, id]) => id)
|
||||
await apiClient.reads.$post({ json: { entryIds } })
|
||||
|
||||
for (const [feedId, id] of batchLikeIds) {
|
||||
entryActions.markRead(feedId, id, true)
|
||||
batchMarkUnread([feedId, id])
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -121,6 +119,7 @@ export function EntryColumn() {
|
||||
),
|
||||
)
|
||||
const scrollMarkUnread = useGeneralSettingKey("scrollMarkUnread")
|
||||
|
||||
const virtuosoOptions = {
|
||||
components: {
|
||||
List: ListContent,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useGeneralSettingKey } from "@renderer/atoms/settings/general"
|
||||
import { useAsRead } from "@renderer/hooks/biz/useAsRead"
|
||||
import { useEntryActions } from "@renderer/hooks/biz/useEntryActions"
|
||||
import { useNavigateEntry } from "@renderer/hooks/biz/useNavigateEntry"
|
||||
@@ -16,6 +17,7 @@ import { memo, useCallback } from "react"
|
||||
import { ReactVirtuosoItemPlaceholder } from "../../components/ui/placeholder"
|
||||
import { ArticleItem } from "./article-item"
|
||||
import { AudioItem } from "./audio-item"
|
||||
import { batchMarkUnread } from "./helper"
|
||||
import { NotificationItem } from "./notification-item"
|
||||
import { PictureItem } from "./picture-item"
|
||||
import { SocialMediaItem } from "./social-media-item"
|
||||
@@ -26,7 +28,13 @@ interface EntryItemProps {
|
||||
entryId: string
|
||||
view?: number
|
||||
}
|
||||
function EntryItemImpl({ entry, view }: { entry: CombinedEntryModel, view?: number }) {
|
||||
function EntryItemImpl({
|
||||
entry,
|
||||
view,
|
||||
}: {
|
||||
entry: CombinedEntryModel
|
||||
view?: number
|
||||
}) {
|
||||
const { items } = useEntryActions({
|
||||
view,
|
||||
entry,
|
||||
@@ -45,10 +53,19 @@ function EntryItemImpl({ entry, view }: { entry: CombinedEntryModel, view?: numb
|
||||
},
|
||||
)
|
||||
|
||||
const isActive = useRouteParamsSelector(({ entryId }) => entryId === entry.entries.id)
|
||||
const isActive = useRouteParamsSelector(
|
||||
({ entryId }) => entryId === entry.entries.id,
|
||||
)
|
||||
|
||||
const asRead = useAsRead(entry)
|
||||
const hoverMarkUnread = useGeneralSettingKey("hoverMarkUnread")
|
||||
|
||||
const handleMouseEnter = useCallback(() => {
|
||||
if (!hoverMarkUnread) return
|
||||
if (asRead) return
|
||||
|
||||
batchMarkUnread([entry.feeds.id, entry.entries.id])
|
||||
}, [asRead, entry.entries.id, entry.feeds.id, hoverMarkUnread])
|
||||
let Item: FC<UniversalItemProps>
|
||||
|
||||
switch (view) {
|
||||
@@ -123,11 +140,13 @@ function EntryItemImpl({ entry, view }: { entry: CombinedEntryModel, view?: numb
|
||||
<div
|
||||
className={cn(
|
||||
"rounded-md bg-theme-background transition-colors",
|
||||
isActive &&
|
||||
"bg-theme-item-active",
|
||||
asRead ? "text-zinc-700 dark:text-neutral-400" : "text-zinc-900 dark:text-neutral-300",
|
||||
isActive && "bg-theme-item-active",
|
||||
asRead ?
|
||||
"text-zinc-700 dark:text-neutral-400" :
|
||||
"text-zinc-900 dark:text-neutral-300",
|
||||
)}
|
||||
onClick={handleClick}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onDoubleClick={handleDoubleClick}
|
||||
onContextMenu={handleContextMenu}
|
||||
>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Checkbox } from "@renderer/components/ui/checkbox"
|
||||
import { Label } from "@renderer/components/ui/label"
|
||||
import { Switch } from "@renderer/components/ui/switch"
|
||||
import { cn } from "@renderer/lib/utils"
|
||||
import { useId } from "react"
|
||||
|
||||
export const SettingCheckbox: Component<{
|
||||
@@ -26,10 +27,12 @@ export const SettingSwitch: Component<{
|
||||
label: string
|
||||
checked: boolean
|
||||
onCheckedChange: (checked: boolean) => void
|
||||
}> = ({ checked, label, onCheckedChange }) => {
|
||||
}> = ({ checked, label, onCheckedChange, className }) => {
|
||||
const id = useId()
|
||||
return (
|
||||
<div className="mb-3 flex items-center justify-between gap-4">
|
||||
<div
|
||||
className={cn("mb-3 flex items-center justify-between gap-4", className)}
|
||||
>
|
||||
<Label htmlFor={id}>{label}</Label>
|
||||
<Switch
|
||||
checked={checked}
|
||||
@@ -42,4 +45,8 @@ export const SettingSwitch: Component<{
|
||||
|
||||
export const SettingDescription: Component<{ children: string }> = ({
|
||||
children,
|
||||
}) => <small className="!mt-2 block w-4/5 text-balance text-[13px] leading-tight text-gray-400 dark:text-neutral-500">{children}</small>
|
||||
}) => (
|
||||
<small className="!mt-0 block w-4/5 text-balance text-[13px] leading-tight text-gray-400 dark:text-neutral-500">
|
||||
{children}
|
||||
</small>
|
||||
)
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { setGeneralSetting, useGeneralSettingValue } from "@renderer/atoms/settings/general"
|
||||
import {
|
||||
setGeneralSetting,
|
||||
useGeneralSettingValue,
|
||||
} from "@renderer/atoms/settings/general"
|
||||
import { tipcClient } from "@renderer/lib/client"
|
||||
import { useCallback, useEffect, useState } from "react"
|
||||
|
||||
@@ -34,6 +37,7 @@ export const SettingGeneral = () => {
|
||||
)}
|
||||
|
||||
<SettingSectionTitle title="Mark read" />
|
||||
|
||||
<SettingSwitch
|
||||
checked={settings.scrollMarkUnread}
|
||||
onCheckedChange={(checked) =>
|
||||
@@ -41,8 +45,19 @@ export const SettingGeneral = () => {
|
||||
label="Mark as read when scrolling"
|
||||
/>
|
||||
<SettingDescription>
|
||||
Automatic marking of articles as read when the item is scrolled up out
|
||||
of the viewport.
|
||||
Automatic marking of feed entry as read when the item is scrolled up
|
||||
out of the viewport.
|
||||
</SettingDescription>
|
||||
|
||||
<SettingSwitch
|
||||
className="mt-6"
|
||||
checked={settings.hoverMarkUnread}
|
||||
onCheckedChange={(checked) =>
|
||||
setGeneralSetting("hoverMarkUnread", checked)}
|
||||
label="Mark as read when hovering"
|
||||
/>
|
||||
<SettingDescription>
|
||||
Automatic marking of feed entry as read when the item is hovered.
|
||||
</SettingDescription>
|
||||
|
||||
<SettingSectionTitle title="Data control" />
|
||||
|
||||
@@ -192,6 +192,7 @@ export const useEntryStore = createZustandStore<EntryState & EntryActions>(
|
||||
read,
|
||||
})
|
||||
},
|
||||
|
||||
markReadByFeedId: (feedId: string) => {
|
||||
const state = get()
|
||||
const entries = state.entries[feedId] || []
|
||||
|
||||
Reference in New Issue
Block a user