refs #543 Fix focus logic in favourite
This commit is contained in:
parent
cb8dfd51c9
commit
545efb9d44
|
@ -2,16 +2,16 @@
|
||||||
<div id="favourites">
|
<div id="favourites">
|
||||||
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
|
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
|
||||||
</div>
|
</div>
|
||||||
<div class="fav" v-for="(message, index) in favourites" v-bind:key="message.id">
|
<div class="fav" v-for="message in favourites" v-bind:key="message.id">
|
||||||
<toot
|
<toot
|
||||||
:message="message"
|
:message="message"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
:focused="index === focusedIndex"
|
:focused="message.uri === focusedId"
|
||||||
v-on:update="updateToot"
|
v-on:update="updateToot"
|
||||||
v-on:delete="deleteToot"
|
v-on:delete="deleteToot"
|
||||||
@focusNext="focusNext"
|
@focusNext="focusNext"
|
||||||
@focusPrev="focusPrev"
|
@focusPrev="focusPrev"
|
||||||
@selectToot="focusToot(index)"
|
@selectToot="focusToot(message)"
|
||||||
>
|
>
|
||||||
</toot>
|
</toot>
|
||||||
</div>
|
</div>
|
||||||
|
@ -35,7 +35,7 @@ export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
heading: true,
|
heading: true,
|
||||||
focusedIndex: null
|
focusedId: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -81,7 +81,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
focusedIndex: function (newState, oldState) {
|
focusedIndex: function (newState, oldState) {
|
||||||
if (newState >= 0 && this.heading) {
|
if (newState && this.heading) {
|
||||||
this.heading = false
|
this.heading = false
|
||||||
} else if (newState === null && !this.heading) {
|
} else if (newState === null && !this.heading) {
|
||||||
this.heading = true
|
this.heading = true
|
||||||
|
@ -147,24 +147,26 @@ export default {
|
||||||
document.getElementById('scrollable'),
|
document.getElementById('scrollable'),
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
this.focusedIndex = null
|
this.focusedId = null
|
||||||
},
|
},
|
||||||
focusNext () {
|
focusNext () {
|
||||||
if (this.focusedIndex === null) {
|
const currentIndex = this.favourites.findIndex(toot => this.focusedId === toot.uri)
|
||||||
this.focusedIndex = 0
|
if (currentIndex === -1) {
|
||||||
} else if (this.focusedIndex < this.favourites.length) {
|
this.focusedId = this.favourites[0].uri
|
||||||
this.focusedIndex++
|
} else if (currentIndex < this.favourites.length) {
|
||||||
|
this.focusedId = this.favourites[currentIndex + 1].uri
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
focusPrev () {
|
focusPrev () {
|
||||||
if (this.focusedIndex === 0) {
|
const currentIndex = this.favourites.findIndex(toot => this.focusedId === toot.uri)
|
||||||
this.focusedIndex = null
|
if (currentIndex === 0) {
|
||||||
} else if (this.focusedIndex > 0) {
|
this.focusedId = null
|
||||||
this.focusedIndex--
|
} else if (currentIndex > 0) {
|
||||||
|
this.focusedId = this.favourites[currentIndex - 1].uri
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
focusToot (index) {
|
focusToot (message) {
|
||||||
this.focusedIndex = index
|
this.focusedId = message.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
|
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
|
||||||
</div>
|
</div>
|
||||||
<transition-group name="timeline" tag="div">
|
<transition-group name="timeline" tag="div">
|
||||||
<div class="home-timeline" v-for="(message, index) in timeline" :key="message.uri">
|
<div class="home-timeline" v-for="message in timeline" :key="message.uri">
|
||||||
<toot
|
<toot
|
||||||
:message="message"
|
:message="message"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
|
|
Loading…
Reference in New Issue