super-productivity/electron/task-widget/task-widget-preload.ts
Johannes Millan 1ee9d7f566 refactor: rename overlay-indicator to task-widget
Rename the "overlay indicator" feature to "task widget" across the
entire codebase for clearer naming. Includes file renames, config key
migration, IPC event rename, and translation key updates.

Migration handles old persisted data from both the `overlayIndicator`
config key and the deprecated `misc.isOverlayIndicatorEnabled` field.
The `taskWidget` type is made optional in GlobalConfigState to prevent
Typia auto-fix from overwriting migrated values during upgrade.
2026-03-30 22:00:47 +02:00

26 lines
835 B
TypeScript

import { contextBridge, ipcRenderer } from 'electron';
contextBridge.exposeInMainWorld('taskWidgetAPI', {
showMainWindow: () => {
ipcRenderer.send('task-widget-show-main-window');
},
onUpdateContent: (callback: (data: any) => void) => {
const listener = (event: Electron.IpcRendererEvent, data: any): void =>
callback(data);
ipcRenderer.on('update-content', listener);
// Return cleanup function
return () => {
ipcRenderer.removeListener('update-content', listener);
};
},
onUpdateOpacity: (callback: (opacity: number) => void) => {
const listener = (_event: Electron.IpcRendererEvent, opacity: number): void =>
callback(opacity);
ipcRenderer.on('update-opacity', listener);
return () => {
ipcRenderer.removeListener('update-opacity', listener);
};
},
});