Skip to content

Commit 9cb586a

Browse files
refactor: remove obsolete code (pingdotgg#9917)
Co-authored-by: Julius Marminge <[email protected]>
1 parent e74c668 commit 9cb586a

116 files changed

Lines changed: 260 additions & 4095 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/desktop/src/app/DesktopAppIdentity.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const makeElectronAppLayer = (calls: ElectronAppCalls) =>
5757
}),
5858
setAppUserModelId: () => Effect.void,
5959
getAppMetrics: Effect.succeed([]),
60-
isDefaultProtocolClient: () => Effect.succeed(false),
6160
setAsDefaultProtocolClient: () => Effect.succeed(true),
6261
setDesktopName: () => Effect.void,
6362
setDockIcon: (iconPath) =>

‎apps/desktop/src/app/DesktopConnectionCatalogStore.test.ts‎

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { assert, describe, it } from "@effect/vitest";
33
import { ConnectionCatalogDocument } from "@t3tools/client-runtime/platform";
44
import { EnvironmentId, type PersistedSavedEnvironmentRecord } from "@t3tools/contracts";
55
import * as Effect from "effect/Effect";
6+
import * as Encoding from "effect/Encoding";
67
import * as FileSystem from "effect/FileSystem";
78
import * as Path from "effect/Path";
89
import * as Layer from "effect/Layer";
@@ -22,6 +23,11 @@ const textEncoder = new TextEncoder();
2223
const decodeConnectionCatalog = Schema.decodeEffect(
2324
Schema.fromJsonString(ConnectionCatalogDocument),
2425
);
26+
const encodeLegacySavedEnvironments = Schema.encodeEffect(
27+
Schema.fromJsonString(
28+
Schema.Struct({ version: Schema.Literal(1), records: Schema.Array(Schema.Unknown) }),
29+
),
30+
);
2531
function makeSafeStorageLayer(available: boolean, failDecrypt: Ref.Ref<boolean> | null = null) {
2632
return Layer.succeed(ElectronSafeStorage.ElectronSafeStorage, {
2733
isEncryptionAvailable: Effect.succeed(available),
@@ -125,7 +131,8 @@ describe("DesktopConnectionCatalogStore", () => {
125131
withStore(
126132
Effect.gen(function* () {
127133
const store = yield* DesktopConnectionCatalogStore.DesktopConnectionCatalogStore;
128-
const savedEnvironments = yield* DesktopSavedEnvironments.DesktopSavedEnvironments;
134+
const environment = yield* DesktopEnvironment.DesktopEnvironment;
135+
const fileSystem = yield* FileSystem.FileSystem;
129136
const records: readonly PersistedSavedEnvironmentRecord[] = [
130137
{
131138
environmentId: EnvironmentId.make("relay-environment"),
@@ -159,11 +166,21 @@ describe("DesktopConnectionCatalogStore", () => {
159166
lastConnectedAt: null,
160167
},
161168
];
162-
yield* savedEnvironments.setRegistry(records);
163-
assert.isTrue(
164-
yield* savedEnvironments.setSecret({
165-
environmentId: EnvironmentId.make("bearer-environment"),
166-
secret: "legacy-token",
169+
yield* fileSystem.makeDirectory(environment.stateDir, { recursive: true });
170+
yield* fileSystem.writeFileString(
171+
environment.savedEnvironmentRegistryPath,
172+
yield* encodeLegacySavedEnvironments({
173+
version: 1,
174+
records: records.map((record) =>
175+
record.environmentId === "bearer-environment"
176+
? {
177+
...record,
178+
encryptedBearerToken: Encoding.encodeBase64(
179+
textEncoder.encode("encrypted:legacy-token"),
180+
),
181+
}
182+
: record,
183+
),
167184
}),
168185
);
169186

@@ -218,7 +235,10 @@ describe("DesktopConnectionCatalogStore", () => {
218235
assert.equal(catalog.credentials[0].credential.token, "legacy-token");
219236
}
220237

221-
yield* savedEnvironments.setRegistry([]);
238+
yield* fileSystem.writeFileString(
239+
environment.savedEnvironmentRegistryPath,
240+
'{"version":1,"records":[]}',
241+
);
222242
assert.deepEqual(yield* store.get, migrated);
223243
}),
224244
),

‎apps/desktop/src/app/DesktopLifecycle.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ function makeElectronAppLayer(
4343
setAboutPanelOptions: () => Effect.void,
4444
setAppUserModelId: () => Effect.void,
4545
getAppMetrics: Effect.succeed([]),
46-
isDefaultProtocolClient: () => Effect.succeed(false),
4746
setAsDefaultProtocolClient: () => Effect.succeed(true),
4847
setDesktopName: () => Effect.void,
4948
setDockIcon: () => Effect.void,

‎apps/desktop/src/backend/DesktopBackendManager.test.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,7 @@ function makeTestInstance(input: MakeInstanceInput) {
165165
latest: Effect.succeed(Option.none()),
166166
changes: Stream.empty,
167167
encoded: input.desktopTelemetryStream ?? Stream.empty,
168-
handleControl: () => Effect.void,
169-
handleControlForSource: (_sourceId, message) =>
170-
(input.desktopTelemetryPublisher?.handleControl ?? (() => Effect.void))(message),
168+
handleControlForSource: () => Effect.void,
171169
removeControlSource: () => Effect.void,
172170
publishUpdateReport: () => Effect.void,
173171
updateRequests: Stream.empty,
@@ -596,7 +594,7 @@ describe("DesktopBackendManager", () => {
596594
const instance = yield* makeTestInstance({
597595
spawnerLayer,
598596
desktopTelemetryPublisher: {
599-
handleControl: (message) =>
597+
handleControlForSource: (_sourceId, message) =>
600598
message.type === "setDiagnosticsDemand"
601599
? Deferred.succeed(handled, message.enabled).pipe(Effect.asVoid)
602600
: Effect.void,

‎apps/desktop/src/backend/DesktopBackendPool.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ function makePoolLayer(
7070
latest: Effect.succeed(Option.none()),
7171
changes: Stream.empty,
7272
encoded: Stream.empty,
73-
handleControl: () => Effect.void,
7473
handleControlForSource: () => Effect.void,
7574
removeControlSource: () => Effect.void,
7675
publishUpdateReport: () => Effect.void,

‎apps/desktop/src/electron/ElectronApp.test.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const {
1010
getAppPathMock,
1111
getSystemLocaleMock,
1212
getVersionMock,
13-
isDefaultProtocolClientMock,
1413
onMock,
1514
quitMock,
1615
relaunchMock,
@@ -32,7 +31,6 @@ const {
3231
getAppPathMock: vi.fn(() => "/app"),
3332
getSystemLocaleMock: vi.fn(() => "en-GB"),
3433
getVersionMock: vi.fn(() => "1.2.3"),
35-
isDefaultProtocolClientMock: vi.fn(() => false),
3634
onMock: vi.fn(),
3735
quitMock: vi.fn(),
3836
relaunchMock: vi.fn(),
@@ -64,7 +62,6 @@ vi.mock("electron", () => ({
6462
getAppPath: getAppPathMock,
6563
getSystemLocale: getSystemLocaleMock,
6664
getVersion: getVersionMock,
67-
isDefaultProtocolClient: isDefaultProtocolClientMock,
6865
isPackaged: true,
6966
name: "T3 Code",
7067
on: onMock,

‎apps/desktop/src/electron/ElectronApp.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export class ElectronApp extends Context.Service<
6464
) => Effect.Effect<void>;
6565
readonly setAppUserModelId: (id: string) => Effect.Effect<void>;
6666
readonly getAppMetrics: Effect.Effect<ReadonlyArray<Electron.ProcessMetric>>;
67-
readonly isDefaultProtocolClient: (protocol: string) => Effect.Effect<boolean>;
6867
readonly setAsDefaultProtocolClient: (
6968
protocol: string,
7069
path?: string,
@@ -166,8 +165,6 @@ export const make = ElectronApp.of({
166165
Electron.app.setAppUserModelId(id);
167166
}),
168167
getAppMetrics: Effect.sync(() => Electron.app.getAppMetrics()),
169-
isDefaultProtocolClient: (protocol) =>
170-
Effect.sync(() => Electron.app.isDefaultProtocolClient(protocol)),
171168
setAsDefaultProtocolClient: (protocol, path, args) =>
172169
Effect.sync(() => {
173170
if (path === undefined) {

0 commit comments

Comments
 (0)