[MM-32371] Communicate history information to webapp for disable/enabling Back/Forward buttons (#1941)

* [MM-32371] Communicate history information to webapp for disable/enabling Back/Forward buttons

* Merge'd
This commit is contained in:
Devin Binnie
2022-01-10 17:38:23 -05:00
committed by GitHub
parent 8ad949eedb
commit 8f96fe42c7
6 changed files with 112 additions and 8 deletions

View File

@@ -3,9 +3,9 @@
// See LICENSE.txt for license information.
'use strict';
import {app, ipcMain, Menu, MenuItemConstructorOptions, MenuItem, session, shell, WebContents, webContents, clipboard} from 'electron';
import {app, ipcMain, Menu, MenuItemConstructorOptions, MenuItem, session, shell, WebContents, clipboard} from 'electron';
import {OPEN_TEAMS_DROPDOWN, SHOW_NEW_SERVER_MODAL} from 'common/communication';
import {BROWSER_HISTORY_BUTTON, OPEN_TEAMS_DROPDOWN, SHOW_NEW_SERVER_MODAL} from 'common/communication';
import {Config} from 'common/config';
import {TabType, getTabDisplayName} from 'common/tabs/TabView';
@@ -178,18 +178,20 @@ export function createTemplate(config: Config) {
label: 'Back',
accelerator: process.platform === 'darwin' ? 'Cmd+[' : 'Alt+Left',
click: () => {
const focused = webContents.getFocusedWebContents();
if (focused.canGoBack()) {
focused.goBack();
const view = WindowManager.viewManager?.getCurrentView();
if (view && view.view.webContents.canGoBack() && !view.isAtRoot) {
view.view.webContents.goBack();
ipcMain.emit(BROWSER_HISTORY_BUTTON, null, view.name);
}
},
}, {
label: 'Forward',
accelerator: process.platform === 'darwin' ? 'Cmd+]' : 'Alt+Right',
click: () => {
const focused = webContents.getFocusedWebContents();
if (focused.canGoForward()) {
focused.goForward();
const view = WindowManager.viewManager?.getCurrentView();
if (view && view.view.webContents.canGoForward()) {
view.view.webContents.goForward();
ipcMain.emit(BROWSER_HISTORY_BUTTON, null, view.name);
}
},
}],