feat(mobile): cache image info (#2899)

This commit is contained in:
Stephen Zhou
2025-02-27 11:10:32 +08:00
committed by GitHub
parent bd12076b21
commit a67d84b7d7
15 changed files with 825 additions and 75 deletions
+8 -1
View File
@@ -1,7 +1,8 @@
import type { FeedViewType } from "@follow/constants"
import { sql } from "drizzle-orm"
import { integer, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core"
import type { AttachmentsModel, ExtraModel, MediaModel } from "./types"
import type { AttachmentsModel, ExtraModel, ImageColorsResult, MediaModel } from "./types"
export const feedsTable = sqliteTable("feeds", {
id: text("id").primaryKey(),
@@ -104,3 +105,9 @@ export const summariesTable = sqliteTable(
unq: uniqueIndex("unq").on(table.entryId, table.language),
}),
)
export const imagesTable = sqliteTable("images", (t) => ({
url: t.text("url").notNull().primaryKey(),
colors: t.text("colors", { mode: "json" }).$type<ImageColorsResult>().notNull(),
createdAt: t.integer("created_at", { mode: "timestamp" }).default(sql`(CURRENT_TIMESTAMP)`),
}))
@@ -2,6 +2,7 @@ import type {
collectionsTable,
entriesTable,
feedsTable,
imagesTable,
inboxesTable,
listsTable,
subscriptionsTable,
@@ -27,6 +28,9 @@ export type EntrySchema = typeof entriesTable.$inferSelect
export type CollectionSchema = typeof collectionsTable.$inferSelect
export type SummarySchema = typeof summariesTable.$inferSelect
export type ImageSchema = typeof imagesTable.$inferInsert
export type MediaModel = {
url: string
type: "photo" | "video"
@@ -51,3 +55,5 @@ export type ExtraModel = {
content_html?: string
}[]
}
export { ImageColorsResult } from "react-native-image-colors"