From 545efb9d4427283d60a5c18dd780a79479922aea Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Wed, 22 Aug 2018 12:38:18 +0900 Subject: [PATCH] refs #543 Fix focus logic in favourite --- .../TimelineSpace/Contents/Favourites.vue | 34 ++++++++++--------- .../TimelineSpace/Contents/Home.vue | 2 +- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/renderer/components/TimelineSpace/Contents/Favourites.vue b/src/renderer/components/TimelineSpace/Contents/Favourites.vue index 0b042783..c81d7a1c 100644 --- a/src/renderer/components/TimelineSpace/Contents/Favourites.vue +++ b/src/renderer/components/TimelineSpace/Contents/Favourites.vue @@ -2,16 +2,16 @@
-
+
@@ -35,7 +35,7 @@ export default { data () { return { heading: true, - focusedIndex: null + focusedId: null } }, computed: { @@ -81,7 +81,7 @@ export default { } }, focusedIndex: function (newState, oldState) { - if (newState >= 0 && this.heading) { + if (newState && this.heading) { this.heading = false } else if (newState === null && !this.heading) { this.heading = true @@ -147,24 +147,26 @@ export default { document.getElementById('scrollable'), 0 ) - this.focusedIndex = null + this.focusedId = null }, focusNext () { - if (this.focusedIndex === null) { - this.focusedIndex = 0 - } else if (this.focusedIndex < this.favourites.length) { - this.focusedIndex++ + const currentIndex = this.favourites.findIndex(toot => this.focusedId === toot.uri) + if (currentIndex === -1) { + this.focusedId = this.favourites[0].uri + } else if (currentIndex < this.favourites.length) { + this.focusedId = this.favourites[currentIndex + 1].uri } }, focusPrev () { - if (this.focusedIndex === 0) { - this.focusedIndex = null - } else if (this.focusedIndex > 0) { - this.focusedIndex-- + const currentIndex = this.favourites.findIndex(toot => this.focusedId === toot.uri) + if (currentIndex === 0) { + this.focusedId = null + } else if (currentIndex > 0) { + this.focusedId = this.favourites[currentIndex - 1].uri } }, - focusToot (index) { - this.focusedIndex = index + focusToot (message) { + this.focusedId = message.id } } } diff --git a/src/renderer/components/TimelineSpace/Contents/Home.vue b/src/renderer/components/TimelineSpace/Contents/Home.vue index 2471bb3d..1eac656c 100644 --- a/src/renderer/components/TimelineSpace/Contents/Home.vue +++ b/src/renderer/components/TimelineSpace/Contents/Home.vue @@ -4,7 +4,7 @@
-
+