diff --git a/apps/web/components/integrations-view.tsx b/apps/web/components/integrations-view.tsx index 047dd6e1..fe68d153 100644 --- a/apps/web/components/integrations-view.tsx +++ b/apps/web/components/integrations-view.tsx @@ -1059,6 +1059,29 @@ function ConnectionsCountPill({ count }: { count: number }) { ) } +function ImportedPill({ + lastImportedAt, +}: { + lastImportedAt: string | number | Date | null +}) { + return ( + + + Imported + {lastImportedAt && ( + + ยท {formatRelativeTime(lastImportedAt)} + + )} + + ) +} + const CONNECTOR_META: Record< ConnectorProvider, { name: string; icon: ReactNode; documentLabel: string } @@ -2463,6 +2486,35 @@ export function IntegrationsView({ staleTime: 30 * 1000, }) + const { data: xBookmarksImport } = useQuery({ + queryKey: ["x-bookmarks-import-status"], + queryFn: async () => { + const response = await $fetch("@post/documents/documents", { + body: { + page: 1, + limit: 1, + sort: "createdAt", + order: "desc", + categories: ["tweet"], + }, + disableValidation: true, + }) + if (response.error) + throw new Error( + response.error?.message || "Failed to load X bookmarks status", + ) + return { + count: response.data?.pagination?.totalItems ?? 0, + lastImportedAt: response.data?.documents?.[0]?.createdAt ?? null, + } + }, + staleTime: 5 * 60 * 1000, + enabled: !publicMode, + }) + + const tweetCount = xBookmarksImport?.count ?? 0 + const lastTweetImportAt = xBookmarksImport?.lastImportedAt ?? null + const keyPrefix = useCallback((key: ListedApiKey): string | null => { return key.start ?? (key.name?.startsWith("sm_") ? key.name : null) }, []) @@ -2675,9 +2727,12 @@ export function IntegrationsView({ if (item.kind === "connector") { return connectionsByProvider[item.provider].length > 0 } + if (item.kind === "import") { + return tweetCount > 0 + } return false }, - [activePluginById, connectionsByProvider, publicMode], + [activePluginById, connectionsByProvider, publicMode, tweetCount], ) const counts = useMemo>( @@ -3286,6 +3341,10 @@ export function IntegrationsView({ if (count <= 0) return null return } + case "import": { + if (tweetCount <= 0) return null + return + } default: return null }