Skip to content

Commit

Permalink
support close action from studio
Browse files Browse the repository at this point in the history
  • Loading branch information
invisal committed Dec 4, 2024
1 parent 9efac5f commit ec206c5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function createDatabaseWindow(conn: ConnectionStoreItem) {
show: false,
width: 1024,
height: 768,
// autoHideMenuBar: true,
autoHideMenuBar: true,
webPreferences: {
devTools: true,
additionalArguments: ["--database=" + conn.id],
Expand All @@ -74,7 +74,7 @@ function createDatabaseWindow(conn: ConnectionStoreItem) {

const queryString = new URLSearchParams({ name: conn.name }).toString();

dbWindow.on("close", () => {
dbWindow.on("closed", () => {
win?.show();
ConnectionPool.close(conn.id);
});
Expand Down Expand Up @@ -200,6 +200,12 @@ ipcMain.handle(
},
);

ipcMain.handle("close", async (sender) => {
sender.sender.close({
waitForBeforeUnload: true,
});
});

ipcMain.handle("connect", (_, conn: ConnectionStoreItem) => {
createDatabaseWindow(conn);
if (win) win.hide();
Expand Down
4 changes: 4 additions & 0 deletions electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ const outerbaseIpc = {
return ipcRenderer.invoke("transaction", connectionId, statements);
},

close() {
return ipcRenderer.invoke("close");
},

connect(conn: ConnectionStoreItem) {
return ipcRenderer.invoke("connect", conn);
},
Expand Down

0 comments on commit ec206c5

Please sign in to comment.