ref0-git 0.2.0 → 0.4.0
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/app/apps/github/.dev.vars.example +2 -1
- package/app/apps/github/generated/git-rest.ts +191 -25
- package/app/apps/github/generated/routeTree.gen.ts +21 -0
- package/app/apps/github/package.json +1 -1
- package/app/apps/github/src/branches/branch-list.tsx +8 -4
- package/app/apps/github/src/branches/branches.ts +10 -5
- package/app/apps/github/src/camo/addresses.ts +120 -0
- package/app/apps/github/src/camo/client.ts +125 -0
- package/app/apps/github/src/camo/fetch.ts +201 -0
- package/app/apps/github/src/camo/lookup.ts +23 -0
- package/app/apps/github/src/camo/node.ts +50 -0
- package/app/apps/github/src/camo/proxy.ts +116 -0
- package/app/apps/github/src/camo/sign-images.ts +307 -0
- package/app/apps/github/src/camo/signing.ts +80 -0
- package/app/apps/github/src/clients/allowed.ts +111 -18
- package/app/apps/github/src/clients/clients.ts +76 -61
- package/app/apps/github/src/clients/transport.ts +13 -0
- package/app/apps/github/src/code/code-tree.tsx +3 -1
- package/app/apps/github/src/code/file-view.tsx +15 -6
- package/app/apps/github/src/code/files.ts +26 -19
- package/app/apps/github/src/code/go-to-file.tsx +2 -1
- package/app/apps/github/src/code/load.ts +41 -23
- package/app/apps/github/src/code/markdown-files.ts +13 -2
- package/app/apps/github/src/code/ref-pages.ts +14 -5
- package/app/apps/github/src/code/ref-switcher.tsx +4 -3
- package/app/apps/github/src/code/refs.ts +42 -8
- package/app/apps/github/src/code/repo-home.tsx +6 -2
- package/app/apps/github/src/code/repo.ts +12 -6
- package/app/apps/github/src/code/saved.ts +5 -3
- package/app/apps/github/src/code/trees.ts +11 -9
- package/app/apps/github/src/components/markdown/markdown.css +6 -0
- package/app/apps/github/src/components/markdown/markdown.tsx +95 -10
- package/app/apps/github/src/components/owner-card.tsx +3 -1
- package/app/apps/github/src/components/repos/your-repos.tsx +3 -1
- package/app/apps/github/src/components/shell/owner-repos.tsx +7 -12
- package/app/apps/github/src/components/shell/repo-switcher.tsx +10 -16
- package/app/apps/github/src/components/signin/device-card.tsx +9 -2
- package/app/apps/github/src/components/user-avatar.tsx +2 -1
- package/app/apps/github/src/context/context.ts +13 -0
- package/app/apps/github/src/diffs/blobs.ts +37 -14
- package/app/apps/github/src/diffs/diff-job.ts +53 -0
- package/app/apps/github/src/diffs/diff-worker.ts +6 -0
- package/app/apps/github/src/diffs/diffing.ts +136 -0
- package/app/apps/github/src/diffs/files.ts +4 -3
- package/app/apps/github/src/diffs/hunks.tsx +101 -53
- package/app/apps/github/src/diffs/patch.ts +20 -11
- package/app/apps/github/src/history/commit-diff.ts +10 -5
- package/app/apps/github/src/history/commit-list.tsx +3 -1
- package/app/apps/github/src/history/commit-page.tsx +4 -2
- package/app/apps/github/src/history/history.ts +12 -10
- package/app/apps/github/src/hooks/allowed.ts +9 -9
- package/app/apps/github/src/hooks/avatars.ts +3 -3
- package/app/apps/github/src/hooks/open-counts.ts +5 -4
- package/app/apps/github/src/hooks/profiles.ts +26 -12
- package/app/apps/github/src/hooks/repos.ts +78 -25
- package/app/apps/github/src/inbox/count.ts +30 -29
- package/app/apps/github/src/inbox/inbox-item.tsx +3 -1
- package/app/apps/github/src/inbox/inbox-page.tsx +5 -2
- package/app/apps/github/src/inbox/marks.ts +26 -15
- package/app/apps/github/src/inbox/release-tags.ts +7 -6
- package/app/apps/github/src/inbox/subjects.ts +5 -4
- package/app/apps/github/src/inbox/subscription-controls.tsx +14 -5
- package/app/apps/github/src/inbox/subscriptions.ts +95 -35
- package/app/apps/github/src/inbox/threads.ts +6 -6
- package/app/apps/github/src/issues/changes.ts +40 -16
- package/app/apps/github/src/issues/counts.ts +8 -5
- package/app/apps/github/src/issues/issue-list.tsx +20 -6
- package/app/apps/github/src/issues/issue-page.tsx +30 -14
- package/app/apps/github/src/issues/issues.ts +195 -46
- package/app/apps/github/src/issues/label-dialog.tsx +8 -11
- package/app/apps/github/src/issues/labels-page.tsx +35 -3
- package/app/apps/github/src/issues/milestone-dialog.tsx +197 -0
- package/app/apps/github/src/issues/milestones-page.tsx +269 -0
- package/app/apps/github/src/issues/new-issue.tsx +3 -1
- package/app/apps/github/src/issues/sidebar.tsx +8 -6
- package/app/apps/github/src/markdown/README.md +22 -17
- package/app/apps/github/src/markdown/context.ts +83 -10
- package/app/apps/github/src/markdown/images.ts +3 -2
- package/app/apps/github/src/markdown/lookup.ts +17 -11
- package/app/apps/github/src/markdown/page-budget.ts +50 -0
- package/app/apps/github/src/markdown/patches.ts +74 -32
- package/app/apps/github/src/markdown/query.ts +7 -2
- package/app/apps/github/src/markdown/remote.ts +106 -0
- package/app/apps/github/src/markdown/render.ts +101 -24
- package/app/apps/github/src/markdown/texts.ts +43 -0
- package/app/apps/github/src/markdown/words-module.d.ts +5 -0
- package/app/apps/github/src/markdown/words-plugin.ts +135 -0
- package/app/apps/github/src/names/repos.ts +1 -1
- package/app/apps/github/src/palette/palette.tsx +28 -10
- package/app/apps/github/src/palette/rows.tsx +93 -40
- package/app/apps/github/src/palette/server.ts +10 -7
- package/app/apps/github/src/palette/targets.ts +1 -0
- package/app/apps/github/src/policy.ts +137 -61
- package/app/apps/github/src/private-repos.ts +5 -5
- package/app/apps/github/src/pulls/compare-page.tsx +6 -3
- package/app/apps/github/src/pulls/files-tab.tsx +480 -214
- package/app/apps/github/src/pulls/held-summary.ts +178 -0
- package/app/apps/github/src/pulls/live.ts +6 -4
- package/app/apps/github/src/pulls/merge-box.tsx +17 -10
- package/app/apps/github/src/pulls/pull-list.tsx +6 -3
- package/app/apps/github/src/pulls/pull-page.tsx +19 -10
- package/app/apps/github/src/pulls/pull.ts +68 -40
- package/app/apps/github/src/pulls/pulls.ts +39 -22
- package/app/apps/github/src/pulls/review-drafts.ts +131 -0
- package/app/apps/github/src/pulls/review.ts +374 -99
- package/app/apps/github/src/pulls/threads.tsx +152 -0
- package/app/apps/github/src/queue/queue-page.tsx +15 -8
- package/app/apps/github/src/queue/queue.ts +35 -20
- package/app/apps/github/src/releases/latest-release.tsx +3 -1
- package/app/apps/github/src/releases/overview.tsx +4 -2
- package/app/apps/github/src/releases/release-form.tsx +8 -5
- package/app/apps/github/src/releases/release-list.tsx +8 -5
- package/app/apps/github/src/releases/release-view.tsx +1 -0
- package/app/apps/github/src/releases/releases.ts +33 -23
- package/app/apps/github/src/releases/tag-list.tsx +3 -1
- package/app/apps/github/src/router.tsx +5 -2
- package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +7 -1
- package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +6 -1
- package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +1 -1
- package/app/apps/github/src/routes/$owner/$repo/branches.tsx +5 -1
- package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +1 -1
- package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +6 -1
- package/app/apps/github/src/routes/$owner/$repo/index.tsx +1 -1
- package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +4 -2
- package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +2 -2
- package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +5 -2
- package/app/apps/github/src/routes/$owner/$repo/labels.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/milestones.tsx +36 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +4 -2
- package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +2 -2
- package/app/apps/github/src/routes/$owner/$repo/queue.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +5 -2
- package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +4 -2
- package/app/apps/github/src/routes/$owner/$repo/route.tsx +9 -5
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +3 -1
- package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +3 -1
- package/app/apps/github/src/routes/-nav.tsx +10 -2
- package/app/apps/github/src/routes/-root-testing.ts +29 -6
- package/app/apps/github/src/routes/__root.tsx +9 -4
- package/app/apps/github/src/routes/index.tsx +3 -1
- package/app/apps/github/src/routes/orgs/$owner/route.tsx +4 -1
- package/app/apps/github/src/routes/orgs/$owner/settings.tsx +4 -1
- package/app/apps/github/src/seed/acme.ts +1 -1
- package/app/apps/github/src/seed/seed.ts +199 -120
- package/app/apps/github/src/server.ts +24 -15
- package/app/apps/github/src/settings/account-avatar.tsx +4 -1
- package/app/apps/github/src/settings/general-settings.tsx +3 -1
- package/app/apps/github/src/settings/general.ts +4 -4
- package/app/apps/github/src/settings/hook-form.tsx +3 -1
- package/app/apps/github/src/settings/hook-list.tsx +5 -2
- package/app/apps/github/src/settings/hooks.ts +7 -7
- package/app/apps/github/src/settings/org-settings.tsx +3 -1
- package/app/apps/github/src/settings/orgs.ts +21 -11
- package/app/apps/github/src/settings/settings-layout.tsx +3 -1
- package/app/apps/github/src/signin/approval.ts +4 -3
- package/app/apps/github/src/signin/auth.ts +9 -2
- package/app/apps/github/src/signin/device-code.ts +8 -3
- package/app/apps/github/src/signin/device-prompt.ts +28 -3
- package/app/apps/github/src/signin/revoke.ts +36 -0
- package/app/apps/github/tsconfig.json +4 -1
- package/app/apps/github/vite.config.ts +8 -0
- package/app/pnpm-workspace.yaml +9 -5
- package/app/tsconfig.base.json +1 -0
- package/dist/cli/child.mjs +1 -1
- package/dist/cli/credentials.mjs +4 -4
- package/dist/cli/documents.mjs +32 -22
- package/dist/cli/events.mjs +1 -1
- package/dist/cli/failure.mjs +20 -7
- package/dist/cli/folders.mjs +2 -2
- package/dist/cli/git-remote-ref0.mjs +47 -22
- package/dist/cli/git.mjs +26 -5
- package/dist/cli/helpers.mjs +168 -35
- package/dist/cli/hosts.mjs +3 -3
- package/dist/cli/output.mjs +2 -2
- package/dist/cli/prompt.mjs +1 -1
- package/dist/cli/queue.mjs +7 -7
- package/dist/cli/ref0-git.mjs +2 -2
- package/dist/cli/repos.mjs +35 -18
- package/dist/cli/resources.mjs +5 -5
- package/dist/cli/retry-after.mjs +8 -0
- package/dist/cli/setup.mjs +172 -66
- package/dist/cli/sign-in.mjs +65 -23
- package/dist/cli/sign-ins.mjs +70 -13
- package/dist/cli/sqlite.mjs +2 -2
- package/dist/cli/tokens.mjs +3 -3
- package/dist/cli/vendor.mjs +1 -1
- package/dist/init/app.mjs +18 -20
- package/dist/init/choices.mjs +1 -1
- package/dist/init/cloudflare.mjs +15 -19
- package/dist/init/create.mjs +4 -3
- package/dist/init/detect.mjs +4 -4
- package/dist/init/files.mjs +121 -9
- package/dist/init/frameworks.mjs +16 -0
- package/dist/init/git-module.mjs +22 -7
- package/dist/init/jsonc.mjs +9 -7
- package/dist/init/metadata.mjs +9 -3
- package/dist/init/mounts.mjs +13 -10
- package/dist/init/next.mjs +3 -5
- package/dist/init/node-app.mjs +3 -3
- package/dist/init/node.mjs +41 -42
- package/dist/init/nuxt.mjs +153 -27
- package/dist/init/stores.mjs +14 -9
- package/dist/init/sveltekit.mjs +4 -2
- package/dist/init/template.mjs +9 -6
- package/dist/init/templates.mjs +64 -48
- package/dist/init/vercel.mjs +37 -36
- package/dist/init/versions.mjs +3 -3
- package/package.json +6 -5
|
@@ -9,9 +9,10 @@ import { notFound } from '@tanstack/react-router';
|
|
|
9
9
|
import { flow } from 'effect/Function';
|
|
10
10
|
import * as Option from 'effect/Option';
|
|
11
11
|
import * as Schema from 'effect/Schema';
|
|
12
|
+
import { useEffect } from 'react';
|
|
12
13
|
|
|
13
14
|
import { cached, readPagesAhead } from '../clients/cached.ts';
|
|
14
|
-
import {
|
|
15
|
+
import { type Clients, useClients } from '../clients/clients.ts';
|
|
15
16
|
import { ownerProblem } from '../names/owners.ts';
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -75,6 +76,7 @@ const lookupFailed = (status: number) => new Error(`The owner didn't load (${sta
|
|
|
75
76
|
* org comes first: the starter's people answer for every login.
|
|
76
77
|
*/
|
|
77
78
|
export const ownerNamed = async (
|
|
79
|
+
clients: Clients,
|
|
78
80
|
login: string,
|
|
79
81
|
viewer: string | undefined,
|
|
80
82
|
): Promise<Owner | undefined> => {
|
|
@@ -82,12 +84,14 @@ export const ownerNamed = async (
|
|
|
82
84
|
return { kind: 'viewer', login: viewer };
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
const org = await github.GET('/orgs/{org}', { params: { path: { org: login } } });
|
|
87
|
+
const org = await clients.github.GET('/orgs/{org}', { params: { path: { org: login } } });
|
|
86
88
|
if (org.data !== undefined) return { kind: 'org', login: org.data.login };
|
|
87
89
|
|
|
88
90
|
if (org.response.status !== 404) throw lookupFailed(org.response.status);
|
|
89
91
|
|
|
90
|
-
const user = await github.GET('/users/{username}', {
|
|
92
|
+
const user = await clients.github.GET('/users/{username}', {
|
|
93
|
+
params: { path: { username: login } },
|
|
94
|
+
});
|
|
91
95
|
if (user.data !== undefined) return { kind: 'user', login: user.data.login };
|
|
92
96
|
|
|
93
97
|
if (user.response.status !== 404) throw lookupFailed(user.response.status);
|
|
@@ -100,10 +104,10 @@ export const ownerNamed = async (
|
|
|
100
104
|
* draws, and kept, so the shell's owner, switcher and lists all read the one answer. `null` for no
|
|
101
105
|
* one.
|
|
102
106
|
*/
|
|
103
|
-
export const ownerAt = (login: string, viewer: string | undefined) =>
|
|
107
|
+
export const ownerAt = (clients: Clients, login: string, viewer: string | undefined) =>
|
|
104
108
|
queryOptions({
|
|
105
109
|
queryKey: ['owner', login.toLowerCase(), viewer ?? null],
|
|
106
|
-
queryFn: async () => (await ownerNamed(login, viewer)) ?? null,
|
|
110
|
+
queryFn: async () => (await ownerNamed(clients, login, viewer)) ?? null,
|
|
107
111
|
staleTime: 5 * 60_000,
|
|
108
112
|
});
|
|
109
113
|
|
|
@@ -112,8 +116,12 @@ export const ownerAt = (login: string, viewer: string | undefined) =>
|
|
|
112
116
|
* anyone else 404, or 302 to the public check, which a browser follows to its 404. It reads the
|
|
113
117
|
* one membership, so an org past the 1,000 the viewer's own list holds still answers.
|
|
114
118
|
*/
|
|
115
|
-
export const viewerBelongs = async (
|
|
116
|
-
|
|
119
|
+
export const viewerBelongs = async (
|
|
120
|
+
clients: Clients,
|
|
121
|
+
org: string,
|
|
122
|
+
viewer: string,
|
|
123
|
+
): Promise<boolean> => {
|
|
124
|
+
const checked = await clients.github.GET('/orgs/{org}/members/{username}', {
|
|
117
125
|
params: { path: { org, username: viewer } },
|
|
118
126
|
});
|
|
119
127
|
const { status } = checked.response;
|
|
@@ -137,8 +145,8 @@ export interface PageViewer {
|
|
|
137
145
|
* falls back: a 404 or 302 still says not a member. The server decides every create, so the
|
|
138
146
|
* fallback offers nothing the server would let no one do.
|
|
139
147
|
*/
|
|
140
|
-
const belongsOr = (org: string, viewer: PageViewer): Promise<boolean> =>
|
|
141
|
-
viewerBelongs(org, viewer.login).catch(() => viewer.orgs.includes(org));
|
|
148
|
+
const belongsOr = (clients: Clients, org: string, viewer: PageViewer): Promise<boolean> =>
|
|
149
|
+
viewerBelongs(clients, org, viewer.login).catch(() => viewer.orgs.includes(org));
|
|
142
150
|
|
|
143
151
|
/**
|
|
144
152
|
* The org New repository starts under: the one `?owner=` names, when the viewer belongs to it, by
|
|
@@ -146,6 +154,7 @@ const belongsOr = (org: string, viewer: PageViewer): Promise<boolean> =>
|
|
|
146
154
|
* under the viewer.
|
|
147
155
|
*/
|
|
148
156
|
export const newUnderOrg = async (
|
|
157
|
+
clients: Clients,
|
|
149
158
|
owner: string | undefined,
|
|
150
159
|
viewer: PageViewer,
|
|
151
160
|
): Promise<string | undefined> => {
|
|
@@ -153,7 +162,7 @@ export const newUnderOrg = async (
|
|
|
153
162
|
|
|
154
163
|
if (viewer.orgs.includes(owner)) return owner;
|
|
155
164
|
|
|
156
|
-
return (await belongsOr(owner, viewer)) ? owner : undefined;
|
|
165
|
+
return (await belongsOr(clients, owner, viewer)) ? owner : undefined;
|
|
157
166
|
};
|
|
158
167
|
|
|
159
168
|
/**
|
|
@@ -164,6 +173,7 @@ export const newUnderOrg = async (
|
|
|
164
173
|
* viewer's orgs, which hold the first 1,000 alone, unless the check fails.
|
|
165
174
|
*/
|
|
166
175
|
export const ownerPage = async (
|
|
176
|
+
clients: Clients,
|
|
167
177
|
login: string,
|
|
168
178
|
viewer: PageViewer | null,
|
|
169
179
|
client: QueryClient,
|
|
@@ -171,14 +181,14 @@ export const ownerPage = async (
|
|
|
171
181
|
): Promise<{ readonly owner: Owner; readonly member: boolean } | undefined> => {
|
|
172
182
|
if (ownerProblem(login) !== undefined) return undefined;
|
|
173
183
|
|
|
174
|
-
const owner = await cached(client, ownerAt(login, viewer?.login));
|
|
184
|
+
const owner = await cached(client, ownerAt(clients, login, viewer?.login));
|
|
175
185
|
if (owner === null) return undefined;
|
|
176
186
|
|
|
177
187
|
if (viewer === null) return { owner, member: false };
|
|
178
188
|
|
|
179
189
|
const [member] = await Promise.all([
|
|
180
|
-
owner.kind === 'org' ? belongsOr(owner.login, viewer) : false,
|
|
181
|
-
readPagesAhead(client, repoList(owner, filter)),
|
|
190
|
+
owner.kind === 'org' ? belongsOr(clients, owner.login, viewer) : false,
|
|
191
|
+
readPagesAhead(client, repoList(clients, owner, filter)),
|
|
182
192
|
]);
|
|
183
193
|
|
|
184
194
|
return { owner, member };
|
|
@@ -190,13 +200,23 @@ export const ownerLoaderDeps = ({ search }: { readonly search: RepoSearch }) =>
|
|
|
190
200
|
/** What an owner's page loader reads: the URL's owner and query, and the root's viewer and cache. */
|
|
191
201
|
export interface OwnerLoad {
|
|
192
202
|
readonly params: { readonly owner: string };
|
|
193
|
-
readonly context: {
|
|
203
|
+
readonly context: {
|
|
204
|
+
readonly viewer: PageViewer | null;
|
|
205
|
+
readonly queryClient: QueryClient;
|
|
206
|
+
readonly clients: Clients;
|
|
207
|
+
};
|
|
194
208
|
readonly deps: RepoSearch;
|
|
195
209
|
}
|
|
196
210
|
|
|
197
211
|
/** An owner's page's loader: `ownerPage`, or not found for an owner no one has. */
|
|
198
212
|
export const ownerLoader = async ({ params, context, deps }: OwnerLoad) => {
|
|
199
|
-
const loaded = await ownerPage(
|
|
213
|
+
const loaded = await ownerPage(
|
|
214
|
+
context.clients,
|
|
215
|
+
params.owner,
|
|
216
|
+
context.viewer,
|
|
217
|
+
context.queryClient,
|
|
218
|
+
filterOf(deps),
|
|
219
|
+
);
|
|
200
220
|
if (loaded === undefined) throw notFound();
|
|
201
221
|
|
|
202
222
|
return loaded;
|
|
@@ -213,13 +233,16 @@ export const newLoaderDeps = ({
|
|
|
213
233
|
|
|
214
234
|
/** What New repository's loader reads: the owner its query names, and the root's viewer. */
|
|
215
235
|
export interface NewLoad {
|
|
216
|
-
readonly context: { readonly viewer: PageViewer | null };
|
|
236
|
+
readonly context: { readonly viewer: PageViewer | null; readonly clients: Clients };
|
|
217
237
|
readonly deps: { readonly owner: string | undefined };
|
|
218
238
|
}
|
|
219
239
|
|
|
220
240
|
/** New repository's loader: the org the form starts under, by `newUnderOrg`, or none. */
|
|
221
241
|
export const newLoader = async ({ context, deps }: NewLoad) => ({
|
|
222
|
-
org:
|
|
242
|
+
org:
|
|
243
|
+
context.viewer === null
|
|
244
|
+
? undefined
|
|
245
|
+
: await newUnderOrg(context.clients, deps.owner, context.viewer),
|
|
223
246
|
});
|
|
224
247
|
|
|
225
248
|
/**
|
|
@@ -280,21 +303,26 @@ interface RepoQuery {
|
|
|
280
303
|
}
|
|
281
304
|
|
|
282
305
|
/** One page of `owner`'s repositories in `query`'s order, from `after`, or the first. */
|
|
283
|
-
const answerOf = async (
|
|
306
|
+
const answerOf = async (
|
|
307
|
+
clients: Clients,
|
|
308
|
+
owner: Owner,
|
|
309
|
+
query: RepoQuery,
|
|
310
|
+
after: string | undefined,
|
|
311
|
+
) => {
|
|
284
312
|
// `after` is the drop-in's cursor, which GitHub's types don't name: a spread passes it.
|
|
285
313
|
const paging = { per_page: perPage, after, ...orders[query.sort] };
|
|
286
314
|
|
|
287
315
|
switch (owner.kind) {
|
|
288
316
|
case 'org':
|
|
289
|
-
return github.GET('/orgs/{org}/repos', {
|
|
317
|
+
return clients.github.GET('/orgs/{org}/repos', {
|
|
290
318
|
params: { path: { org: owner.login }, query: { ...paging, type: query.type } },
|
|
291
319
|
});
|
|
292
320
|
case 'user':
|
|
293
|
-
return github.GET('/users/{username}/repos', {
|
|
321
|
+
return clients.github.GET('/users/{username}/repos', {
|
|
294
322
|
params: { path: { username: owner.login }, query: { ...paging } },
|
|
295
323
|
});
|
|
296
324
|
case 'viewer':
|
|
297
|
-
return github.GET('/user/repos', {
|
|
325
|
+
return clients.github.GET('/user/repos', {
|
|
298
326
|
params: {
|
|
299
327
|
query: { ...paging, affiliation: 'owner', visibility: visibilityOf(query.type) },
|
|
300
328
|
},
|
|
@@ -303,11 +331,12 @@ const answerOf = async (owner: Owner, query: RepoQuery, after: string | undefine
|
|
|
303
331
|
};
|
|
304
332
|
|
|
305
333
|
const repoPage = async (
|
|
334
|
+
clients: Clients,
|
|
306
335
|
owner: Owner,
|
|
307
336
|
query: RepoQuery,
|
|
308
337
|
after: string | undefined,
|
|
309
338
|
): Promise<RepoPage> => {
|
|
310
|
-
const answer = await answerOf(owner, query, after);
|
|
339
|
+
const answer = await answerOf(clients, owner, query, after);
|
|
311
340
|
if (answer.data === undefined)
|
|
312
341
|
throw new Error(`The repositories didn't load (${answer.response.status})`);
|
|
313
342
|
|
|
@@ -333,7 +362,7 @@ const firstPage: string | undefined = undefined;
|
|
|
333
362
|
* `owner`'s repositories in `filter`'s order, a page at a time, as the list scrolls on, with the
|
|
334
363
|
* drop-in filtering what its list takes: a route's loader reads the first page before it draws.
|
|
335
364
|
*/
|
|
336
|
-
export const repoList = (owner: Owner, filter: RepoFilter) => {
|
|
365
|
+
export const repoList = (clients: Clients, owner: Owner, filter: RepoFilter) => {
|
|
337
366
|
const query: RepoQuery = { sort: filter.sort, type: serverType(owner, filter.type) };
|
|
338
367
|
|
|
339
368
|
// Its pages' param named, as the loaders' `readPagesAhead` reads it, where the default is `unknown`.
|
|
@@ -345,7 +374,7 @@ export const repoList = (owner: Owner, filter: RepoFilter) => {
|
|
|
345
374
|
string | undefined
|
|
346
375
|
>({
|
|
347
376
|
queryKey: ['repos', owner.kind, owner.login, query.sort, query.type],
|
|
348
|
-
queryFn: ({ pageParam }) => repoPage(owner, query, pageParam),
|
|
377
|
+
queryFn: ({ pageParam }) => repoPage(clients, owner, query, pageParam),
|
|
349
378
|
initialPageParam: firstPage,
|
|
350
379
|
getNextPageParam: (last: RepoPage) => last.next,
|
|
351
380
|
});
|
|
@@ -358,13 +387,37 @@ export const repoList = (owner: Owner, filter: RepoFilter) => {
|
|
|
358
387
|
*/
|
|
359
388
|
export const useRepos = (owner: Owner, filter: RepoFilter) =>
|
|
360
389
|
useInfiniteQuery({
|
|
361
|
-
...repoList(owner, filter),
|
|
390
|
+
...repoList(useClients(), owner, filter),
|
|
362
391
|
placeholderData: (previous, previousQuery) =>
|
|
363
392
|
previousQuery?.queryKey[1] === owner.kind && previousQuery.queryKey[2] === owner.login
|
|
364
393
|
? previous
|
|
365
394
|
: undefined,
|
|
366
395
|
});
|
|
367
396
|
|
|
397
|
+
/**
|
|
398
|
+
* `owner`'s repository names in `list`'s order, as a switcher's menu reads them: once `enabled`,
|
|
399
|
+
* and, while `seeking` holds for the names loaded, a page after each until the list ends,
|
|
400
|
+
* `maxFiltered` names are in, or a read fails. `reading` says it's reading on.
|
|
401
|
+
*/
|
|
402
|
+
export const useRepoNames = (
|
|
403
|
+
owner: Owner,
|
|
404
|
+
list: RepoFilter,
|
|
405
|
+
enabled: boolean,
|
|
406
|
+
seeking: (names: readonly string[]) => boolean,
|
|
407
|
+
) => {
|
|
408
|
+
const repos = useInfiniteQuery({ ...repoList(useClients(), owner, list), enabled });
|
|
409
|
+
const names = repos.data?.pages.flatMap((page) => page.repos.map((repo) => repo.name)) ?? [];
|
|
410
|
+
const reading =
|
|
411
|
+
seeking(names) && repos.hasNextPage && names.length < maxFiltered && !repos.isError;
|
|
412
|
+
const { fetchNextPage, isFetchingNextPage } = repos;
|
|
413
|
+
|
|
414
|
+
useEffect(() => {
|
|
415
|
+
if (reading && !isFetchingNextPage) void fetchNextPage();
|
|
416
|
+
}, [reading, isFetchingNextPage, fetchNextPage, names.length]);
|
|
417
|
+
|
|
418
|
+
return { repos, names, reading };
|
|
419
|
+
};
|
|
420
|
+
|
|
368
421
|
/** What a list shows of the repositories it has loaded. */
|
|
369
422
|
export interface RepoFilter {
|
|
370
423
|
readonly search: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { queryOptions } from '@tanstack/react-query';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import type { Clients } from '../clients/clients.ts';
|
|
4
4
|
import { failure } from '../hooks/answers.ts';
|
|
5
5
|
import { nextCursor } from '../hooks/repos.ts';
|
|
6
6
|
import { inboxListKey } from './threads.ts';
|
|
@@ -36,35 +36,36 @@ const pollMsOf = (headers: Headers) => {
|
|
|
36
36
|
* nothing redraws and no list reads again. Any other answer to a held copy reads the inbox's lists
|
|
37
37
|
* again, so an open Inbox page shows what came, its `Last-Modified` moved or not.
|
|
38
38
|
*/
|
|
39
|
-
export const inboxCount =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
export const inboxCount = (clients: Clients) =>
|
|
40
|
+
queryOptions({
|
|
41
|
+
queryKey: ['inbox', 'count'],
|
|
42
|
+
queryFn: async ({ client, queryKey }): Promise<InboxCount> => {
|
|
43
|
+
const held = client.getQueryData<InboxCount>(queryKey);
|
|
44
|
+
const answer = await clients.github.GET('/notifications', {
|
|
45
|
+
params: { query: { per_page: countedMost } },
|
|
46
|
+
headers: held?.modified === undefined ? {} : { 'if-modified-since': held.modified },
|
|
47
|
+
});
|
|
48
|
+
if (answer.response.status === 304 && held !== undefined) return held;
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
if (answer.data === undefined) throw failure("The inbox's count didn't load", answer);
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
const { headers } = answer.response;
|
|
53
|
+
const counted: InboxCount = {
|
|
54
|
+
count: answer.data.filter((thread) => thread.unread).length,
|
|
55
|
+
more: nextCursor(headers.get('link')) !== undefined,
|
|
56
|
+
modified: headers.get('last-modified') ?? undefined,
|
|
57
|
+
pollMs: pollMsOf(headers),
|
|
58
|
+
};
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
// A 200 to the copy's If-Modified-Since is a change, even under the same Last-Modified: a
|
|
61
|
+
// change in the second that copy names keeps it, since HTTP's dates hold whole seconds.
|
|
62
|
+
if (held !== undefined && (held.modified !== undefined || counted.modified !== undefined)) {
|
|
63
|
+
await client.invalidateQueries({ queryKey: inboxListKey });
|
|
64
|
+
}
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
});
|
|
66
|
+
return counted;
|
|
67
|
+
},
|
|
68
|
+
refetchInterval: (query) => query.state.data?.pollMs ?? pollSeconds * 1000,
|
|
69
|
+
refetchOnWindowFocus: 'always',
|
|
70
|
+
retry: false,
|
|
71
|
+
});
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
SidebarMenuButton,
|
|
11
11
|
SidebarMenuItem,
|
|
12
12
|
} from '../components/ui/sidebar.tsx';
|
|
13
|
+
import { useClients } from '../clients/clients.ts';
|
|
13
14
|
import { inboxCount } from './count.ts';
|
|
14
15
|
|
|
15
16
|
/** The Inbox page's own path. */
|
|
@@ -25,7 +26,8 @@ export const inInbox = (path: string) =>
|
|
|
25
26
|
* count of none, one that hasn't come, or one that failed, leaves the end to the keys.
|
|
26
27
|
*/
|
|
27
28
|
export function InboxItem({ path }: { readonly path: string }) {
|
|
28
|
-
const
|
|
29
|
+
const clients = useClients();
|
|
30
|
+
const counted = useQuery(inboxCount(clients)).data;
|
|
29
31
|
const here = inInbox(path);
|
|
30
32
|
|
|
31
33
|
return (
|
|
@@ -14,6 +14,7 @@ import { type RefObject, useEffect, useRef, useState } from 'react';
|
|
|
14
14
|
|
|
15
15
|
import { cn } from '#/lib/cn';
|
|
16
16
|
|
|
17
|
+
import { useClients } from '../clients/clients.ts';
|
|
17
18
|
import { Go, usePreloaded } from '../code/controls.tsx';
|
|
18
19
|
import { typesInto } from '../components/hotkeys/hotkeys.tsx';
|
|
19
20
|
import { ItemList, More } from '../components/item-list.tsx';
|
|
@@ -384,7 +385,8 @@ function Marks({
|
|
|
384
385
|
* and `e` marks the focused one done.
|
|
385
386
|
*/
|
|
386
387
|
function Threads({ filter }: { readonly filter: InboxFilter }) {
|
|
387
|
-
const
|
|
388
|
+
const clients = useClients();
|
|
389
|
+
const pages = useInfiniteQuery(inboxList(clients, filter));
|
|
388
390
|
const loaded = pages.data?.pages ?? [];
|
|
389
391
|
const threads = loaded.flatMap((page) => page.threads);
|
|
390
392
|
const states = useSubjectStates(loaded);
|
|
@@ -548,7 +550,8 @@ function Filters({
|
|
|
548
550
|
* by repo, newest first. `j` and `k` move between rows, Enter opens one, and `e` marks it done.
|
|
549
551
|
*/
|
|
550
552
|
export function InboxPage({ filter }: { readonly filter: InboxFilter }) {
|
|
551
|
-
const
|
|
553
|
+
const clients = useClients();
|
|
554
|
+
const pages = useInfiniteQuery(inboxList(clients, filter));
|
|
552
555
|
const repos = [
|
|
553
556
|
...new Set(
|
|
554
557
|
(pages.data?.pages ?? []).flatMap((page) =>
|
|
@@ -2,7 +2,7 @@ import { useMutation, useMutationState, useQueryClient } from '@tanstack/react-q
|
|
|
2
2
|
import { toast } from 'sonner';
|
|
3
3
|
|
|
4
4
|
import { atMost } from '../clients/at-most.ts';
|
|
5
|
-
import {
|
|
5
|
+
import { type Clients, useClients } from '../clients/clients.ts';
|
|
6
6
|
import type { RepoPlace } from '../code/places.ts';
|
|
7
7
|
import { failure } from '../hooks/answers.ts';
|
|
8
8
|
import { inboxCount } from './count.ts';
|
|
@@ -22,19 +22,24 @@ export type Mark =
|
|
|
22
22
|
/** Each thread mark's call, GitHub's `PATCH` or `DELETE` on the thread, and what its failure says. */
|
|
23
23
|
const threadMarks = {
|
|
24
24
|
read: {
|
|
25
|
-
send: (thread_id: number) =>
|
|
26
|
-
github.PATCH('/notifications/threads/{thread_id}', {
|
|
25
|
+
send: (clients: Clients, thread_id: number) =>
|
|
26
|
+
clients.github.PATCH('/notifications/threads/{thread_id}', {
|
|
27
|
+
params: { path: { thread_id } },
|
|
28
|
+
}),
|
|
27
29
|
failed: "The notification wasn't marked read",
|
|
28
30
|
},
|
|
29
31
|
done: {
|
|
30
|
-
send: (thread_id: number) =>
|
|
31
|
-
github.DELETE('/notifications/threads/{thread_id}', {
|
|
32
|
+
send: (clients: Clients, thread_id: number) =>
|
|
33
|
+
clients.github.DELETE('/notifications/threads/{thread_id}', {
|
|
34
|
+
params: { path: { thread_id } },
|
|
35
|
+
}),
|
|
32
36
|
failed: "The notification wasn't marked done",
|
|
33
37
|
},
|
|
34
38
|
} as const satisfies Record<
|
|
35
39
|
ThreadMark,
|
|
36
40
|
{
|
|
37
41
|
readonly send: (
|
|
42
|
+
clients: Clients,
|
|
38
43
|
id: number,
|
|
39
44
|
) => Promise<{ readonly error?: unknown; readonly response: Response }>;
|
|
40
45
|
readonly failed: string;
|
|
@@ -45,16 +50,16 @@ const threadMarks = {
|
|
|
45
50
|
const marksAtOnce = 4;
|
|
46
51
|
|
|
47
52
|
/** The thread `id` marked as `kind` says. */
|
|
48
|
-
const markOne = async (kind: ThreadMark, id: string) => {
|
|
53
|
+
const markOne = async (clients: Clients, kind: ThreadMark, id: string) => {
|
|
49
54
|
const { send, failed } = threadMarks[kind];
|
|
50
|
-
const answer = await send(Number(id));
|
|
55
|
+
const answer = await send(clients, Number(id));
|
|
51
56
|
if (!answer.response.ok) throw failure(failed, answer);
|
|
52
57
|
};
|
|
53
58
|
|
|
54
59
|
/** What marking the thread `id` threw, once its call has answered, or `undefined` if it didn't. */
|
|
55
|
-
const failureOf = async (kind: ThreadMark, id: string) => {
|
|
60
|
+
const failureOf = async (clients: Clients, kind: ThreadMark, id: string) => {
|
|
56
61
|
try {
|
|
57
|
-
await markOne(kind, id);
|
|
62
|
+
await markOne(clients, kind, id);
|
|
58
63
|
|
|
59
64
|
return undefined;
|
|
60
65
|
} catch (failure) {
|
|
@@ -66,12 +71,15 @@ const failureOf = async (kind: ThreadMark, id: string) => {
|
|
|
66
71
|
* Every unread thread updated at or before `upTo` marked read: a thread that came after the page
|
|
67
72
|
* showed its newest stays unread. GitHub's words when a job marks the rest later, else nothing.
|
|
68
73
|
*/
|
|
69
|
-
const markAll = async (repo: RepoPlace | undefined, upTo: string) => {
|
|
74
|
+
const markAll = async (clients: Clients, repo: RepoPlace | undefined, upTo: string) => {
|
|
70
75
|
const body = { last_read_at: upTo, read: true };
|
|
71
76
|
const answer =
|
|
72
77
|
repo === undefined
|
|
73
|
-
? await github.PUT('/notifications', { body })
|
|
74
|
-
: await github.PUT('/repos/{owner}/{repo}/notifications', {
|
|
78
|
+
? await clients.github.PUT('/notifications', { body })
|
|
79
|
+
: await clients.github.PUT('/repos/{owner}/{repo}/notifications', {
|
|
80
|
+
params: { path: repo },
|
|
81
|
+
body,
|
|
82
|
+
});
|
|
75
83
|
if (!answer.response.ok) throw failure("The inbox wasn't marked read", answer);
|
|
76
84
|
|
|
77
85
|
return answer.response.status === 202 ? answer.data?.message : undefined;
|
|
@@ -87,16 +95,19 @@ const markKey = ['inbox', 'mark'] as const;
|
|
|
87
95
|
* own mark has, and `pending` holds while any is waiting or running.
|
|
88
96
|
*/
|
|
89
97
|
export const useInboxMark = () => {
|
|
98
|
+
const clients = useClients();
|
|
90
99
|
const queries = useQueryClient();
|
|
91
100
|
const { mutateAsync } = useMutation({
|
|
92
101
|
mutationKey: markKey,
|
|
93
102
|
scope: { id: markKey.join('/') },
|
|
94
103
|
mutationFn: async (mark: Mark) => {
|
|
95
|
-
if (mark.kind === 'all') return markAll(mark.repo, mark.upTo);
|
|
104
|
+
if (mark.kind === 'all') return markAll(clients, mark.repo, mark.upTo);
|
|
96
105
|
|
|
97
106
|
// Every thread's call answers before the mark settles, failed or not, so the reads after it
|
|
98
107
|
// and the next mark wait for all of them.
|
|
99
|
-
const failures = await atMost(marksAtOnce, mark.ids, (id) =>
|
|
108
|
+
const failures = await atMost(marksAtOnce, mark.ids, (id) =>
|
|
109
|
+
failureOf(clients, mark.kind, id),
|
|
110
|
+
);
|
|
100
111
|
const failed = failures.find((failure) => failure !== undefined);
|
|
101
112
|
if (failed !== undefined) throw failed;
|
|
102
113
|
|
|
@@ -109,7 +120,7 @@ export const useInboxMark = () => {
|
|
|
109
120
|
onSettled: () =>
|
|
110
121
|
Promise.all([
|
|
111
122
|
queries.invalidateQueries({ queryKey: inboxListKey }),
|
|
112
|
-
queries.invalidateQueries({ queryKey: inboxCount.queryKey }),
|
|
123
|
+
queries.invalidateQueries({ queryKey: inboxCount(clients).queryKey }),
|
|
113
124
|
]),
|
|
114
125
|
});
|
|
115
126
|
const pending =
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { keepPreviousData, queryOptions, useQueries } from '@tanstack/react-query';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { type Clients, useClients } from '../clients/clients.ts';
|
|
4
4
|
import type { RepoPlace } from '../code/places.ts';
|
|
5
5
|
import type { ThreadPage } from './threads.ts';
|
|
6
6
|
|
|
7
7
|
/** A release's tag, read by its ID, or `undefined` for one gone, a 404, or a read that failed. */
|
|
8
|
-
const tagOf = async (place: RepoPlace, release: number) => {
|
|
8
|
+
const tagOf = async (clients: Clients, place: RepoPlace, release: number) => {
|
|
9
9
|
try {
|
|
10
|
-
const answer = await github.GET('/repos/{owner}/{repo}/releases/{release_id}', {
|
|
10
|
+
const answer = await clients.github.GET('/repos/{owner}/{repo}/releases/{release_id}', {
|
|
11
11
|
params: { path: { ...place, release_id: release } },
|
|
12
12
|
});
|
|
13
13
|
|
|
@@ -22,7 +22,7 @@ const tagOf = async (place: RepoPlace, release: number) => {
|
|
|
22
22
|
* none in turn, kept under the threads and the times each moved, as its subjects' states are. A
|
|
23
23
|
* read that fails leaves its thread out, once, with no error on the inbox.
|
|
24
24
|
*/
|
|
25
|
-
const releaseTags = (page: ThreadPage) => {
|
|
25
|
+
const releaseTags = (clients: Clients, page: ThreadPage) => {
|
|
26
26
|
const asked = page.threads.flatMap((thread) =>
|
|
27
27
|
thread.subject.kind === 'release' && thread.subject.release !== undefined
|
|
28
28
|
? [{ thread, release: thread.subject.release }]
|
|
@@ -37,7 +37,7 @@ const releaseTags = (page: ThreadPage) => {
|
|
|
37
37
|
],
|
|
38
38
|
queryFn: async (): Promise<ReadonlyMap<string, string>> => {
|
|
39
39
|
const tags = await Promise.all(
|
|
40
|
-
asked.map(({ thread, release }) => tagOf(thread.place, release)),
|
|
40
|
+
asked.map(({ thread, release }) => tagOf(clients, thread.place, release)),
|
|
41
41
|
);
|
|
42
42
|
|
|
43
43
|
return new Map(
|
|
@@ -59,7 +59,8 @@ const releaseTags = (page: ThreadPage) => {
|
|
|
59
59
|
* release threads' tags at once, kept as `useSubjectStates` keeps its subjects.
|
|
60
60
|
*/
|
|
61
61
|
export const useReleaseTags = (pages: readonly ThreadPage[]): ReadonlyMap<string, string> => {
|
|
62
|
-
const
|
|
62
|
+
const clients = useClients();
|
|
63
|
+
const answers = useQueries({ queries: pages.map((page) => releaseTags(clients, page)) });
|
|
63
64
|
|
|
64
65
|
return new Map(answers.flatMap((answer) => [...(answer.data ?? new Map())]));
|
|
65
66
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { keepPreviousData, queryOptions, useQueries } from '@tanstack/react-query';
|
|
2
2
|
import * as Schema from 'effect/Schema';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { type Clients, useClients } from '../clients/clients.ts';
|
|
5
5
|
import { subjectNumber, type ThreadPage } from './threads.ts';
|
|
6
6
|
|
|
7
7
|
/** What a row shows of its subject: its state, and who acted on it last. */
|
|
@@ -124,7 +124,7 @@ const actorOf = (node: Node) =>
|
|
|
124
124
|
* times each was updated, so a thread that moves reads again, and no other page does. A subject
|
|
125
125
|
* that isn't an issue or a pull request, or that the answer leaves `null`, has no state.
|
|
126
126
|
*/
|
|
127
|
-
const subjectStates = (page: ThreadPage) => {
|
|
127
|
+
const subjectStates = (clients: Clients, page: ThreadPage) => {
|
|
128
128
|
const asked = page.threads.flatMap((thread) => {
|
|
129
129
|
const number = subjectNumber(thread.subject);
|
|
130
130
|
|
|
@@ -146,7 +146,7 @@ const subjectStates = (page: ThreadPage) => {
|
|
|
146
146
|
],
|
|
147
147
|
);
|
|
148
148
|
const variables = Object.fromEntries(named);
|
|
149
|
-
const answer = await query(
|
|
149
|
+
const answer = await clients.query(
|
|
150
150
|
"The inbox's states",
|
|
151
151
|
subjectsOperation(asked.length),
|
|
152
152
|
variables,
|
|
@@ -178,7 +178,8 @@ const subjectStates = (page: ThreadPage) => {
|
|
|
178
178
|
export const useSubjectStates = (
|
|
179
179
|
pages: readonly ThreadPage[],
|
|
180
180
|
): ReadonlyMap<string, SubjectState> => {
|
|
181
|
-
const
|
|
181
|
+
const clients = useClients();
|
|
182
|
+
const answers = useQueries({ queries: pages.map((page) => subjectStates(clients, page)) });
|
|
182
183
|
|
|
183
184
|
return new Map(answers.flatMap((answer) => [...(answer.data ?? new Map())]));
|
|
184
185
|
};
|
|
@@ -3,6 +3,7 @@ import { useLocation, useRouteContext } from '@tanstack/react-router';
|
|
|
3
3
|
import { BellIcon, BellOffIcon, ChevronDownIcon, EyeIcon, EyeOffIcon } from 'lucide-react';
|
|
4
4
|
import { toast } from 'sonner';
|
|
5
5
|
|
|
6
|
+
import { useClients } from '../clients/clients.ts';
|
|
6
7
|
import type { RepoPlace } from '../code/places.ts';
|
|
7
8
|
import { repoAt } from '../code/repo.ts';
|
|
8
9
|
import { signInHref } from '../components/states/states.tsx';
|
|
@@ -68,9 +69,13 @@ function Watchers({ count }: { readonly count: number }) {
|
|
|
68
69
|
*/
|
|
69
70
|
export function WatchMenu({ place }: { readonly place: RepoPlace }) {
|
|
70
71
|
const { viewer } = useRouteContext({ from: '__root__' });
|
|
72
|
+
const clients = useClients();
|
|
71
73
|
const here = useLocation({ select: (location) => location.href });
|
|
72
|
-
const watchers = useQuery(repoAt(place)).data?.watchers;
|
|
73
|
-
const subscription = useQuery({
|
|
74
|
+
const watchers = useQuery(repoAt(clients, place)).data?.watchers;
|
|
75
|
+
const subscription = useQuery({
|
|
76
|
+
...repoSubscription(clients, place),
|
|
77
|
+
enabled: viewer !== null,
|
|
78
|
+
}).data;
|
|
74
79
|
const change = useSubscriptionChange(place);
|
|
75
80
|
if (watchers === undefined) return null;
|
|
76
81
|
|
|
@@ -140,9 +145,13 @@ export function SubjectNotifications({
|
|
|
140
145
|
readonly number: number;
|
|
141
146
|
}) {
|
|
142
147
|
const { viewer } = useRouteContext({ from: '__root__' });
|
|
148
|
+
const clients = useClients();
|
|
143
149
|
const signedIn = viewer !== null;
|
|
144
|
-
const subject = useQuery({
|
|
145
|
-
|
|
150
|
+
const subject = useQuery({
|
|
151
|
+
...subjectSubscription(clients, place, number),
|
|
152
|
+
enabled: signedIn,
|
|
153
|
+
}).data;
|
|
154
|
+
const repo = useQuery({ ...repoSubscription(clients, place), enabled: signedIn }).data;
|
|
146
155
|
const change = useSubscriptionChange(place);
|
|
147
156
|
|
|
148
157
|
if (subject === undefined || subject === null || subject.state === null || repo === undefined) {
|
|
@@ -151,7 +160,7 @@ export function SubjectNotifications({
|
|
|
151
160
|
|
|
152
161
|
const { id, state } = subject;
|
|
153
162
|
const { line, next } = notificationsOf(
|
|
154
|
-
{ state, canSubscribe: subject.canSubscribe },
|
|
163
|
+
{ state, reason: subject.reason, canSubscribe: subject.canSubscribe },
|
|
155
164
|
repo?.state ?? null,
|
|
156
165
|
);
|
|
157
166
|
|