Skip to content

Commit

Permalink
Merge pull request #1566 from hollow-owl/master
Browse files Browse the repository at this point in the history
Fix Mouse back button not doing anything
  • Loading branch information
nukeop authored Mar 13, 2024
2 parents 779a4ad + f91cfe3 commit 6ad71a5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/app/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class App extends React.PureComponent {

this.updateConnectivityStatus(navigator.onLine);
window.addEventListener('online', () => this.updateConnectivityStatus(true));
window.addEventListener('offline', () => this.updateConnectivityStatus(false));
window.addEventListener('offline', () => this.updateConnectivityStatus(false));
}

updateConnectivityStatus = (isConnected) => {
Expand Down
11 changes: 11 additions & 0 deletions packages/app/app/containers/IpcContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ class IpcContainer extends React.Component {
}
});

ipcRenderer.on(IpcEvents.NAVIGATE_BACK, () => {
if (this.props.history.index > 1) {
this.props.history.goBack();
}
});
ipcRenderer.on(IpcEvents.NAVIGATE_FORWARD, () => {
if (this.props.history.index < (this.props.history.length - 1)) {
this.props.history.goForward();
}
});

}

componentDidUpdate({ queue: prevQueue }) {
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/ipc/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ enum IpcEvents {

PLAY_STARTUP_TRACK = 'play-startup-track',

ELECTRON_TIMBER_ERROR_EVENT = '__ELECTRON_TIMBER_ERROR__'
ELECTRON_TIMBER_ERROR_EVENT = '__ELECTRON_TIMBER_ERROR__',

NAVIGATE_BACK = 'navigate-back',
NAVIGATE_FORWARD = 'navigate-forward',

}

export default IpcEvents;
11 changes: 11 additions & 0 deletions packages/main/src/services/window/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Config from '../config';
import Logger, { $mainLogger, $ipcLogger } from '../logger';
import Platform from '../platform';
import Store from '../store';
import { IpcEvents } from '@nuclear/core';

const urlMapper: Record<Env, string> = {
[Env.DEV]: url.format({
Expand Down Expand Up @@ -79,6 +80,16 @@ class Window {
this.browserWindow.once('focus', () => this.browserWindow.flashFrame(false));
}

this.browserWindow.on('app-command', (e, cmd) => {
if (cmd === 'browser-backward') {
this.browserWindow.webContents.send(IpcEvents.NAVIGATE_BACK);

}
if (cmd === 'browser-forward') {
this.browserWindow.webContents.send(IpcEvents.NAVIGATE_FORWARD);
}
});

this.isReady = new Promise((resolve) => {
this.resolve = resolve;
});
Expand Down

0 comments on commit 6ad71a5

Please sign in to comment.