From 07e969ff451a6c9adafb4c7fe23444bceb0b18fd Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Thu, 17 Apr 2025 17:21:26 +0800 Subject: [PATCH] refactor: split readability table (#3516) --- .../src/hooks/biz/useEntryActions.tsx | 20 ++--- apps/mobile/src/morph/hono.ts | 6 +- packages/shared/src/hono.ts | 87 +++++++++++++------ 3 files changed, 67 insertions(+), 46 deletions(-) diff --git a/apps/desktop/src/renderer/src/hooks/biz/useEntryActions.tsx b/apps/desktop/src/renderer/src/hooks/biz/useEntryActions.tsx index faaba31c2..5f33139c6 100644 --- a/apps/desktop/src/renderer/src/hooks/biz/useEntryActions.tsx +++ b/apps/desktop/src/renderer/src/hooks/biz/useEntryActions.tsx @@ -21,7 +21,7 @@ import { COMMAND_ID } from "~/modules/command/commands/id" import { useRunCommandFn } from "~/modules/command/hooks/use-command" import type { FollowCommandId } from "~/modules/command/types" import { useToolbarOrderMap } from "~/modules/customize-toolbar/hooks" -import { getEntry, useEntry } from "~/store/entry" +import { useEntry } from "~/store/entry" import { useFeedById } from "~/store/feed" import { useInboxById } from "~/store/inbox" @@ -37,21 +37,11 @@ export const toggleEntryReadability = async ({ id, url }: { id: string; url: str }) try { let data = getReadabilityContent()[id] - if (!data) { - const entry = getEntry(id) - if ( - entry && - "readabilityContent" in entry.entries && - entry.entries.readabilityContent !== null - ) { - data = { content: entry.entries.readabilityContent } - } - if (!data) { - const result = await apiClient.entries.readability.$get({ query: { id } }) - if (result.data) { - data = result.data - } + if (!data) { + const result = await apiClient.entries.readability.$get({ query: { id } }) + if (result.data) { + data = result.data } } diff --git a/apps/mobile/src/morph/hono.ts b/apps/mobile/src/morph/hono.ts index cc6feca9a..48fd5455e 100644 --- a/apps/mobile/src/morph/hono.ts +++ b/apps/mobile/src/morph/hono.ts @@ -108,8 +108,7 @@ class Morph { title: item.entries.title, url: item.entries.url, content: null, - readabilityContent: - "readabilityContent" in item.entries ? item.entries.readabilityContent : null, + readabilityContent: null, description: item.entries.description, guid: item.entries.guid, author: item.entries.author, @@ -164,8 +163,7 @@ class Morph { title: data.entries.title, url: data.entries.url, content: data.entries.content, - readabilityContent: - "readabilityContent" in data.entries ? data.entries.readabilityContent : null, + readabilityContent: null, description: data.entries.description, guid: data.entries.guid, author: data.entries.author, diff --git a/packages/shared/src/hono.ts b/packages/shared/src/hono.ts index 8c0f69c96..c6365760f 100644 --- a/packages/shared/src/hono.ts +++ b/packages/shared/src/hono.ts @@ -2193,23 +2193,6 @@ declare const entries: drizzle_orm_pg_core.PgTableWithColumns<{ identity: undefined; generated: undefined; }, {}, {}>; - readabilityContent: drizzle_orm_pg_core.PgColumn<{ - name: "readability_content"; - tableName: "entries"; - dataType: "string"; - columnType: "PgText"; - data: string; - driverParam: string; - notNull: false; - hasDefault: false; - isPrimaryKey: false; - isAutoincrement: false; - hasRuntimeDefault: false; - enumValues: [string, ...string[]]; - baseColumn: never; - identity: undefined; - generated: undefined; - }, {}, {}>; }; dialect: "pg"; }>; @@ -2443,7 +2426,6 @@ declare const entriesOpenAPISchema: z.ZodObject>; language: z.ZodNullable; feedId: z.ZodString; - readabilityContent: z.ZodNullable; }, "media" | "attachments" | "extra">, { attachments: z.ZodNullable; + entryId: drizzle_orm_pg_core.PgColumn<{ + name: "entry_id"; + tableName: "readabilities"; + dataType: "string"; + columnType: "PgText"; + data: string; + driverParam: string; + notNull: true; + hasDefault: false; + isPrimaryKey: false; + isAutoincrement: false; + hasRuntimeDefault: false; + enumValues: [string, ...string[]]; + baseColumn: never; + identity: undefined; + generated: undefined; + }, {}, {}>; + content: drizzle_orm_pg_core.PgColumn<{ + name: "content"; + tableName: "readabilities"; + dataType: "string"; + columnType: "PgText"; + data: string; + driverParam: string; + notNull: false; + hasDefault: false; + isPrimaryKey: false; + isAutoincrement: false; + hasRuntimeDefault: false; + enumValues: [string, ...string[]]; + baseColumn: never; + identity: undefined; + generated: undefined; + }, {}, {}>; + }; + dialect: "pg"; +}>; + declare const rsshub: drizzle_orm_pg_core.PgTableWithColumns<{ name: "rsshub"; schema: undefined; @@ -13394,7 +13433,6 @@ declare const _routes: hono_hono_base.HonoBase, "/">; type AppType = typeof _routes; -export { type ActionsModel, type AirdropActivity, type AppType, type AttachmentsModel, type AuthSession, type AuthUser, CommonEntryFields, type ConditionItem, type DetailModel, type EntriesModel, type ExtraModel, type FeedModel, type ListModel, type MediaModel, type MessagingData, MessagingType, type SettingsModel, type UrlReadsModel, account, achievements, achievementsOpenAPISchema, actions, actionsItemOpenAPISchema, actionsOpenAPISchema, actionsRelations, activityEnum, airdrops, airdropsOpenAPISchema, attachmentsZodSchema, authPlugins, boosts, captcha, collections, collectionsOpenAPISchema, collectionsRelations, detailModelSchema, entries, entriesOpenAPISchema, entriesRelations, extraZodSchema, feedPowerTokens, feedPowerTokensOpenAPISchema, feedPowerTokensRelations, feeds, feedsOpenAPISchema, feedsRelations, inboxHandleSchema, inboxes, inboxesEntries, inboxesEntriesInsertOpenAPISchema, type inboxesEntriesModel, inboxesEntriesOpenAPISchema, inboxesEntriesRelations, inboxesOpenAPISchema, inboxesRelations, invitations, invitationsOpenAPISchema, invitationsRelations, languageSchema, levels, levelsOpenAPISchema, levelsRelations, lists, listsOpenAPISchema, listsRelations, listsSubscriptions, listsSubscriptionsOpenAPISchema, listsSubscriptionsRelations, lower, mediaZodSchema, messaging, messagingOpenAPISchema, messagingRelations, rsshub, rsshubOpenAPISchema, rsshubPurchase, rsshubUsage, rsshubUsageOpenAPISchema, rsshubUsageRelations, session, settings, subscriptions, subscriptionsOpenAPISchema, subscriptionsRelations, timeline, timelineOpenAPISchema, timelineRelations, transactionType, transactions, transactionsOpenAPISchema, transactionsRelations, twoFactor, uploads, urlReads, urlReadsOpenAPISchema, user, users, usersOpenApiSchema, usersRelations, verification, wallets, walletsOpenAPISchema, walletsRelations }; +export { type ActionsModel, type AirdropActivity, type AppType, type AttachmentsModel, type AuthSession, type AuthUser, CommonEntryFields, type ConditionItem, type DetailModel, type EntriesModel, type ExtraModel, type FeedModel, type ListModel, type MediaModel, type MessagingData, MessagingType, type SettingsModel, type UrlReadsModel, account, achievements, achievementsOpenAPISchema, actions, actionsItemOpenAPISchema, actionsOpenAPISchema, actionsRelations, activityEnum, airdrops, airdropsOpenAPISchema, attachmentsZodSchema, authPlugins, boosts, captcha, collections, collectionsOpenAPISchema, collectionsRelations, detailModelSchema, entries, entriesOpenAPISchema, entriesRelations, extraZodSchema, feedPowerTokens, feedPowerTokensOpenAPISchema, feedPowerTokensRelations, feeds, feedsOpenAPISchema, feedsRelations, inboxHandleSchema, inboxes, inboxesEntries, inboxesEntriesInsertOpenAPISchema, type inboxesEntriesModel, inboxesEntriesOpenAPISchema, inboxesEntriesRelations, inboxesOpenAPISchema, inboxesRelations, invitations, invitationsOpenAPISchema, invitationsRelations, languageSchema, levels, levelsOpenAPISchema, levelsRelations, lists, listsOpenAPISchema, listsRelations, listsSubscriptions, listsSubscriptionsOpenAPISchema, listsSubscriptionsRelations, lower, mediaZodSchema, messaging, messagingOpenAPISchema, messagingRelations, readabilities, rsshub, rsshubOpenAPISchema, rsshubPurchase, rsshubUsage, rsshubUsageOpenAPISchema, rsshubUsageRelations, session, settings, subscriptions, subscriptionsOpenAPISchema, subscriptionsRelations, timeline, timelineOpenAPISchema, timelineRelations, transactionType, transactions, transactionsOpenAPISchema, transactionsRelations, twoFactor, uploads, urlReads, urlReadsOpenAPISchema, user, users, usersOpenApiSchema, usersRelations, verification, wallets, walletsOpenAPISchema, walletsRelations };