fix: properly handle single emoji as project icon

This commit is contained in:
Harshita 2025-09-06 06:00:52 +05:30
parent d35b1ef491
commit 3696d62fba
19 changed files with 575 additions and 37 deletions

View file

@ -1,4 +1,4 @@
import * as windowStateKeeper from 'electron-window-state';
import windowStateKeeper from 'electron-window-state';
import {
App,
BrowserWindow,
@ -159,7 +159,12 @@ export const createWindow = ({
} else {
log('Loading custom styles from ' + CSS_FILE_PATH);
const styles = readFileSync(CSS_FILE_PATH, { encoding: 'utf8' });
mainWin.webContents.insertCSS(styles).then(log).catch(error);
try {
mainWin.webContents.insertCSS(styles);
log('Custom styles loaded successfully');
} catch (cssError) {
error('Failed to load custom styles:', cssError);
}
}
});
});
@ -329,8 +334,8 @@ const appCloseHandler = (app: App): void => {
mainWin.on('closed', () => {
// Dereference the window object
mainWin = null;
mainWinModule.win = null;
mainWin = null as any;
mainWinModule.win = undefined;
});
mainWin.webContents.on('render-process-gone', (event, detailed) => {
@ -358,7 +363,7 @@ const appMinimizeHandler = (app: App): void => {
// For regular minimize (not to tray), also show overlay
showOverlayWindow();
if (IS_MAC) {
app.dock.show();
app.dock?.show();
}
}
});
@ -366,26 +371,37 @@ const appMinimizeHandler = (app: App): void => {
}
};
const upsertKeyValue = <T>(obj: T, keyToChange: string, value: string[]): T => {
const upsertKeyValue = <T extends Record<string, any> | undefined>(
obj: T,
keyToChange: string,
value: string[],
): T => {
if (!obj) return obj;
const keyToChangeLower = keyToChange.toLowerCase();
for (const key of Object.keys(obj)) {
if (key.toLowerCase() === keyToChangeLower) {
// Reassign old key
obj[key] = value;
(obj as any)[key] = value;
// Done
return;
return obj;
}
}
// Insert at end instead
obj[keyToChange] = value;
(obj as any)[keyToChange] = value;
return obj;
};
const removeKeyInAnyCase = <T>(obj: T, keyToRemove: string): T => {
const removeKeyInAnyCase = <T extends Record<string, any> | undefined>(
obj: T,
keyToRemove: string,
): T => {
if (!obj) return obj;
const keyToRemoveLower = keyToRemove.toLowerCase();
for (const key of Object.keys(obj)) {
if (key.toLowerCase() === keyToRemoveLower) {
delete obj[key];
return;
delete (obj as any)[key];
return obj;
}
}
return obj;
};

View file

@ -10,7 +10,8 @@
"skipLibCheck": true,
"typeRoots": ["node_modules/@types"],
"downlevelIteration": true,
"lib": ["dom"]
"lib": ["dom"],
"esModuleInterop": true
},
"include": ["main.ts", "**/*.ts"],
"exclude": ["../node_modules", "**/*.spec.ts"]