Skip to content

Commit 22e6fbf

Browse files
fix: resolve auto-restart issue by adding restart-app IPC bridge
1 parent 2e7fb7a commit 22e6fbf

5 files changed

Lines changed: 36 additions & 10 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "api-documenter",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "Self-hosted Postman alternative with folder-level RBAC and offline-first documentation",
55
"main": "./out/main/index.js",
66
"author": "Praneeth Kulukuri",

src/main/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ ipcMain.handle('select-directory', async () => {
8686
})
8787

8888
ipcMain.handle('get-app-path', () => app.getPath('userData'))
89+
ipcMain.handle('get-app-version', () => app.getVersion())
8990

9091
// ─── HTTP Request Handler (Postman-like API testing) ─────────────
9192
ipcMain.handle('send-http-request', async (_event, opts: {
@@ -677,6 +678,10 @@ autoUpdater.on('error', (err) => {
677678
mainWindow?.webContents.send('update-status', 'error', err.message)
678679
})
679680

681+
ipcMain.handle('restart-app', () => {
682+
autoUpdater.quitAndInstall()
683+
})
684+
680685
app.whenReady().then(() => {
681686
// Check for updates on startup
682687
if (!is.dev) {

src/preload/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export interface ElectronAPI {
2929
readFile: (filePath: string) => Promise<{ success: boolean; data?: string; error?: string }>
3030
selectDirectory: () => Promise<string | null>
3131
getAppPath: () => Promise<string>
32+
getAppVersion: () => Promise<string>
3233
// HTTP requests
3334
sendHttpRequest: (opts: HttpRequestOptions) => Promise<HttpResponse>
3435
// Remote DB management
@@ -46,6 +47,7 @@ export interface ElectronAPI {
4647
deployToVercel: (params: { databaseUrl: string, adminToken?: string, projectId: string, projectName: string }) => Promise<{ success: boolean; url?: string; error?: string }>
4748
deleteVercelProject: (params: { projectId: string, projectName: string }) => Promise<{ success: boolean; error?: string }>
4849
onDeployOutput: (callback: (data: string) => void) => () => void
50+
restartApp: () => Promise<void>
4951
// Updates
5052
onUpdateStatus: (callback: (status: string, version?: string) => void) => () => void
5153
onUpdateProgress: (callback: (percent: number) => void) => () => void
@@ -62,6 +64,7 @@ const electronAPI: ElectronAPI = {
6264
readFile: (filePath) => ipcRenderer.invoke('read-file', filePath),
6365
selectDirectory: () => ipcRenderer.invoke('select-directory'),
6466
getAppPath: () => ipcRenderer.invoke('get-app-path'),
67+
getAppVersion: () => ipcRenderer.invoke('get-app-version'),
6568
sendHttpRequest: (opts) => ipcRenderer.invoke('send-http-request', opts),
6669
testDbConnection: (url) => ipcRenderer.invoke('test-db-connection', url),
6770
createRemoteTables: (url) => ipcRenderer.invoke('create-remote-tables', url),
@@ -76,6 +79,7 @@ const electronAPI: ElectronAPI = {
7679
// Deployment
7780
deployToVercel: (params) => ipcRenderer.invoke('deploy-to-vercel', params),
7881
deleteVercelProject: (params) => ipcRenderer.invoke('delete-vercel-project', params),
82+
restartApp: () => ipcRenderer.invoke('restart-app'),
7983
onDeployOutput: (callback) => {
8084
const subscription = (_event: any, data: string) => callback(data)
8185
ipcRenderer.on('deploy-output', subscription)

src/renderer/src/components/Sidebar.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ export function Sidebar() {
3232
const [ctx, setCtx] = useState<{ x: number; y: number; type: 'folder' | 'api'; id: string } | null>(null)
3333
const [confirmDelete, setConfirmDelete] = useState<{ type: 'folder' | 'api'; id: string; folderId?: string; projectId?: string } | null>(null)
3434
const [isActionsExpanded, setIsActionsExpanded] = useState(false) // Added state for collapsible actions
35+
const [version, setVersion] = useState<string>('')
36+
37+
useEffect(() => {
38+
; (window as any).electronAPI.getAppVersion().then(setVersion)
39+
}, [])
3540

3641
useEffect(() => { const h = () => setCtx(null); window.addEventListener('click', h); return () => window.removeEventListener('click', h) }, [])
3742

@@ -260,15 +265,18 @@ export function Sidebar() {
260265
})()}
261266

262267
{/* ═══ Footer meta ═══ */}
263-
<div className="text-[10px] font-medium" style={{ flexShrink: 0, padding: '8px 16px', borderTop: '1px solid #1A1A1A', color: '#6B7280' }}>
264-
{folders?.length || 0} folders · {(() => {
265-
if (!currentProjectId) return 'No project'
266-
const p = projects?.find(x => x.id === currentProjectId)
267-
const hasD = p?.databaseUrl && p.databaseUrl.trim() !== ''
268-
const hasP = p?.proxyUrl && p.proxyUrl.trim() !== ''
269-
if (hasD || hasP) return 'Remote'
270-
return 'Local'
271-
})()}
268+
<div className="text-[10px] font-medium" style={{ flexShrink: 0, padding: '8px 16px', borderTop: '1px solid #1A1A1A', color: '#6B7280', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
269+
<span>
270+
{folders?.length || 0} folders · {(() => {
271+
if (!currentProjectId) return 'No project'
272+
const p = projects?.find(x => x.id === currentProjectId)
273+
const hasD = p?.databaseUrl && p.databaseUrl.trim() !== ''
274+
const hasP = p?.proxyUrl && p.proxyUrl.trim() !== ''
275+
if (hasD || hasP) return 'Remote'
276+
return 'Local'
277+
})()}
278+
</span>
279+
<span style={{ opacity: 0.5, fontStyle: 'italic' }}>v{version}</span>
272280
</div>
273281
</aside>
274282

src/renderer/src/components/UpdaterNotifier.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ export function UpdaterNotifier() {
3030
}
3131
}, [])
3232

33+
useEffect(() => {
34+
if (status === 'downloaded') {
35+
const timer = setTimeout(() => {
36+
; (window as any).electronAPI.restartApp()
37+
}, 3000)
38+
return () => clearTimeout(timer)
39+
}
40+
}, [status])
41+
3342
if (!visible) return null
3443

3544
return (

0 commit comments

Comments
 (0)