Skip to content

Commit 5582155

Browse files
committed
refactor(github): notifications reader acquires GitHubRest from the environment
1 parent df12852 commit 5582155

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎packages/source-control-github/src/server/GitHubPullRequestApi.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@ export const make = Effect.gen(function* () {
927927
const sourceControlHost = yield* SourceControlHost.SourceControlHost;
928928
const fileSystem = yield* FileSystem.FileSystem;
929929
const revalidateChecks = yield* makeChecksRevalidator;
930+
const listPullRequestNotifications = yield* makeListPullRequestNotifications;
930931
const client = yield* GraphQLClient.make(PullRequestGraphQLGroup).pipe(
931932
Effect.provide(GitHubGraphQlClient.layer),
932933
);
@@ -2028,7 +2029,7 @@ export const make = Effect.gen(function* () {
20282029

20292030
getPullRequestSummary,
20302031
getPullRequestWatchFingerprint,
2031-
listPullRequestNotifications: makeListPullRequestNotifications(api),
2032+
listPullRequestNotifications,
20322033

20332034
getPullRequestDetail,
20342035
getPullRequestPreview: Effect.fn("GitHubPullRequestApi.getPullRequestPreview")(

‎packages/source-control-github/src/server/GitHubRest.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ describe("listPullRequestNotifications", () => {
647647
);
648648
return Effect.gen(function* () {
649649
yield* TestClock.setTime(NOW);
650-
const list = makeListPullRequestNotifications(yield* GitHubRest.GitHubRest);
650+
const list = yield* makeListPullRequestNotifications;
651651
const since = Date.parse("2026-10-05T11:55:00.400Z");
652652
const input = { host: "github.com", repository: "acme/web", since };
653653
expect(yield* list(input)).toBeNull();

‎packages/source-control-github/src/server/gitHubNotifications.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as DateTime from "effect/DateTime";
33
import * as Effect from "effect/Effect";
44
import * as Schema from "effect/Schema";
55

6-
import type * as GitHubRest from "./GitHubRest.ts";
6+
import * as GitHubRest from "./GitHubRest.ts";
77
import * as GitHubRequestPolicy from "./GitHubRequestPolicy.ts";
88

99
const OPERATION = "listPullRequestNotifications";
@@ -25,8 +25,9 @@ const decodeThreads = Schema.decodeUnknownEffect(
2525
* result as a 304 that costs no quota. Fine-grained and GitHub App tokens cannot read
2626
* notifications, so a refusal is null.
2727
*/
28-
export const makeListPullRequestNotifications = (rest: GitHubRest.GitHubRest["Service"]) =>
29-
Effect.fn("GitHubPullRequestApi.listPullRequestNotifications")(function* (input: {
28+
export const makeListPullRequestNotifications = Effect.gen(function* () {
29+
const rest = yield* GitHubRest.GitHubRest;
30+
return Effect.fn("GitHubPullRequestApi.listPullRequestNotifications")(function* (input: {
3031
readonly host: string;
3132
readonly repository: string;
3233
readonly since: number;
@@ -81,3 +82,4 @@ export const makeListPullRequestNotifications = (rest: GitHubRest.GitHubRest["Se
8182
truncated: threads.length >= PAGE_SIZE,
8283
} satisfies ProviderChangeRequestNotifications;
8384
});
85+
});

0 commit comments

Comments
 (0)