diff --git a/src/renderer/App.js b/src/renderer/App.js
index 33af3ec8d..d4b97d6dc 100644
--- a/src/renderer/App.js
+++ b/src/renderer/App.js
@@ -138,6 +138,10 @@ export default Vue.extend({
this.checkForNewBlogPosts()
}, 500)
})
+
+ this.$router.afterEach((to, from) => {
+ this.$refs.topNav.navigateHistory()
+ })
})
},
methods: {
@@ -278,10 +282,10 @@ export default Vue.extend({
if (event.altKey) {
switch (event.code) {
case 'ArrowRight':
- window.history.forward()
+ this.$refs.topNav.historyForward()
break
case 'ArrowLeft':
- window.history.back()
+ this.$refs.topNav.historyBack()
break
}
}
diff --git a/src/renderer/components/top-nav/top-nav.js b/src/renderer/components/top-nav/top-nav.js
index 36175a51a..72e1de21e 100644
--- a/src/renderer/components/top-nav/top-nav.js
+++ b/src/renderer/components/top-nav/top-nav.js
@@ -20,6 +20,8 @@ export default Vue.extend({
windowWidth: 0,
showFilters: false,
searchFilterValueChanged: false,
+ historyIndex: 1,
+ isForwardOrBack: false,
searchSuggestionsDataList: []
}
},
@@ -257,12 +259,41 @@ export default Vue.extend({
this.searchFilterValueChanged = filterValueChanged
},
+ navigateHistory: function() {
+ if (!this.isForwardOrBack) {
+ this.historyIndex = window.history.length
+ $('#historyArrowBack').removeClass('fa-arrow-left')
+ $('#historyArrowForward').addClass('fa-arrow-right')
+ } else {
+ this.isForwardOrBack = false
+ }
+ },
+
historyBack: function () {
+ this.isForwardOrBack = true
window.history.back()
+
+ if (this.historyIndex > 1) {
+ this.historyIndex--
+ $('#historyArrowForward').removeClass('fa-arrow-right')
+ if (this.historyIndex === 1) {
+ $('#historyArrowBack').addClass('fa-arrow-left')
+ }
+ }
},
historyForward: function () {
+ this.isForwardOrBack = true
window.history.forward()
+
+ if (this.historyIndex < window.history.length) {
+ this.historyIndex++
+ $('#historyArrowBack').removeClass('fa-arrow-left')
+
+ if (this.historyIndex === window.history.length) {
+ $('#historyArrowForward').addClass('fa-arrow-right')
+ }
+ }
},
toggleSideNav: function () {
diff --git a/src/renderer/components/top-nav/top-nav.sass b/src/renderer/components/top-nav/top-nav.sass
index 19877f869..b926d7221 100644
--- a/src/renderer/components/top-nav/top-nav.sass
+++ b/src/renderer/components/top-nav/top-nav.sass
@@ -38,6 +38,12 @@
width: 1em
height: 1em
+ &.fa-arrow-left, &.fa-arrow-right
+ color: gray
+ opacity: 0.5
+ pointer-events: none
+ user-select: none
+
@include top-nav-is-colored
color: var(--text-with-main-color)
diff --git a/src/renderer/components/top-nav/top-nav.vue b/src/renderer/components/top-nav/top-nav.vue
index a714ad779..731f26450 100644
--- a/src/renderer/components/top-nav/top-nav.vue
+++ b/src/renderer/components/top-nav/top-nav.vue
@@ -13,7 +13,8 @@
@keypress="toggleSideNav"
/>