feat: tips for new entries
This commit is contained in:
parent
78b2c99046
commit
86ed9c7410
|
|
@ -141,7 +141,7 @@
|
|||
"@vercel/ncc": "0.38.1",
|
||||
"@vitejs/plugin-react": "^4.3.1",
|
||||
"drizzle-orm": "0.32.0",
|
||||
"electron": "^31.0.2",
|
||||
"electron": "^30.1.2",
|
||||
"electron-devtools-installer": "3.2.0",
|
||||
"electron-vite": "^2.3.0",
|
||||
"eslint": "^9.7.0",
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@ importers:
|
|||
dependencies:
|
||||
'@egoist/tipc':
|
||||
specifier: 0.3.1
|
||||
version: 0.3.1(patch_hash=xlivt3m5hothgltzlhgcjx3uca)(electron@31.2.1)(react@18.3.1)
|
||||
version: 0.3.1(patch_hash=xlivt3m5hothgltzlhgcjx3uca)(electron@30.1.2)(react@18.3.1)
|
||||
'@electron-toolkit/preload':
|
||||
specifier: ^3.0.1
|
||||
version: 3.0.1(electron@31.2.1)
|
||||
version: 3.0.1(electron@30.1.2)
|
||||
'@electron-toolkit/utils':
|
||||
specifier: ^3.0.0
|
||||
version: 3.0.0(electron@31.2.1)
|
||||
version: 3.0.0(electron@30.1.2)
|
||||
'@fontsource/sn-pro':
|
||||
specifier: 5.0.1
|
||||
version: 5.0.1
|
||||
|
|
@ -348,8 +348,8 @@ importers:
|
|||
specifier: 0.32.0
|
||||
version: 0.32.0(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(@types/react@18.3.3)(react@18.3.1)
|
||||
electron:
|
||||
specifier: ^31.0.2
|
||||
version: 31.2.1
|
||||
specifier: ^30.1.2
|
||||
version: 30.1.2
|
||||
electron-devtools-installer:
|
||||
specifier: 3.2.0
|
||||
version: 3.2.0
|
||||
|
|
@ -3664,8 +3664,8 @@ packages:
|
|||
resolution: {integrity: sha512-oM8BW3a8NEqG0XW+Vx3xywhk0DyDV4T0jT0zZfWt0IczNT3jHAAvQWBorF8osQDplSsCyXXyxrsrQ8cY0Slb/A==}
|
||||
engines: {node: '>=8.0.0'}
|
||||
|
||||
electron@31.2.1:
|
||||
resolution: {integrity: sha512-g3CLKjl4yuXt6VWm/KpgEjYYhFiCl19RgUn8lOC8zV/56ZXAS3+mqV4wWzicE/7vSYXs6GRO7vkYRwrwhX3Gaw==}
|
||||
electron@30.1.2:
|
||||
resolution: {integrity: sha512-A5CFGwbA+HSXnzwjc8fP2GIezBcAb0uN/VbNGLOW8DHOYn07rvJ/1bAJECHUUzt5zbfohveG3hpMQiYpbktuDw==}
|
||||
engines: {node: '>= 12.20.55'}
|
||||
hasBin: true
|
||||
|
||||
|
|
@ -7212,9 +7212,9 @@ snapshots:
|
|||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@egoist/tipc@0.3.1(patch_hash=xlivt3m5hothgltzlhgcjx3uca)(electron@31.2.1)(react@18.3.1)':
|
||||
'@egoist/tipc@0.3.1(patch_hash=xlivt3m5hothgltzlhgcjx3uca)(electron@30.1.2)(react@18.3.1)':
|
||||
dependencies:
|
||||
electron: 31.2.1
|
||||
electron: 30.1.2
|
||||
optionalDependencies:
|
||||
'@tanstack/react-query': 5.51.4(react@18.3.1)
|
||||
transitivePeerDependencies:
|
||||
|
|
@ -7439,17 +7439,17 @@ snapshots:
|
|||
dependencies:
|
||||
chrome-trace-event: 1.0.4
|
||||
|
||||
'@electron-toolkit/preload@3.0.1(electron@31.2.1)':
|
||||
'@electron-toolkit/preload@3.0.1(electron@30.1.2)':
|
||||
dependencies:
|
||||
electron: 31.2.1
|
||||
electron: 30.1.2
|
||||
|
||||
'@electron-toolkit/tsconfig@1.0.1(@types/node@20.14.11)':
|
||||
dependencies:
|
||||
'@types/node': 20.14.11
|
||||
|
||||
'@electron-toolkit/utils@3.0.0(electron@31.2.1)':
|
||||
'@electron-toolkit/utils@3.0.0(electron@30.1.2)':
|
||||
dependencies:
|
||||
electron: 31.2.1
|
||||
electron: 30.1.2
|
||||
|
||||
'@electron/asar@3.2.10':
|
||||
dependencies:
|
||||
|
|
@ -10703,7 +10703,7 @@ snapshots:
|
|||
- supports-color
|
||||
optional: true
|
||||
|
||||
electron@31.2.1:
|
||||
electron@30.1.2:
|
||||
dependencies:
|
||||
'@electron/get': 2.0.3
|
||||
'@types/node': 20.14.11
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ import {
|
|||
useRouteParamsSelector,
|
||||
useRouteParms,
|
||||
} from "@renderer/hooks/biz/useRouteParams"
|
||||
import { useAuthQuery } from "@renderer/hooks/common"
|
||||
import { views } from "@renderer/lib/constants"
|
||||
import { shortcuts } from "@renderer/lib/shortcuts"
|
||||
import { useEntries } from "@renderer/queries/entries"
|
||||
import { entries, useEntries } from "@renderer/queries/entries"
|
||||
import { entryActions, useEntryIdsByFeedIdOrView } from "@renderer/store/entry"
|
||||
import { useFolderFeedsByFeedId } from "@renderer/store/subscription"
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
||||
|
|
@ -69,11 +70,36 @@ export const useEntriesByView = ({
|
|||
|
||||
const folderIds = useFolderFeedsByFeedId(feedId)
|
||||
|
||||
const query = useEntries({
|
||||
const entriesOptions = {
|
||||
id: folderIds?.join(",") || feedId,
|
||||
view,
|
||||
...(unreadOnly === true && { read: false }),
|
||||
}
|
||||
const query = useEntries(entriesOptions)
|
||||
|
||||
const [firstId, setFirstId] = useState<string>()
|
||||
const [hasUpdate, setHasUpdate] = useState(false)
|
||||
const firstEntry = useAuthQuery(entries.entries({
|
||||
...entriesOptions,
|
||||
limit: 1,
|
||||
}), {
|
||||
refetchInterval: 1000 * 10,
|
||||
enabled: !hasUpdate,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (query.data?.pages?.[0]?.data?.[0].entries.id) {
|
||||
setFirstId(query.data.pages[0].data[0].entries.id)
|
||||
setHasUpdate(false)
|
||||
}
|
||||
}, [query.data?.pages?.[0]?.data?.[0].entries.id])
|
||||
|
||||
useEffect(() => {
|
||||
if (!hasUpdate && firstId && firstEntry.data?.data?.[0].entries.id && firstId !== firstEntry.data.data[0].entries.id) {
|
||||
setHasUpdate(true)
|
||||
}
|
||||
}, [firstEntry.data?.data?.[0].entries.id])
|
||||
|
||||
const remoteEntryIds = useMemo(
|
||||
() =>
|
||||
query.data?.pages
|
||||
|
|
@ -144,6 +170,7 @@ export const useEntriesByView = ({
|
|||
return {
|
||||
...query,
|
||||
|
||||
hasUpdate,
|
||||
refetch: useCallback(() => {
|
||||
query.refetch()
|
||||
}, [query]),
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ export function EntryColumn() {
|
|||
refetch={entries.refetch}
|
||||
isRefreshing={entries.isFetching && !entries.isFetchingNextPage}
|
||||
totalCount={virtuosoOptions.totalCount}
|
||||
hasUpdate={entries.hasUpdate}
|
||||
/>
|
||||
<m.div
|
||||
key={`${routeFeedId}-${view}`}
|
||||
|
|
@ -173,7 +174,8 @@ const ListHeader: FC<{
|
|||
totalCount: number
|
||||
refetch: () => void
|
||||
isRefreshing: boolean
|
||||
}> = ({ totalCount, refetch, isRefreshing }) => {
|
||||
hasUpdate: boolean
|
||||
}> = ({ totalCount, refetch, isRefreshing, hasUpdate }) => {
|
||||
const routerParams = useRouteParms()
|
||||
|
||||
const unreadOnly = useGeneralSettingKey("unreadOnly")
|
||||
|
|
@ -285,7 +287,7 @@ const ListHeader: FC<{
|
|||
) :
|
||||
(
|
||||
<ActionButton
|
||||
tooltip="Refetch"
|
||||
tooltip={hasUpdate ? "New entries available" : "Refetch"}
|
||||
onClick={() => {
|
||||
refetch()
|
||||
}}
|
||||
|
|
@ -294,6 +296,7 @@ const ListHeader: FC<{
|
|||
className={cn(
|
||||
"i-mgc-refresh-2-cute-re",
|
||||
isRefreshing && "animate-spin",
|
||||
hasUpdate && "text-theme-accent",
|
||||
)}
|
||||
/>
|
||||
</ActionButton>
|
||||
|
|
|
|||
|
|
@ -8,19 +8,21 @@ export const entries = {
|
|||
id,
|
||||
view,
|
||||
read,
|
||||
limit,
|
||||
}: {
|
||||
id?: number | string
|
||||
view?: number
|
||||
read?: boolean
|
||||
limit?: number
|
||||
}) =>
|
||||
defineQuery(
|
||||
["entries", id, view, read],
|
||||
["entries", id, view, read, limit],
|
||||
async ({ pageParam }) =>
|
||||
entryActions.fetchEntries({
|
||||
id,
|
||||
view,
|
||||
read,
|
||||
|
||||
limit,
|
||||
pageParam: pageParam as string,
|
||||
}),
|
||||
{
|
||||
|
|
@ -67,7 +69,6 @@ export const useEntries = ({
|
|||
return lastPage.data.at(-1)!.entries.publishedAt
|
||||
},
|
||||
initialPageParam: undefined,
|
||||
refetchInterval: 1000 * 60 * 10,
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnReconnect: false,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -79,13 +79,20 @@ class EntryActions {
|
|||
id,
|
||||
view,
|
||||
read,
|
||||
|
||||
limit,
|
||||
pageParam,
|
||||
}: {
|
||||
id?: number | string
|
||||
view?: number
|
||||
read?: boolean
|
||||
limit?: number
|
||||
pageParam?: string
|
||||
}) {
|
||||
const data = await apiClient.entries.$post({
|
||||
json: {
|
||||
publishedAfter: pageParam as string,
|
||||
publishedAfter: pageParam,
|
||||
read,
|
||||
limit,
|
||||
// withContent: true,
|
||||
...getEntriesParams({
|
||||
id,
|
||||
|
|
|
|||
Loading…
Reference in New Issue