birdclaw 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +10 -8
- package/bin/birdclaw.mjs +4 -66
- package/dist/cli/birdclaw.js +28165 -0
- package/dist/client/assets/AvatarChip-DLoqM5xD.js +1 -0
- package/dist/client/assets/ProfilePreview-BejAuYsJ.js +1 -0
- package/dist/client/assets/SavedTimelineView-BIS7HKpp.js +1 -0
- package/dist/client/assets/SmartTimestamp-BR0-9se2.js +1 -0
- package/dist/client/assets/TimelineRouteFrame-CyGPj0eM.js +1 -0
- package/dist/client/assets/blocks-7UDKQp8H.js +1 -0
- package/dist/client/assets/bookmarks-CbBkMvXk.js +1 -0
- package/dist/client/assets/chunk-C0phanGV.js +1 -0
- package/dist/client/assets/circle-check-C_Vq3ElD.js +1 -0
- package/dist/client/assets/client-stream-contracts-ys3XhWG4.js +5 -0
- package/dist/client/assets/createLucideIcon-JV8isFFR.js +1 -0
- package/dist/client/assets/data-sources-Cm2bpNvg.js +1 -0
- package/dist/client/assets/discuss-DTjaOugw.js +1 -0
- package/dist/client/assets/dms-CGd6Eogq.js +1 -0
- package/dist/client/assets/inbox-BHlGuOy2.js +1 -0
- package/dist/client/assets/index-CEIG7S6s.js +31 -0
- package/dist/client/assets/index-bpFrQ5yG.css +1 -0
- package/dist/client/assets/likes-cLrcAQem.js +1 -0
- package/dist/client/assets/links-CM9QO1LC.js +1 -0
- package/dist/client/assets/mapbox-BxTlqXt9.js +2 -0
- package/dist/client/assets/mapbox-gl-dgf_hX3a.js +3215 -0
- package/dist/client/assets/mentions-CxKCgzIf.js +1 -0
- package/dist/client/assets/network-map-B5a3whqj.js +2 -0
- package/dist/client/assets/profile-analyze-CRtNEwlb.js +1 -0
- package/dist/client/assets/profile-hydration-client-YEtJsNTv.js +1 -0
- package/dist/client/assets/profiles._handle-C82_HoKX.js +1 -0
- package/dist/client/assets/query-client-fYu2rzRC.js +17 -0
- package/dist/client/assets/rate-limits-ScaEwdVK.js +1 -0
- package/dist/client/assets/react-dom-DHl6Ug7F.js +1 -0
- package/dist/client/assets/react-nBylq1U5.js +1 -0
- package/dist/client/assets/repeat-2-xCwHM9hD.js +1 -0
- package/dist/client/assets/routes-q7ZaW4En.js +1 -0
- package/dist/client/assets/schemas-I9r6F6ya.js +64 -0
- package/dist/client/assets/search-Dq5kYsxA.js +1 -0
- package/dist/client/assets/sparkles-CQVlvHsZ.js +1 -0
- package/dist/client/assets/styles-B8s3tt3r.css +2 -0
- package/dist/client/assets/today-CeG1O7Py.js +1 -0
- package/dist/client/assets/triangle-alert-CBL7s2pf.js +1 -0
- package/dist/client/assets/useTimelineRouteData-1HsqgvUi.js +1 -0
- package/dist/client/assets/users-CHbKlqUr.js +1 -0
- package/dist/server/assets/AvatarChip-zUDAEmjL.js +105 -0
- package/dist/server/assets/FeedState-ntW0Q2GB.js +214 -0
- package/dist/server/assets/ProfileAnalysisStream-BFvhVdhn.js +198 -0
- package/dist/server/assets/ProfilePreview-C6gAor_j.js +752 -0
- package/dist/server/assets/SavedTimelineView-BG1jnBp1.js +64 -0
- package/dist/server/assets/SmartTimestamp-DfwE1NGf.js +45 -0
- package/dist/server/assets/SyncNowButton-BOn_IBXS.js +76 -0
- package/dist/server/assets/TimelineRouteFrame-CU7ilM7U.js +85 -0
- package/dist/server/assets/TweetRichText-DhCVv1-6.js +74 -0
- package/dist/server/assets/_tanstack-start-manifest_v-C-ZRnG_n.js +148 -0
- package/dist/server/assets/account-selection-CTdFGWRk.js +44 -0
- package/dist/server/assets/blocks-C1mgGTB3.js +299 -0
- package/dist/server/assets/blocks-DSgQghqP.js +17 -0
- package/dist/server/assets/bookmarks-BJN8tykY.js +14 -0
- package/dist/server/assets/client-stream-contracts-C2xbWVjm.js +769 -0
- package/dist/server/assets/data-sources-BnA1Q94p.js +180 -0
- package/dist/server/assets/discuss-CJ1dau1j.js +15 -0
- package/dist/server/assets/discuss-QTo08NCN.js +338 -0
- package/dist/server/assets/dms-BuLj4bp8.js +368 -0
- package/dist/server/assets/dms-DAyQrVM2.js +240 -0
- package/dist/server/assets/empty-plugin-adapters-DzrEkdBF.js +5 -0
- package/dist/server/assets/inbox-CkGOaW1q.js +214 -0
- package/dist/server/assets/inbox-DpWd1EzC.js +146 -0
- package/dist/server/assets/likes-DBOAtsJU.js +14 -0
- package/dist/server/assets/links-DAhSjynu.js +240 -0
- package/dist/server/assets/links-DmH5lxHO.js +468 -0
- package/dist/server/assets/mentions-BH2MzKtB.js +26 -0
- package/dist/server/assets/network-map-D3CzRcC4.js +224 -0
- package/dist/server/assets/network-map-D5DoLOwR.js +582 -0
- package/dist/server/assets/profile-analyze-BP65PED0.js +90 -0
- package/dist/server/assets/profile-analyze-C1NoM0tV.js +9 -0
- package/dist/server/assets/profile-hydration-client-GJ4kwJS8.js +133 -0
- package/dist/server/assets/profiles._handle-DjwlN_ac.js +184 -0
- package/dist/server/assets/profiles._handle-DsLNj2Ca.js +12 -0
- package/dist/server/assets/query-client-BdauHBgd.js +923 -0
- package/dist/server/assets/rate-limits-VAr2qzYD.js +262 -0
- package/dist/server/assets/route-search-BUlQ5lGM.js +117 -0
- package/dist/server/assets/router-DqkwSPiM.js +17026 -0
- package/dist/server/assets/routes-A9c9ZhwN.js +26 -0
- package/dist/server/assets/start-FaDOTmto.js +4 -0
- package/dist/server/assets/today-B5hVM57Z.js +17 -0
- package/dist/server/assets/today-fvGiZ7ud.js +303 -0
- package/dist/server/assets/ui-qbmcMSSX.js +137 -0
- package/{src/components/useDebouncedValue.ts → dist/server/assets/useDebouncedValue-DOnA6Xcy.js} +4 -4
- package/dist/server/assets/useTimelineRouteData-27cxynxa.js +1101 -0
- package/dist/server/server.js +5520 -0
- package/package.json +26 -34
- package/playwright.config.ts +0 -35
- package/scripts/browser-perf.mjs +0 -427
- package/scripts/build-docs-site.mjs +0 -967
- package/scripts/docs-site-assets.mjs +0 -311
- package/scripts/run-vitest.mjs +0 -21
- package/scripts/sanitize-node-options.mjs +0 -23
- package/scripts/start-test-server.mjs +0 -42
- package/src/cli/command-context.ts +0 -17
- package/src/cli/register-analysis.ts +0 -500
- package/src/cli/register-compose.ts +0 -40
- package/src/cli/register-graph.ts +0 -132
- package/src/cli/register-inbox.ts +0 -41
- package/src/cli/register-storage.ts +0 -106
- package/src/cli-moderation.ts +0 -210
- package/src/cli.ts +0 -1616
- package/src/components/AccountSwitcher.tsx +0 -178
- package/src/components/AppNav.tsx +0 -118
- package/src/components/AvatarChip.tsx +0 -58
- package/src/components/AvatarPreload.ts +0 -149
- package/src/components/BrandMark.tsx +0 -67
- package/src/components/ConversationThread.tsx +0 -131
- package/src/components/DmWorkspace.tsx +0 -286
- package/src/components/EmbeddedTweetCard.tsx +0 -55
- package/src/components/FeedState.tsx +0 -147
- package/src/components/FloatingPreview.tsx +0 -382
- package/src/components/InboxCard.tsx +0 -152
- package/src/components/LinkPreviewCard.tsx +0 -292
- package/src/components/MarkdownCitations.tsx +0 -680
- package/src/components/MarkdownViewer.tsx +0 -111
- package/src/components/ProfileAnalysisClient.ts +0 -191
- package/src/components/ProfileAnalysisStream.tsx +0 -259
- package/src/components/ProfilePreview.tsx +0 -131
- package/src/components/SavedTimelineView.tsx +0 -155
- package/src/components/SmartTimestamp.tsx +0 -72
- package/src/components/SyncNowButton.tsx +0 -140
- package/src/components/ThemeSlider.tsx +0 -80
- package/src/components/TimelineCard.tsx +0 -533
- package/src/components/TimelineRouteFrame.tsx +0 -186
- package/src/components/TweetArticleCard.tsx +0 -66
- package/src/components/TweetMediaGrid.tsx +0 -185
- package/src/components/TweetRichText.tsx +0 -159
- package/src/components/account-selection.ts +0 -64
- package/src/components/links-controller.ts +0 -162
- package/src/components/links-model.ts +0 -198
- package/src/components/network-map-controller.ts +0 -84
- package/src/components/network-map-model.ts +0 -255
- package/src/components/useTimelineRouteData.ts +0 -193
- package/src/lib/account-sync-job.ts +0 -666
- package/src/lib/actions-transport.ts +0 -300
- package/src/lib/analysis-runtime.ts +0 -238
- package/src/lib/api-client.ts +0 -220
- package/src/lib/api-contracts.ts +0 -328
- package/src/lib/archive-finder.ts +0 -185
- package/src/lib/archive-import-plan.ts +0 -102
- package/src/lib/archive-import.ts +0 -2695
- package/src/lib/authored-live.ts +0 -1027
- package/src/lib/avatar-cache.ts +0 -349
- package/src/lib/backup.ts +0 -2652
- package/src/lib/bird-actions.ts +0 -294
- package/src/lib/bird-command.ts +0 -130
- package/src/lib/bird.ts +0 -1140
- package/src/lib/blocklist.ts +0 -136
- package/src/lib/blocks-write.ts +0 -171
- package/src/lib/blocks.ts +0 -387
- package/src/lib/bookmark-sync-job.ts +0 -536
- package/src/lib/config.ts +0 -224
- package/src/lib/conversation-surface.ts +0 -205
- package/src/lib/data-sources.ts +0 -219
- package/src/lib/database-metrics.ts +0 -88
- package/src/lib/database-migrations.ts +0 -34
- package/src/lib/database-schema.ts +0 -312
- package/src/lib/database-writer.ts +0 -69
- package/src/lib/db.ts +0 -889
- package/src/lib/dm-read-model.ts +0 -533
- package/src/lib/dms-live.ts +0 -870
- package/src/lib/effect-runtime.ts +0 -45
- package/src/lib/follow-graph.ts +0 -1087
- package/src/lib/geocoding.ts +0 -296
- package/src/lib/http-effect.ts +0 -222
- package/src/lib/identity-search-index.ts +0 -369
- package/src/lib/import-repository.ts +0 -138
- package/src/lib/inbox.ts +0 -242
- package/src/lib/link-index.ts +0 -641
- package/src/lib/link-insights.ts +0 -860
- package/src/lib/link-preview-metadata.ts +0 -754
- package/src/lib/live-sync-engine.ts +0 -209
- package/src/lib/live-transport-gateway.ts +0 -128
- package/src/lib/location.ts +0 -137
- package/src/lib/media-fetch.ts +0 -860
- package/src/lib/media-includes.ts +0 -165
- package/src/lib/mention-threads-live.ts +0 -830
- package/src/lib/mentions-export.ts +0 -147
- package/src/lib/mentions-live.ts +0 -1114
- package/src/lib/moderation-target.ts +0 -227
- package/src/lib/moderation-write.ts +0 -131
- package/src/lib/mutes-write.ts +0 -171
- package/src/lib/mutes.ts +0 -84
- package/src/lib/ndjson-stream.ts +0 -106
- package/src/lib/network-map.ts +0 -382
- package/src/lib/openai-response-runtime.ts +0 -251
- package/src/lib/openai.ts +0 -117
- package/src/lib/paginated-sync.ts +0 -93
- package/src/lib/period-digest.ts +0 -1364
- package/src/lib/present.ts +0 -118
- package/src/lib/profile-affiliation-hydration.ts +0 -228
- package/src/lib/profile-affiliations.ts +0 -262
- package/src/lib/profile-analysis.ts +0 -1198
- package/src/lib/profile-bio-entities.ts +0 -318
- package/src/lib/profile-history.ts +0 -164
- package/src/lib/profile-hydration.ts +0 -180
- package/src/lib/profile-replies.ts +0 -77
- package/src/lib/profile-resolver.ts +0 -650
- package/src/lib/queries.ts +0 -6
- package/src/lib/query-actions.ts +0 -437
- package/src/lib/query-client.tsx +0 -47
- package/src/lib/query-read-model-shared.ts +0 -52
- package/src/lib/query-read-models.ts +0 -5
- package/src/lib/query-resource.ts +0 -41
- package/src/lib/query-status.ts +0 -164
- package/src/lib/research.ts +0 -652
- package/src/lib/runtime-services.ts +0 -20
- package/src/lib/search-discussion.ts +0 -812
- package/src/lib/seed.ts +0 -613
- package/src/lib/server-runtime-services.ts +0 -30
- package/src/lib/sqlite.ts +0 -183
- package/src/lib/streaming-ingestion.ts +0 -240
- package/src/lib/sync-cache.ts +0 -70
- package/src/lib/sync-plan.ts +0 -175
- package/src/lib/theme-transition.ts +0 -113
- package/src/lib/theme.tsx +0 -165
- package/src/lib/timeline-collections-live.ts +0 -407
- package/src/lib/timeline-live.ts +0 -302
- package/src/lib/timeline-read-model.ts +0 -1191
- package/src/lib/tweet-account-edges.ts +0 -48
- package/src/lib/tweet-lookup.ts +0 -46
- package/src/lib/tweet-render.ts +0 -430
- package/src/lib/tweet-repository.ts +0 -156
- package/src/lib/tweet-search-live.ts +0 -462
- package/src/lib/types.ts +0 -723
- package/src/lib/ui.ts +0 -529
- package/src/lib/url-expansion-store.ts +0 -110
- package/src/lib/url-expansion.ts +0 -343
- package/src/lib/url-safety.ts +0 -220
- package/src/lib/web-sync.ts +0 -533
- package/src/lib/whois.ts +0 -1080
- package/src/lib/x-profile.ts +0 -365
- package/src/lib/x-web.ts +0 -199
- package/src/lib/xurl-rate-limits.ts +0 -267
- package/src/lib/xurl.ts +0 -1677
- package/src/routeTree.gen.ts +0 -723
- package/src/router.tsx +0 -20
- package/src/routes/__root.tsx +0 -82
- package/src/routes/api/action.tsx +0 -147
- package/src/routes/api/avatar.tsx +0 -50
- package/src/routes/api/blocks.tsx +0 -35
- package/src/routes/api/conversation.tsx +0 -45
- package/src/routes/api/data-sources.tsx +0 -24
- package/src/routes/api/inbox.tsx +0 -43
- package/src/routes/api/link-insights.tsx +0 -85
- package/src/routes/api/link-preview.tsx +0 -47
- package/src/routes/api/network-map.tsx +0 -55
- package/src/routes/api/period-digest.tsx +0 -101
- package/src/routes/api/profile-analysis.tsx +0 -97
- package/src/routes/api/profile-hydrate.tsx +0 -54
- package/src/routes/api/query.tsx +0 -121
- package/src/routes/api/search-discussion.tsx +0 -113
- package/src/routes/api/status.tsx +0 -30
- package/src/routes/api/sync.tsx +0 -108
- package/src/routes/api/xurl-rate-limits.tsx +0 -24
- package/src/routes/blocks.tsx +0 -343
- package/src/routes/bookmarks.tsx +0 -18
- package/src/routes/data-sources.tsx +0 -249
- package/src/routes/discuss.tsx +0 -419
- package/src/routes/dms.tsx +0 -415
- package/src/routes/inbox.tsx +0 -232
- package/src/routes/index.tsx +0 -32
- package/src/routes/likes.tsx +0 -18
- package/src/routes/links.tsx +0 -631
- package/src/routes/mentions.tsx +0 -32
- package/src/routes/network-map.tsx +0 -732
- package/src/routes/profile-analyze.tsx +0 -112
- package/src/routes/profiles.$handle.tsx +0 -228
- package/src/routes/rate-limits.tsx +0 -305
- package/src/routes/today.tsx +0 -511
- package/src/styles.css +0 -257
- package/tsconfig.json +0 -29
- package/vite.config.ts +0 -29
- /package/{public → dist/client}/birdclaw-mark.png +0 -0
- /package/{public → dist/client}/favicon.ico +0 -0
- /package/{public → dist/client}/logo192.png +0 -0
- /package/{public → dist/client}/logo512.png +0 -0
- /package/{public → dist/client}/manifest.json +0 -0
- /package/{public → dist/client}/robots.txt +0 -0
package/src/routes/dms.tsx
DELETED
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import {
|
|
3
|
-
keepPreviousData,
|
|
4
|
-
useMutation,
|
|
5
|
-
useQuery,
|
|
6
|
-
useQueryClient,
|
|
7
|
-
} from "@tanstack/react-query";
|
|
8
|
-
import { Search } from "lucide-react";
|
|
9
|
-
import { useEffect, useMemo, useState } from "react";
|
|
10
|
-
import { DmWorkspace } from "#/components/DmWorkspace";
|
|
11
|
-
import { FeedEmpty, FeedError, FeedLoading } from "#/components/FeedState";
|
|
12
|
-
import { SyncNowButton } from "#/components/SyncNowButton";
|
|
13
|
-
import { useSelectedAccountId } from "#/components/account-selection";
|
|
14
|
-
import {
|
|
15
|
-
fetchQueryEnvelope,
|
|
16
|
-
fetchQueryResponse,
|
|
17
|
-
postAction,
|
|
18
|
-
} from "#/lib/api-client";
|
|
19
|
-
import { queryKeys } from "#/lib/query-client";
|
|
20
|
-
import type {
|
|
21
|
-
DmConversationItem,
|
|
22
|
-
DmMessageItem,
|
|
23
|
-
QueryResponse,
|
|
24
|
-
ReplyFilter,
|
|
25
|
-
} from "#/lib/types";
|
|
26
|
-
import { useDebouncedValue } from "#/components/useDebouncedValue";
|
|
27
|
-
import {
|
|
28
|
-
cx,
|
|
29
|
-
pageHeaderClass,
|
|
30
|
-
pageHeaderRowClass,
|
|
31
|
-
pageSubtitleClass,
|
|
32
|
-
pageTitleClass,
|
|
33
|
-
searchFieldIconClass,
|
|
34
|
-
searchFieldInputClass,
|
|
35
|
-
searchFieldShellClass,
|
|
36
|
-
segmentActiveClass,
|
|
37
|
-
segmentClass,
|
|
38
|
-
segmentedClass,
|
|
39
|
-
tabButtonActiveClass,
|
|
40
|
-
tabButtonClass,
|
|
41
|
-
tabButtonIndicatorClass,
|
|
42
|
-
tabStripClass,
|
|
43
|
-
timestampClass,
|
|
44
|
-
} from "#/lib/ui";
|
|
45
|
-
|
|
46
|
-
export const Route = createFileRoute("/dms")({
|
|
47
|
-
component: DmsRoute,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const TABS: Array<{ value: ReplyFilter; label: string }> = [
|
|
51
|
-
{ value: "all", label: "All" },
|
|
52
|
-
{ value: "unreplied", label: "Unreplied" },
|
|
53
|
-
{ value: "replied", label: "Replied" },
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
const SORTS: Array<{ value: "recent" | "followers"; label: string }> = [
|
|
57
|
-
{ value: "recent", label: "Newest" },
|
|
58
|
-
{ value: "followers", label: "Followers" },
|
|
59
|
-
];
|
|
60
|
-
|
|
61
|
-
type DmInboxFilter = "all" | "accepted" | "requests";
|
|
62
|
-
|
|
63
|
-
const INBOX_FILTERS: Array<{ value: DmInboxFilter; label: string }> = [
|
|
64
|
-
{ value: "all", label: "All" },
|
|
65
|
-
{ value: "accepted", label: "Accepted" },
|
|
66
|
-
{ value: "requests", label: "Requests" },
|
|
67
|
-
];
|
|
68
|
-
|
|
69
|
-
const filterNumberFieldClass =
|
|
70
|
-
"flex h-[46px] shrink-0 items-center gap-2 rounded-md border border-[var(--line)] bg-[var(--bg)] px-3 py-0 text-[14px] text-[var(--ink)] outline-none transition-colors duration-150 focus-within:border-[var(--accent)] focus-within:shadow-[0_0_0_1px_var(--accent)]";
|
|
71
|
-
|
|
72
|
-
function DmsRoute() {
|
|
73
|
-
const queryClient = useQueryClient();
|
|
74
|
-
const [selectedConversationId, setSelectedConversationId] = useState<
|
|
75
|
-
string | undefined
|
|
76
|
-
>();
|
|
77
|
-
const [inboxFilter, setInboxFilter] = useState<DmInboxFilter>("all");
|
|
78
|
-
const [replyFilter, setReplyFilter] = useState<ReplyFilter>("unreplied");
|
|
79
|
-
const [minFollowers, setMinFollowers] = useState("");
|
|
80
|
-
const [minInfluenceScore, setMinInfluenceScore] = useState("");
|
|
81
|
-
const [sort, setSort] = useState<"recent" | "followers">("recent");
|
|
82
|
-
const [search, setSearch] = useState("");
|
|
83
|
-
const [replyDraft, setReplyDraft] = useState("");
|
|
84
|
-
const statusQuery = useQuery({
|
|
85
|
-
queryKey: queryKeys.status,
|
|
86
|
-
queryFn: ({ signal }) => fetchQueryEnvelope({ signal }),
|
|
87
|
-
});
|
|
88
|
-
const meta = statusQuery.data ?? null;
|
|
89
|
-
const selectedAccountId = useSelectedAccountId(meta?.accounts);
|
|
90
|
-
const debouncedSearch = useDebouncedValue(search, 180);
|
|
91
|
-
const dmsQueryKey = [
|
|
92
|
-
...queryKeys.dms,
|
|
93
|
-
{
|
|
94
|
-
inboxFilter,
|
|
95
|
-
replyFilter,
|
|
96
|
-
minFollowers,
|
|
97
|
-
minInfluenceScore,
|
|
98
|
-
sort,
|
|
99
|
-
search: debouncedSearch,
|
|
100
|
-
selectedAccountId: selectedAccountId ?? null,
|
|
101
|
-
selectedConversationId: selectedConversationId ?? null,
|
|
102
|
-
},
|
|
103
|
-
] as const;
|
|
104
|
-
const dmsQuery = useQuery({
|
|
105
|
-
queryKey: dmsQueryKey,
|
|
106
|
-
queryFn: ({ signal }) => {
|
|
107
|
-
const url = new URL("/api/query", window.location.origin);
|
|
108
|
-
url.searchParams.set("resource", "dms");
|
|
109
|
-
url.searchParams.set("inbox", inboxFilter);
|
|
110
|
-
url.searchParams.set("replyFilter", replyFilter);
|
|
111
|
-
url.searchParams.set("sort", sort);
|
|
112
|
-
if (minFollowers.trim()) {
|
|
113
|
-
url.searchParams.set("minFollowers", minFollowers.trim());
|
|
114
|
-
}
|
|
115
|
-
if (minInfluenceScore.trim()) {
|
|
116
|
-
url.searchParams.set("minInfluenceScore", minInfluenceScore.trim());
|
|
117
|
-
}
|
|
118
|
-
if (selectedAccountId && inboxFilter !== "requests") {
|
|
119
|
-
url.searchParams.set("account", selectedAccountId);
|
|
120
|
-
}
|
|
121
|
-
if (selectedConversationId) {
|
|
122
|
-
url.searchParams.set("conversationId", selectedConversationId);
|
|
123
|
-
}
|
|
124
|
-
if (debouncedSearch.trim()) {
|
|
125
|
-
url.searchParams.set("search", debouncedSearch.trim());
|
|
126
|
-
}
|
|
127
|
-
return fetchQueryResponse(url, { signal });
|
|
128
|
-
},
|
|
129
|
-
placeholderData: keepPreviousData,
|
|
130
|
-
staleTime: 5 * 60_000,
|
|
131
|
-
});
|
|
132
|
-
const items = (dmsQuery.data?.items ?? []) as DmConversationItem[];
|
|
133
|
-
const messages = dmsQuery.data?.selectedConversation?.messages ?? [];
|
|
134
|
-
const loadedConversationId =
|
|
135
|
-
dmsQuery.data?.selectedConversation?.conversation.id;
|
|
136
|
-
|
|
137
|
-
useEffect(() => {
|
|
138
|
-
if (!dmsQuery.data) return;
|
|
139
|
-
const nextSelected = loadedConversationId ?? items[0]?.id;
|
|
140
|
-
setSelectedConversationId((current) => {
|
|
141
|
-
if (!current) return nextSelected;
|
|
142
|
-
return items.some((conversation) => conversation.id === current)
|
|
143
|
-
? current
|
|
144
|
-
: nextSelected;
|
|
145
|
-
});
|
|
146
|
-
}, [dmsQuery.data, items, loadedConversationId]);
|
|
147
|
-
|
|
148
|
-
const selectedConversation =
|
|
149
|
-
items.find((item) => item.id === selectedConversationId) ?? null;
|
|
150
|
-
const switchingConversation = Boolean(
|
|
151
|
-
!dmsQuery.isError &&
|
|
152
|
-
selectedConversationId &&
|
|
153
|
-
loadedConversationId &&
|
|
154
|
-
selectedConversationId !== loadedConversationId,
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
const subtitle = useMemo(() => {
|
|
158
|
-
if (!meta) return "Loading direct messages...";
|
|
159
|
-
return `${String(meta.stats.dms)} conversations cached locally`;
|
|
160
|
-
}, [meta]);
|
|
161
|
-
const replyMutation = useMutation({
|
|
162
|
-
mutationFn: ({
|
|
163
|
-
conversationId,
|
|
164
|
-
text,
|
|
165
|
-
}: {
|
|
166
|
-
conversationId: string;
|
|
167
|
-
text: string;
|
|
168
|
-
}) => postAction({ kind: "replyDm", conversationId, text }),
|
|
169
|
-
onMutate: async ({ conversationId, text }) => {
|
|
170
|
-
await queryClient.cancelQueries({ queryKey: dmsQueryKey });
|
|
171
|
-
const previous = queryClient.getQueryData<QueryResponse>(dmsQueryKey);
|
|
172
|
-
if (!previous || !selectedConversation) return { previous };
|
|
173
|
-
const now = new Date().toISOString();
|
|
174
|
-
const accountRecord = meta?.accounts.find(
|
|
175
|
-
(account) => account.id === selectedConversation.accountId,
|
|
176
|
-
);
|
|
177
|
-
const senderHandle = (
|
|
178
|
-
accountRecord?.handle ?? selectedConversation.accountHandle
|
|
179
|
-
).replace(/^@/, "");
|
|
180
|
-
const optimisticMessage: DmMessageItem = {
|
|
181
|
-
id: `optimistic-${now}`,
|
|
182
|
-
conversationId,
|
|
183
|
-
text,
|
|
184
|
-
createdAt: now,
|
|
185
|
-
direction: "outbound",
|
|
186
|
-
isReplied: true,
|
|
187
|
-
mediaCount: 0,
|
|
188
|
-
sender: {
|
|
189
|
-
id: `local-${selectedConversation.accountId}`,
|
|
190
|
-
handle: senderHandle,
|
|
191
|
-
displayName: accountRecord?.name ?? senderHandle,
|
|
192
|
-
bio: "",
|
|
193
|
-
followersCount: 0,
|
|
194
|
-
avatarHue: 18,
|
|
195
|
-
createdAt: now,
|
|
196
|
-
},
|
|
197
|
-
};
|
|
198
|
-
const previousItems = previous.items as DmConversationItem[];
|
|
199
|
-
queryClient.setQueryData<QueryResponse>(dmsQueryKey, {
|
|
200
|
-
...previous,
|
|
201
|
-
items: previousItems.map((item) =>
|
|
202
|
-
item.id === conversationId
|
|
203
|
-
? {
|
|
204
|
-
...item,
|
|
205
|
-
lastMessageAt: now,
|
|
206
|
-
lastMessagePreview: text,
|
|
207
|
-
needsReply: false,
|
|
208
|
-
unreadCount: 0,
|
|
209
|
-
}
|
|
210
|
-
: item,
|
|
211
|
-
),
|
|
212
|
-
selectedConversation: previous.selectedConversation
|
|
213
|
-
? {
|
|
214
|
-
...previous.selectedConversation,
|
|
215
|
-
messages: [
|
|
216
|
-
...previous.selectedConversation.messages,
|
|
217
|
-
optimisticMessage,
|
|
218
|
-
],
|
|
219
|
-
}
|
|
220
|
-
: previous.selectedConversation,
|
|
221
|
-
});
|
|
222
|
-
return { previous };
|
|
223
|
-
},
|
|
224
|
-
onError: (_error, _variables, context) => {
|
|
225
|
-
if (context?.previous) {
|
|
226
|
-
queryClient.setQueryData(dmsQueryKey, context.previous);
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
onSettled: () =>
|
|
230
|
-
Promise.all([
|
|
231
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.dms }),
|
|
232
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.status }),
|
|
233
|
-
]),
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
async function replyToConversation(conversationId: string) {
|
|
237
|
-
const text = replyDraft.trim();
|
|
238
|
-
if (!text || !selectedConversation) return;
|
|
239
|
-
setReplyDraft("");
|
|
240
|
-
try {
|
|
241
|
-
await replyMutation.mutateAsync({ conversationId, text });
|
|
242
|
-
setSelectedConversationId(conversationId);
|
|
243
|
-
} catch {
|
|
244
|
-
setReplyDraft(text);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function refreshLocalView() {
|
|
249
|
-
void Promise.all([
|
|
250
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.dms }),
|
|
251
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.status }),
|
|
252
|
-
]);
|
|
253
|
-
}
|
|
254
|
-
const loading = dmsQuery.isPending;
|
|
255
|
-
const error = dmsQuery.error
|
|
256
|
-
? dmsQuery.error instanceof Error
|
|
257
|
-
? dmsQuery.error.message
|
|
258
|
-
: "Messages unavailable"
|
|
259
|
-
: null;
|
|
260
|
-
const replyError = replyMutation.error
|
|
261
|
-
? replyMutation.error instanceof Error
|
|
262
|
-
? replyMutation.error.message
|
|
263
|
-
: "Reply failed"
|
|
264
|
-
: null;
|
|
265
|
-
|
|
266
|
-
return (
|
|
267
|
-
<>
|
|
268
|
-
<header className={pageHeaderClass}>
|
|
269
|
-
<div className={pageHeaderRowClass}>
|
|
270
|
-
<div className="flex min-w-0 flex-col">
|
|
271
|
-
<h1 className={pageTitleClass}>Messages</h1>
|
|
272
|
-
<p className={pageSubtitleClass}>{subtitle}</p>
|
|
273
|
-
</div>
|
|
274
|
-
<SyncNowButton
|
|
275
|
-
accounts={meta?.accounts}
|
|
276
|
-
kind="dms"
|
|
277
|
-
label="Sync DMs"
|
|
278
|
-
onSynced={refreshLocalView}
|
|
279
|
-
syncOptions={{
|
|
280
|
-
inbox: inboxFilter,
|
|
281
|
-
limit: inboxFilter === "requests" ? 200 : 50,
|
|
282
|
-
maxPages: inboxFilter === "requests" ? 3 : 1,
|
|
283
|
-
}}
|
|
284
|
-
/>
|
|
285
|
-
</div>
|
|
286
|
-
<div className="flex flex-wrap items-center gap-2 px-4 pb-3">
|
|
287
|
-
<div className={segmentedClass} aria-label="DM inbox">
|
|
288
|
-
{INBOX_FILTERS.map((filter) => (
|
|
289
|
-
<button
|
|
290
|
-
key={filter.value}
|
|
291
|
-
aria-pressed={inboxFilter === filter.value}
|
|
292
|
-
className={cx(
|
|
293
|
-
segmentClass,
|
|
294
|
-
inboxFilter === filter.value && segmentActiveClass,
|
|
295
|
-
)}
|
|
296
|
-
onClick={() => setInboxFilter(filter.value)}
|
|
297
|
-
type="button"
|
|
298
|
-
>
|
|
299
|
-
{filter.label}
|
|
300
|
-
</button>
|
|
301
|
-
))}
|
|
302
|
-
</div>
|
|
303
|
-
<label className={cx(searchFieldShellClass, "flex-1 min-w-[200px]")}>
|
|
304
|
-
<Search className={searchFieldIconClass} strokeWidth={2} />
|
|
305
|
-
<input
|
|
306
|
-
className={searchFieldInputClass}
|
|
307
|
-
onChange={(event) => setSearch(event.target.value)}
|
|
308
|
-
placeholder="Search DMs"
|
|
309
|
-
value={search}
|
|
310
|
-
/>
|
|
311
|
-
</label>
|
|
312
|
-
<label className={cx(filterNumberFieldClass, "w-[156px]")}>
|
|
313
|
-
<span className="shrink-0 text-[12px] font-semibold text-[var(--ink-soft)]">
|
|
314
|
-
Followers
|
|
315
|
-
</span>
|
|
316
|
-
<input
|
|
317
|
-
className="min-w-0 flex-1 border-0 bg-transparent text-right text-[14px] text-[var(--ink)] outline-none placeholder:text-[var(--ink-soft)]"
|
|
318
|
-
inputMode="numeric"
|
|
319
|
-
onChange={(event) => setMinFollowers(event.target.value)}
|
|
320
|
-
placeholder="Any"
|
|
321
|
-
value={minFollowers}
|
|
322
|
-
/>
|
|
323
|
-
</label>
|
|
324
|
-
<label className={cx(filterNumberFieldClass, "w-[132px]")}>
|
|
325
|
-
<span className="shrink-0 text-[12px] font-semibold text-[var(--ink-soft)]">
|
|
326
|
-
Score
|
|
327
|
-
</span>
|
|
328
|
-
<input
|
|
329
|
-
className="min-w-0 flex-1 border-0 bg-transparent text-right text-[14px] text-[var(--ink)] outline-none placeholder:text-[var(--ink-soft)]"
|
|
330
|
-
inputMode="numeric"
|
|
331
|
-
onChange={(event) => setMinInfluenceScore(event.target.value)}
|
|
332
|
-
placeholder="Any"
|
|
333
|
-
value={minInfluenceScore}
|
|
334
|
-
/>
|
|
335
|
-
</label>
|
|
336
|
-
<div className={segmentedClass}>
|
|
337
|
-
{SORTS.map((option) => (
|
|
338
|
-
<button
|
|
339
|
-
key={option.value}
|
|
340
|
-
className={cx(
|
|
341
|
-
segmentClass,
|
|
342
|
-
option.value === sort && segmentActiveClass,
|
|
343
|
-
)}
|
|
344
|
-
onClick={() => setSort(option.value)}
|
|
345
|
-
type="button"
|
|
346
|
-
>
|
|
347
|
-
{option.label}
|
|
348
|
-
</button>
|
|
349
|
-
))}
|
|
350
|
-
</div>
|
|
351
|
-
</div>
|
|
352
|
-
<div className={tabStripClass} aria-label="DM reply filter">
|
|
353
|
-
{TABS.map((tab) => {
|
|
354
|
-
const active = replyFilter === tab.value;
|
|
355
|
-
return (
|
|
356
|
-
<button
|
|
357
|
-
key={tab.value}
|
|
358
|
-
type="button"
|
|
359
|
-
aria-pressed={active}
|
|
360
|
-
className={cx(tabButtonClass, active && tabButtonActiveClass)}
|
|
361
|
-
onClick={() => setReplyFilter(tab.value)}
|
|
362
|
-
>
|
|
363
|
-
<span className="relative inline-flex flex-col items-center justify-center py-1">
|
|
364
|
-
{tab.value}
|
|
365
|
-
{active ? <span className={tabButtonIndicatorClass} /> : null}
|
|
366
|
-
</span>
|
|
367
|
-
</button>
|
|
368
|
-
);
|
|
369
|
-
})}
|
|
370
|
-
</div>
|
|
371
|
-
</header>
|
|
372
|
-
{replyError ? (
|
|
373
|
-
<p className={cx(timestampClass, "px-4 py-2 text-red-500")}>
|
|
374
|
-
{replyError}
|
|
375
|
-
</p>
|
|
376
|
-
) : null}
|
|
377
|
-
|
|
378
|
-
{(loading && items.length === 0) || switchingConversation ? (
|
|
379
|
-
<FeedLoading
|
|
380
|
-
detail="Reading local conversations and reply state"
|
|
381
|
-
label="Loading messages"
|
|
382
|
-
/>
|
|
383
|
-
) : error ? (
|
|
384
|
-
<FeedError
|
|
385
|
-
action={
|
|
386
|
-
<button
|
|
387
|
-
className="rounded-full bg-[var(--accent)] px-4 py-1.5 text-[14px] font-bold text-white"
|
|
388
|
-
onClick={() => void dmsQuery.refetch()}
|
|
389
|
-
type="button"
|
|
390
|
-
>
|
|
391
|
-
Retry
|
|
392
|
-
</button>
|
|
393
|
-
}
|
|
394
|
-
message={error}
|
|
395
|
-
title="Could not load messages"
|
|
396
|
-
/>
|
|
397
|
-
) : items.length === 0 ? (
|
|
398
|
-
<FeedEmpty
|
|
399
|
-
detail="Sync DMs or broaden the filters to find a conversation."
|
|
400
|
-
label="No conversations in this view"
|
|
401
|
-
/>
|
|
402
|
-
) : (
|
|
403
|
-
<DmWorkspace
|
|
404
|
-
conversations={items}
|
|
405
|
-
onReplyDraftChange={setReplyDraft}
|
|
406
|
-
onReplySend={replyToConversation}
|
|
407
|
-
onSelectConversation={setSelectedConversationId}
|
|
408
|
-
replyDraft={replyDraft}
|
|
409
|
-
selectedConversation={selectedConversation}
|
|
410
|
-
selectedMessages={messages}
|
|
411
|
-
/>
|
|
412
|
-
)}
|
|
413
|
-
</>
|
|
414
|
-
);
|
|
415
|
-
}
|
package/src/routes/inbox.tsx
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import {
|
|
3
|
-
keepPreviousData,
|
|
4
|
-
useMutation,
|
|
5
|
-
useQuery,
|
|
6
|
-
useQueryClient,
|
|
7
|
-
} from "@tanstack/react-query";
|
|
8
|
-
import { Sparkles } from "lucide-react";
|
|
9
|
-
import { useMemo, useState } from "react";
|
|
10
|
-
import { useSelectedAccountId } from "#/components/account-selection";
|
|
11
|
-
import { InboxCard } from "#/components/InboxCard";
|
|
12
|
-
import { fetchQueryEnvelope, postAction } from "#/lib/api-client";
|
|
13
|
-
import { queryKeys } from "#/lib/query-client";
|
|
14
|
-
import type { InboxItem, InboxKind, InboxResponse } from "#/lib/types";
|
|
15
|
-
import {
|
|
16
|
-
cx,
|
|
17
|
-
emptyStateClass,
|
|
18
|
-
feedClass,
|
|
19
|
-
pageHeaderClass,
|
|
20
|
-
pageHeaderRowClass,
|
|
21
|
-
pageSubtitleClass,
|
|
22
|
-
pageTitleClass,
|
|
23
|
-
primaryButtonClass,
|
|
24
|
-
secondaryButtonClass,
|
|
25
|
-
tabButtonActiveClass,
|
|
26
|
-
tabButtonClass,
|
|
27
|
-
tabButtonIndicatorClass,
|
|
28
|
-
tabStripClass,
|
|
29
|
-
textFieldClass,
|
|
30
|
-
textFieldShortClass,
|
|
31
|
-
timestampClass,
|
|
32
|
-
} from "#/lib/ui";
|
|
33
|
-
|
|
34
|
-
export const Route = createFileRoute("/inbox")({
|
|
35
|
-
component: InboxRoute,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const TABS: Array<{ value: InboxKind; label: string }> = [
|
|
39
|
-
{ value: "mixed", label: "Mixed" },
|
|
40
|
-
{ value: "mentions", label: "Mentions" },
|
|
41
|
-
{ value: "dms", label: "DMs" },
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
function InboxRoute() {
|
|
45
|
-
const queryClient = useQueryClient();
|
|
46
|
-
const [kind, setKind] = useState<InboxKind>("mixed");
|
|
47
|
-
const [minScore, setMinScore] = useState("40");
|
|
48
|
-
const [hideLowSignal, setHideLowSignal] = useState(true);
|
|
49
|
-
const [activeReplyId, setActiveReplyId] = useState<string | null>(null);
|
|
50
|
-
const [replyDraft, setReplyDraft] = useState("");
|
|
51
|
-
const [isSendingReply, setIsSendingReply] = useState(false);
|
|
52
|
-
const [replyError, setReplyError] = useState<string | null>(null);
|
|
53
|
-
const statusQuery = useQuery({
|
|
54
|
-
queryKey: queryKeys.status,
|
|
55
|
-
queryFn: ({ signal }) => fetchQueryEnvelope({ signal }),
|
|
56
|
-
});
|
|
57
|
-
const meta = statusQuery.data ?? null;
|
|
58
|
-
const selectedAccountId = useSelectedAccountId(meta?.accounts);
|
|
59
|
-
const inboxQueryKey = [
|
|
60
|
-
...queryKeys.inbox,
|
|
61
|
-
{
|
|
62
|
-
hideLowSignal,
|
|
63
|
-
kind,
|
|
64
|
-
minScore,
|
|
65
|
-
selectedAccountId: selectedAccountId ?? null,
|
|
66
|
-
},
|
|
67
|
-
] as const;
|
|
68
|
-
const inboxQuery = useQuery({
|
|
69
|
-
queryKey: inboxQueryKey,
|
|
70
|
-
queryFn: async ({ signal }) => {
|
|
71
|
-
const url = new URL("/api/inbox", window.location.origin);
|
|
72
|
-
url.searchParams.set("kind", kind);
|
|
73
|
-
url.searchParams.set("minScore", minScore);
|
|
74
|
-
if (selectedAccountId) {
|
|
75
|
-
url.searchParams.set("account", selectedAccountId);
|
|
76
|
-
}
|
|
77
|
-
if (hideLowSignal) {
|
|
78
|
-
url.searchParams.set("hideLowSignal", "1");
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const response = await fetch(url, { signal });
|
|
82
|
-
if (!response.ok) {
|
|
83
|
-
throw new Error(`Inbox request failed (${String(response.status)})`);
|
|
84
|
-
}
|
|
85
|
-
return (await response.json()) as InboxResponse;
|
|
86
|
-
},
|
|
87
|
-
placeholderData: keepPreviousData,
|
|
88
|
-
staleTime: 5 * 60_000,
|
|
89
|
-
});
|
|
90
|
-
const items = inboxQuery.data?.items ?? [];
|
|
91
|
-
const stats = inboxQuery.data?.stats ?? null;
|
|
92
|
-
const scoreMutation = useMutation({
|
|
93
|
-
mutationFn: () =>
|
|
94
|
-
postAction({
|
|
95
|
-
kind: "scoreInbox",
|
|
96
|
-
scoreKind: kind,
|
|
97
|
-
account: selectedAccountId,
|
|
98
|
-
limit: 8,
|
|
99
|
-
}),
|
|
100
|
-
onSuccess: () =>
|
|
101
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.inbox }),
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
const subtitle = useMemo(() => {
|
|
105
|
-
if (!meta || !stats) return "Ranking unreplied mentions and DMs...";
|
|
106
|
-
return `${String(stats.total)} in queue · ${String(stats.openai)} OpenAI scored · ${meta.transport.statusText}`;
|
|
107
|
-
}, [meta, stats]);
|
|
108
|
-
|
|
109
|
-
async function scoreNow() {
|
|
110
|
-
await scoreMutation.mutateAsync();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async function sendReply(item: InboxItem) {
|
|
114
|
-
if (!replyDraft.trim()) return;
|
|
115
|
-
setIsSendingReply(true);
|
|
116
|
-
setReplyError(null);
|
|
117
|
-
try {
|
|
118
|
-
await postAction(
|
|
119
|
-
item.entityKind === "dm"
|
|
120
|
-
? {
|
|
121
|
-
kind: "replyDm",
|
|
122
|
-
conversationId: item.entityId,
|
|
123
|
-
text: replyDraft,
|
|
124
|
-
}
|
|
125
|
-
: {
|
|
126
|
-
kind: "replyTweet",
|
|
127
|
-
accountId: item.accountId,
|
|
128
|
-
tweetId: item.entityId,
|
|
129
|
-
text: replyDraft,
|
|
130
|
-
},
|
|
131
|
-
);
|
|
132
|
-
setReplyDraft("");
|
|
133
|
-
setActiveReplyId(null);
|
|
134
|
-
await queryClient.invalidateQueries({ queryKey: queryKeys.inbox });
|
|
135
|
-
} catch (error) {
|
|
136
|
-
setReplyError(error instanceof Error ? error.message : "Reply failed");
|
|
137
|
-
} finally {
|
|
138
|
-
setIsSendingReply(false);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return (
|
|
143
|
-
<>
|
|
144
|
-
<header className={pageHeaderClass}>
|
|
145
|
-
<div className={pageHeaderRowClass}>
|
|
146
|
-
<div className="flex min-w-0 flex-col">
|
|
147
|
-
<h1 className={pageTitleClass}>Inbox</h1>
|
|
148
|
-
<p className={pageSubtitleClass}>{subtitle}</p>
|
|
149
|
-
</div>
|
|
150
|
-
<button
|
|
151
|
-
className={primaryButtonClass}
|
|
152
|
-
disabled={scoreMutation.isPending}
|
|
153
|
-
onClick={() => void scoreNow()}
|
|
154
|
-
type="button"
|
|
155
|
-
>
|
|
156
|
-
<Sparkles className="size-4" strokeWidth={2.2} />
|
|
157
|
-
{scoreMutation.isPending ? "Scoring..." : "Score with OpenAI"}
|
|
158
|
-
</button>
|
|
159
|
-
</div>
|
|
160
|
-
<div className="flex flex-wrap items-center gap-2 px-4 pb-3">
|
|
161
|
-
<input
|
|
162
|
-
className={cx(textFieldClass, textFieldShortClass)}
|
|
163
|
-
inputMode="numeric"
|
|
164
|
-
onChange={(event) => setMinScore(event.target.value)}
|
|
165
|
-
placeholder="Min AI score"
|
|
166
|
-
value={minScore}
|
|
167
|
-
/>
|
|
168
|
-
<button
|
|
169
|
-
className={secondaryButtonClass}
|
|
170
|
-
onClick={() => setHideLowSignal((value) => !value)}
|
|
171
|
-
type="button"
|
|
172
|
-
aria-pressed={hideLowSignal}
|
|
173
|
-
>
|
|
174
|
-
{hideLowSignal ? "Hide low-signal" : "Show all"}
|
|
175
|
-
</button>
|
|
176
|
-
</div>
|
|
177
|
-
<div className={tabStripClass}>
|
|
178
|
-
{TABS.map((tab) => {
|
|
179
|
-
const active = kind === tab.value;
|
|
180
|
-
return (
|
|
181
|
-
<button
|
|
182
|
-
key={tab.value}
|
|
183
|
-
type="button"
|
|
184
|
-
aria-pressed={active}
|
|
185
|
-
className={cx(tabButtonClass, active && tabButtonActiveClass)}
|
|
186
|
-
onClick={() => setKind(tab.value)}
|
|
187
|
-
>
|
|
188
|
-
<span className="relative inline-flex flex-col items-center justify-center py-1">
|
|
189
|
-
{tab.value}
|
|
190
|
-
{active ? <span className={tabButtonIndicatorClass} /> : null}
|
|
191
|
-
</span>
|
|
192
|
-
</button>
|
|
193
|
-
);
|
|
194
|
-
})}
|
|
195
|
-
</div>
|
|
196
|
-
</header>
|
|
197
|
-
{replyError ? (
|
|
198
|
-
<p className={cx(timestampClass, "px-4 py-2 text-red-500")}>
|
|
199
|
-
{replyError}
|
|
200
|
-
</p>
|
|
201
|
-
) : null}
|
|
202
|
-
<section className={feedClass}>
|
|
203
|
-
{items.length === 0 ? (
|
|
204
|
-
<div className={emptyStateClass}>Inbox clear.</div>
|
|
205
|
-
) : null}
|
|
206
|
-
{items.map((item) => (
|
|
207
|
-
<InboxCard
|
|
208
|
-
key={item.id}
|
|
209
|
-
isReplying={activeReplyId === item.id}
|
|
210
|
-
item={item}
|
|
211
|
-
onReplyChange={setReplyDraft}
|
|
212
|
-
onReplySend={() => void sendReply(item)}
|
|
213
|
-
onReplyToggle={() => {
|
|
214
|
-
setReplyError(null);
|
|
215
|
-
if (activeReplyId === item.id) {
|
|
216
|
-
setActiveReplyId(null);
|
|
217
|
-
setReplyDraft("");
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
setActiveReplyId(item.id);
|
|
221
|
-
setReplyDraft("");
|
|
222
|
-
}}
|
|
223
|
-
replyDraft={activeReplyId === item.id ? replyDraft : ""}
|
|
224
|
-
/>
|
|
225
|
-
))}
|
|
226
|
-
</section>
|
|
227
|
-
{isSendingReply ? (
|
|
228
|
-
<p className={cx(timestampClass, "px-4 py-2")}>Sending reply...</p>
|
|
229
|
-
) : null}
|
|
230
|
-
</>
|
|
231
|
-
);
|
|
232
|
-
}
|
package/src/routes/index.tsx
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { TimelineRouteFrame } from "#/components/TimelineRouteFrame";
|
|
3
|
-
import type { QueryEnvelope } from "#/lib/types";
|
|
4
|
-
|
|
5
|
-
export const Route = createFileRoute("/")({
|
|
6
|
-
component: HomeRoute,
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
function homeSubtitle(meta: QueryEnvelope | null) {
|
|
10
|
-
if (!meta) return "Loading local context...";
|
|
11
|
-
return `${String(meta.stats.home)} items · ${String(meta.stats.needsReply)} waiting · ${meta.transport.statusText}`;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function HomeRoute() {
|
|
15
|
-
return (
|
|
16
|
-
<TimelineRouteFrame
|
|
17
|
-
emptyDetail="Try a different filter or sync the timeline again."
|
|
18
|
-
emptyLabel="No posts in this view"
|
|
19
|
-
errorFallback="Timeline unavailable"
|
|
20
|
-
errorTitle="Could not load posts"
|
|
21
|
-
initialReplyFilter="all"
|
|
22
|
-
loadingDetail="Reading the local timeline store"
|
|
23
|
-
loadingLabel="Loading posts"
|
|
24
|
-
resource="home"
|
|
25
|
-
searchPlaceholder="Search local timeline"
|
|
26
|
-
subtitle={homeSubtitle}
|
|
27
|
-
syncKind="timeline"
|
|
28
|
-
syncLabel="Sync timeline"
|
|
29
|
-
title="Home"
|
|
30
|
-
/>
|
|
31
|
-
);
|
|
32
|
-
}
|
package/src/routes/likes.tsx
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { SavedTimelineView } from "#/components/SavedTimelineView";
|
|
3
|
-
|
|
4
|
-
export const Route = createFileRoute("/likes")({
|
|
5
|
-
component: LikesRoute,
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
function LikesRoute() {
|
|
9
|
-
return (
|
|
10
|
-
<SavedTimelineView
|
|
11
|
-
eyebrow="liked posts"
|
|
12
|
-
filter="liked"
|
|
13
|
-
loadingLabel="Loading liked posts..."
|
|
14
|
-
searchPlaceholder="Search likes"
|
|
15
|
-
title="Things worth keeping in the orbit."
|
|
16
|
-
/>
|
|
17
|
-
);
|
|
18
|
-
}
|