MCPcopy
hub / github.com/21st-dev/1code / registerIpcHandlers

Function registerIpcHandlers

src/main/windows/main.ts:43–542  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41let ipcHandlersRegistered = false
42
43function registerIpcHandlers(): void {
44 if (ipcHandlersRegistered) return
45 ipcHandlersRegistered = true
46
47 // App info
48 ipcMain.handle("app:version", () => app.getVersion())
49 ipcMain.handle("app:isPackaged", () => app.isPackaged)
50
51 // Windows: Frame preference persistence
52 ipcMain.handle("window:set-frame-preference", (_event, useNativeFrame: boolean) => {
53 try {
54 const settingsPath = join(app.getPath("userData"), "window-settings.json")
55 const settingsDir = app.getPath("userData")
56 mkdirSync(settingsDir, { recursive: true })
57 writeFileSync(settingsPath, JSON.stringify({ useNativeFrame }, null, 2))
58 return true
59 } catch (error) {
60 console.error("[Main] Failed to save frame preference:", error)
61 return false
62 }
63 })
64
65 // Windows: Get current window frame state
66 ipcMain.handle("window:get-frame-state", () => {
67 if (process.platform !== "win32") return false
68 try {
69 const settingsPath = join(app.getPath("userData"), "window-settings.json")
70 if (existsSync(settingsPath)) {
71 const settings = JSON.parse(readFileSync(settingsPath, "utf-8"))
72 return settings.useNativeFrame === true
73 }
74 return false // Default: frameless
75 } catch {
76 return false
77 }
78 })
79
80 // Note: Update checking is now handled by auto-updater module (lib/auto-updater.ts)
81 ipcMain.handle("app:set-badge", (event, count: number | null) => {
82 const win = getWindowFromEvent(event)
83 if (process.platform === "darwin") {
84 app.dock.setBadge(count ? String(count) : "")
85 } else if (process.platform === "win32" && win) {
86 // Windows: Update title with count as fallback
87 if (count !== null && count > 0) {
88 win.setTitle(`1Code (${count})`)
89 } else {
90 win.setTitle("1Code")
91 win.setOverlayIcon(null, "")
92 }
93 }
94 })
95
96 // Windows: Badge overlay icon
97 ipcMain.handle("app:set-badge-icon", (event, imageData: string | null) => {
98 const win = getWindowFromEvent(event)
99 if (process.platform === "win32" && win) {
100 if (imageData) {

Callers 1

createWindowFunction · 0.70

Calls 15

getBaseUrlFunction · 0.90
getAuthManagerFunction · 0.90
handleAuthCodeFunction · 0.90
registerGitWatcherIPCFunction · 0.90
registerThemeScannerIPCFunction · 0.90
getWindowFromEventFunction · 0.85
createWindowFunction · 0.85
setOptOutFunction · 0.85
validateSenderFunction · 0.85
showLoginPageInWindowFunction · 0.85
closeMethod · 0.80
focusChatOwnerMethod · 0.80

Tested by

no test coverage detected