mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-09 06:55:03 +00:00
[Feature] Prompt user to save requests before exiting app (#1317)
* Starting quit flow and focusing in draft * Finishing app if there is no draft to save * Automatically opening request after creation through event queue * Fix remove events from queue using pathname to find item * Removing updateNextAction * Listening via predicate * Confirm close dialog toggle moved to store * Draft operations as tab actions * Complete quit flow * Fixing close app/window hooks * Breaking the chain when dismissing dialog * Displaying request name in ConfirmRequestClose modal * Added disableEscapeKey and disableCloseOnOutsideClick props to Modal (passed in ConfirmRequestClose) * Removing logs * Refactor * listenerMiddleware module * ipc events listeners names * Update next action * Helpful comments * Eventually handle events to close request even if is no draft * Request name in bold
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
const path = require('path');
|
||||
const isDev = require('electron-is-dev');
|
||||
const { format } = require('url');
|
||||
const { BrowserWindow, app, Menu } = require('electron');
|
||||
const { BrowserWindow, app, Menu, ipcMain } = require('electron');
|
||||
const { setContentSecurityPolicy } = require('electron-util');
|
||||
|
||||
const menuTemplate = require('./app/menu-template');
|
||||
@@ -97,6 +97,10 @@ app.on('ready', async () => {
|
||||
|
||||
mainWindow.on('maximize', () => saveMaximized(true));
|
||||
mainWindow.on('unmaximize', () => saveMaximized(false));
|
||||
mainWindow.on('close', (e) => {
|
||||
e.preventDefault();
|
||||
ipcMain.emit('main:start-quit-flow');
|
||||
});
|
||||
|
||||
mainWindow.webContents.on('will-redirect', (event, url) => {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const _ = require('lodash');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { ipcMain, shell, dialog } = require('electron');
|
||||
const { ipcMain, shell, dialog, app } = require('electron');
|
||||
const { envJsonToBru, bruToJson, jsonToBru, jsonToCollectionBru } = require('../bru');
|
||||
|
||||
const {
|
||||
@@ -585,6 +585,14 @@ const registerMainEventHandlers = (mainWindow, watcher, lastOpenedCollections) =
|
||||
watcher.addWatcher(win, pathname, uid);
|
||||
lastOpenedCollections.add(pathname);
|
||||
});
|
||||
|
||||
ipcMain.on('main:start-quit-flow', () => {
|
||||
mainWindow.webContents.send('main:start-quit-flow');
|
||||
});
|
||||
|
||||
ipcMain.handle('main:complete-quit-flow', () => {
|
||||
mainWindow.destroy();
|
||||
});
|
||||
};
|
||||
|
||||
const registerCollectionsIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
||||
|
||||
Reference in New Issue
Block a user