Skip to content

Commit a6ded7e

Browse files
committed
fix(desktop): stop overwriting a custom dock icon on launch
1 parent 2f486ab commit a6ded7e

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ describe("DesktopAppIdentity", () => {
199199
assert.equal(calls.setAboutPanelOptions[0]?.applicationName, "T3 Code (Alpha)");
200200
assert.equal(calls.setAboutPanelOptions[0]?.applicationVersion, "1.2.3");
201201
assert.equal(calls.setAboutPanelOptions[0]?.version, "0123456789ab");
202-
assert.deepEqual(calls.setDockIcon, ["/icon.png"]);
202+
// Packaged: the bundle's own icon stands, so a custom one the user
203+
// attached survives.
204+
assert.deepEqual(calls.setDockIcon, []);
203205
}),
204206
{
205207
calls,
@@ -212,4 +214,28 @@ describe("DesktopAppIdentity", () => {
212214
},
213215
);
214216
});
217+
218+
it.effect("sets the dock icon only when running unpackaged", () => {
219+
const calls: ElectronAppCalls = {
220+
setAboutPanelOptions: [],
221+
setDockIcon: [],
222+
setName: [],
223+
};
224+
225+
return withIdentity(
226+
Effect.gen(function* () {
227+
const identity = yield* DesktopAppIdentity.DesktopAppIdentity;
228+
yield* identity.configure;
229+
230+
// Electron shows a generic icon for an unpackaged run, which is the
231+
// reason this call exists at all.
232+
assert.deepEqual(calls.setDockIcon, ["/icon.png"]);
233+
}),
234+
{
235+
calls,
236+
environment: { isPackaged: false },
237+
pngIconPath: Option.some("/icon.png"),
238+
},
239+
);
240+
});
215241
});

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ export const make = Effect.gen(function* () {
134134
yield* electronApp.setDesktopName(environment.linuxDesktopEntryName);
135135
}
136136

137-
if (environment.platform === "darwin") {
137+
// Unpackaged runs only. A packaged bundle already carries its icon in
138+
// Info.plist, so setting the dock tile again changes nothing except to
139+
// overwrite a custom icon the user attached to the app themselves.
140+
if (environment.platform === "darwin" && !environment.isPackaged) {
138141
const iconPaths = yield* assets.iconPaths;
139142
yield* Option.match(iconPaths.png, {
140143
onNone: () => Effect.void,

0 commit comments

Comments
 (0)