better back/forward navigation

This commit is contained in:
zadam
2020-03-08 17:17:18 +01:00
parent 5f4d963580
commit 493d088d80
4 changed files with 23 additions and 23 deletions
@@ -138,17 +138,11 @@ export default class Entrypoints extends Component {
}
backInNoteHistoryCommand() {
const electron = require('electron');
const {webContents} = electron.remote.getCurrentWindow();
webContents.goBack();
window.history.back();
}
forwardInNoteHistoryCommand() {console.log("forward");
const electron = require('electron');
const {webContents} = electron.remote.getCurrentWindow();
webContents.goForward();
forwardInNoteHistoryCommand() {
window.history.forward();
}
async searchForResultsCommand({searchText}) {
@@ -104,8 +104,8 @@ export default class TabManager extends Component {
setCurrentNotePathToHash() {
const activeTabContext = this.getActiveTabContext();
if (activeTabContext
&& activeTabContext.notePath !== treeService.getHashValueFromAddress()) {
if (window.history.length === 0 // first history entry
|| (activeTabContext && activeTabContext.notePath !== treeService.getHashValueFromAddress()[0])) {
const url = '#' + (activeTabContext.notePath || "") + "-" + activeTabContext.tabId;
// using pushState instead of directly modifying document.location because it does not trigger hashchange
@@ -117,9 +117,9 @@ export default class TabManager extends Component {
// it helps navigating in history if note title is included in the title
document.title += " - " + activeTabContext.note.title;
}
this.triggerEvent('activeNoteChanged');
}
this.triggerEvent('activeNoteChanged'); // trigger this even in on popstate event
}
/** @return {TabContext[]} */