diff --git a/src/renderer/src/components/entry-content/share.tsx b/src/renderer/src/components/entry-content/share.tsx
index d6643bd23..036d8b4d9 100644
--- a/src/renderer/src/components/entry-content/share.tsx
+++ b/src/renderer/src/components/entry-content/share.tsx
@@ -6,20 +6,20 @@ import {
TooltipTrigger,
} from "@renderer/components/ui/tooltip"
import { useEntryActions } from "@renderer/hooks/useEntryActions"
-import type { EntriesResponse } from "@renderer/lib/types"
+import type { EntryResponse } from "@renderer/lib/types"
export function EntryShare({
view,
entry,
}: {
view: number
- entry?: EntriesResponse[number]
+ entry?: EntryResponse
}) {
const { items } = useEntryActions({
view,
entry,
})
- if (!entry?.url) return null
+ if (!entry?.entries.url) return null
return (
diff --git a/src/renderer/src/components/follow/form.tsx b/src/renderer/src/components/follow/form.tsx
index ba9dcfde4..0e97fb85c 100644
--- a/src/renderer/src/components/follow/form.tsx
+++ b/src/renderer/src/components/follow/form.tsx
@@ -16,7 +16,7 @@ import {
} from "@renderer/components/ui/form"
import { Image } from "@renderer/components/ui/image"
import { Input } from "@renderer/components/ui/input"
-import type { EntriesResponse, FeedResponse } from "@renderer/lib/types"
+import type { FeedResponse } from "@renderer/lib/types"
import { apiFetch } from "@renderer/queries/api-fetch"
import { useMutation } from "@tanstack/react-query"
import { useEffect } from "react"
@@ -67,7 +67,7 @@ export function FollowForm({ type }: { type: string }) {
data: {
feed: FeedResponse
docs?: string
- entries?: Partial
+ entries?: Partial
isSubscribed?: boolean
subscriptionCount?: number
}[]
diff --git a/src/renderer/src/hono.ts b/src/renderer/src/hono.ts
index 76095499b..a6f483196 100644
--- a/src/renderer/src/hono.ts
+++ b/src/renderer/src/hono.ts
@@ -3,6 +3,60 @@ import * as hono_utils_http_status from 'hono/utils/http-status';
import * as hono from 'hono';
declare const routes: hono_hono_base.HonoBase {
const checkEagle = useQuery({
queryKey: ["check-eagle"],
- enabled: !!entry?.url && !!view,
+ enabled: !!entry?.entries.url && !!view,
queryFn: async () => {
try {
await ofetch("http://localhost:41595")
@@ -31,7 +31,7 @@ export const useEntryActions = ({
})
const updateEntry = useUpdateEntry({
- entryId: entry?.id,
+ entryId: entry?.entries.id,
})
const collect = useMutation({
@@ -39,12 +39,14 @@ export const useEntryActions = ({
apiFetch("/collections", {
method: "POST",
body: {
- entryId: entry?.id,
+ entryId: entry?.entries.id,
},
}),
onSuccess: () => {
updateEntry({
- collected: true,
+ collections: {
+ createdAt: new Date().toISOString(),
+ },
})
toast({
@@ -58,12 +60,12 @@ export const useEntryActions = ({
apiFetch("/collections", {
method: "DELETE",
body: {
- entryId: entry?.id,
+ entryId: entry?.entries.id,
},
}),
onSuccess: () => {
updateEntry({
- collected: false,
+ collections: undefined,
})
toast({
@@ -77,7 +79,7 @@ export const useEntryActions = ({
apiFetch("/reads", {
method: "POST",
body: {
- entryId: entry?.id,
+ entryId: entry?.entries.id,
},
}),
onSuccess: () => {
@@ -91,7 +93,7 @@ export const useEntryActions = ({
apiFetch("/reads", {
method: "DELETE",
body: {
- entryId: entry?.id,
+ entryId: entry?.entries.id,
},
}),
onSuccess: () => {
@@ -103,14 +105,14 @@ export const useEntryActions = ({
const { toast } = useToast()
- if (!entry?.url || view === undefined) return { items: [] }
+ if (!entry?.entries.url || view === undefined) return { items: [] }
const items = [
[
{
name: "Collect",
className: "i-mingcute-star-line",
- disabled: !!entry.collected,
+ disabled: !!entry.collections,
onClick: () => {
collect.mutate()
},
@@ -118,7 +120,7 @@ export const useEntryActions = ({
{
name: "Uncollect",
className: "i-mingcute-star-fill",
- disabled: !entry.collected,
+ disabled: !entry.collections,
onClick: () => {
uncollect.mutate()
},
@@ -127,8 +129,8 @@ export const useEntryActions = ({
name: "Copy Link",
className: "i-mingcute-link-line",
onClick: () => {
- if (!entry.url) return
- navigator.clipboard.writeText(entry.url)
+ if (!entry.entries.url) return
+ navigator.clipboard.writeText(entry.entries.url)
toast({
duration: 1000,
description: "Link copied to clipboard.",
@@ -139,8 +141,8 @@ export const useEntryActions = ({
name: "Open in Browser",
className: "i-mingcute-world-2-line",
onClick: () => {
- if (!entry.url) return
- window.open(entry.url, "_blank")
+ if (!entry.entries.url) return
+ window.open(entry.entries.url, "_blank")
},
},
{
@@ -148,12 +150,12 @@ export const useEntryActions = ({
icon: "/eagle.svg",
disabled:
(checkEagle.isLoading ? true : !checkEagle.data) ||
- !entry.images?.length,
+ !entry.entries.images?.length,
onClick: async () => {
- if (!entry.url || !entry.images?.length) return
+ if (!entry.entries.url || !entry.entries.images?.length) return
const response = await client?.saveToEagle({
- url: entry.url,
- images: entry.images,
+ url: entry.entries.url,
+ images: entry.entries.images,
})
if (response?.status === "success") {
toast({
@@ -172,8 +174,8 @@ export const useEntryActions = ({
name: "Share",
className: "i-mingcute-share-2-line",
onClick: () => {
- if (!entry.url) return
- client?.showShareMenu(entry.url)
+ if (!entry.entries.url) return
+ client?.showShareMenu(entry.entries.url)
},
},
{
diff --git a/src/renderer/src/hooks/useUpdateEntry.tsx b/src/renderer/src/hooks/useUpdateEntry.tsx
index 3c021fa55..71115d1c3 100644
--- a/src/renderer/src/hooks/useUpdateEntry.tsx
+++ b/src/renderer/src/hooks/useUpdateEntry.tsx
@@ -1,4 +1,4 @@
-import type { EntriesResponse, ListResponse } from "@renderer/lib/types"
+import type { TimelineResponse, ListResponse } from "@renderer/lib/types"
import { Queries } from "@renderer/queries"
import type { InfiniteData, QueryKey } from "@tanstack/react-query"
import { useQueryClient } from "@tanstack/react-query"
@@ -7,7 +7,7 @@ import { produce } from "immer"
export const useUpdateEntry = ({ entryId }: { entryId?: string }) => {
const queryClient = useQueryClient()
- const updateEntry = (changed: Partial) => {
+ const updateEntry = (changed: Partial) => {
const query = Queries.entries.byId(entryId)
query.setData((draft) => {
@@ -19,12 +19,12 @@ export const useUpdateEntry = ({ entryId }: { entryId?: string }) => {
queryKey: ["entries"],
})
entriesData.forEach(([key, data]: [QueryKey, unknown]) => {
- const assertData = data as InfiniteData>
+ const assertData = data as InfiniteData>
const finaldata = produce(assertData, (assertData) => {
const list = assertData?.pages?.[0]?.data
if (list) {
for (const item of list) {
- if (item.id === entryId) {
+ if (item.entries.id === entryId) {
for (const [key, value] of Object.entries(changed)) {
item[key] = value
}
diff --git a/src/renderer/src/lib/types.ts b/src/renderer/src/lib/types.ts
index 8e6c28173..78e6a9381 100644
--- a/src/renderer/src/lib/types.ts
+++ b/src/renderer/src/lib/types.ts
@@ -20,39 +20,22 @@ export type SubscriptionResponse = Array<
>[number] & { unread?: number }
>
-// export type EntriesResponse = {
-// author?: string
-// category?: string[]
-// changedAt: string
-// content?: string
-// description?: string
-// enclosure?: {
-// url: string
-// type?: string
-// length?: number
-// title?: string
-// }
-// feedId: string
-// guid: string
-// id: string
-// images?: string[]
-// publishedAt: string
-// readingTime?: number
-// title?: string
-// url?: string
+export type EntryResponse = Exclude<
+ Extract<
+ InferResponseType,
+ { code: 0 }
+ >["data"],
+ undefined
+>
-// feeds: FeedResponse
-// collected: boolean
-// read: boolean
-// }[]
-export type EntriesResponse = Array<
+export type TimelineResponse = Array<
Exclude<
Extract<
- InferResponseType,
+ InferResponseType,
{ code: 0 }
>["data"],
undefined
- >
+ >[number]
>
export type ListResponse = {
diff --git a/src/renderer/src/queries/entries.ts b/src/renderer/src/queries/entries.ts
index 13366b019..00384cf87 100644
--- a/src/renderer/src/queries/entries.ts
+++ b/src/renderer/src/queries/entries.ts
@@ -4,8 +4,7 @@ import {
import { useBizInfiniteQuery } from "@renderer/hooks/useBizQuery"
import { levels } from "@renderer/lib/constants"
import { defineQuery } from "@renderer/lib/defineQuery"
-import type { EntriesResponse, ListResponse } from "@renderer/lib/types"
-import { apiClient, apiFetch } from "@renderer/queries/api-fetch"
+import { apiClient } from "@renderer/queries/api-fetch"
export const entries = {
entries: ({
@@ -18,11 +17,9 @@ export const entries = {
view?: number
}) =>
defineQuery(
- ["entries", level, id],
+ ["entries", level, id, view],
async ({ pageParam }) => {
const params: {
- category?: string
- view?: number
feedId?: string
feedIdList?: string[]
} = {}
@@ -31,14 +28,14 @@ export const entries = {
} else if (level === levels.feed) {
params.feedId = `${id}`
}
- return await apiFetch>("/entries", {
- method: "POST",
- body: {
- offset: pageParam,
+ const res = await apiClient.timeline.$post({
+ json: {
+ offset: pageParam as number | undefined,
view,
...params,
},
})
+ return await res.json()
},
{
rootKey: ["entries"],
@@ -51,7 +48,11 @@ export const entries = {
if (!id) {
throw new UnprocessableEntityError("id is required")
}
- const res = await apiClient.entries.$get({ query: { id } })
+ const res = await apiClient.entries.$get({
+ query: {
+ id,
+ },
+ })
const json = await res.json()
return json.data