mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-02-08 15:58:42 +01:00
refs #543 Set shortcut key to move toot in notification
This commit is contained in:
parent
a63bfa7ea8
commit
f80d4183a9
@ -1,9 +1,40 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="notification">
|
<div class="notification">
|
||||||
<favourite v-if="message.type === 'favourite'" :message="message" :filter="filter"></favourite>
|
<favourite v-if="message.type === 'favourite'"
|
||||||
<follow v-else-if="message.type === 'follow'" :message="message"></follow>
|
:message="message"
|
||||||
<mention v-else-if="message.type === 'mention'" :message="message" :filter="filter"></mention>
|
:filter="filter"
|
||||||
<reblog v-else-if="message.type == 'reblog'" :message="message" :filter="filter"></reblog>
|
:focused="focused"
|
||||||
|
@focusNext="$emit('focusNext')"
|
||||||
|
@focusPrev="$emit('focusPrev')"
|
||||||
|
@select="$emit('selectNotification')"
|
||||||
|
>
|
||||||
|
</favourite>
|
||||||
|
<follow v-else-if="message.type === 'follow'"
|
||||||
|
:message="message"
|
||||||
|
:focused="focused"
|
||||||
|
@focusNext="$emit('focusNext')"
|
||||||
|
@focusPrev="$emit('focusPrev')"
|
||||||
|
@select="$emit('selectNotification')"
|
||||||
|
>
|
||||||
|
</follow>
|
||||||
|
<mention v-else-if="message.type === 'mention'"
|
||||||
|
:message="message"
|
||||||
|
:filter="filter"
|
||||||
|
:focused="focused"
|
||||||
|
@focusNext="$emit('focusNext')"
|
||||||
|
@focusPrev="$emit('focusPrev')"
|
||||||
|
@select="$emit('selectNotification')"
|
||||||
|
>
|
||||||
|
</mention>
|
||||||
|
<reblog v-else-if="message.type == 'reblog'"
|
||||||
|
:message="message"
|
||||||
|
:filter="filter"
|
||||||
|
:focused="focused"
|
||||||
|
@focusNext="$emit('focusNext')"
|
||||||
|
@focusPrev="$emit('focusPrev')"
|
||||||
|
@select="$emit('selectNotification')"
|
||||||
|
>
|
||||||
|
</reblog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -23,6 +54,10 @@ export default {
|
|||||||
filter: {
|
filter: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
|
},
|
||||||
|
focused: {
|
||||||
|
type: Boolean,
|
||||||
|
defalt: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: { Favourite, Follow, Mention, Reblog }
|
components: { Favourite, Follow, Mention, Reblog }
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="status" tabIndex="0">
|
<div
|
||||||
|
class="status"
|
||||||
|
tabIndex="0"
|
||||||
|
v-shortkey="{next: ['j'], prev: ['k']}"
|
||||||
|
@shortkey="handleStatusControl"
|
||||||
|
ref="status"
|
||||||
|
@click="$emit('select')"
|
||||||
|
>
|
||||||
<div v-show="filtered(message)" class="filtered">
|
<div v-show="filtered(message)" class="filtered">
|
||||||
Filtered
|
Filtered
|
||||||
</div>
|
</div>
|
||||||
@ -80,6 +87,10 @@ export default {
|
|||||||
filter: {
|
filter: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
|
},
|
||||||
|
focused: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
@ -88,6 +99,24 @@ export default {
|
|||||||
showAttachments: false
|
showAttachments: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted () {
|
||||||
|
if (this.focused) {
|
||||||
|
this.$refs.status.focus()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
focused: function (newState, oldState) {
|
||||||
|
if (newState) {
|
||||||
|
this.$nextTick(function () {
|
||||||
|
this.$refs.status.focus()
|
||||||
|
})
|
||||||
|
} else if (oldState && !newState) {
|
||||||
|
this.$nextTick(function () {
|
||||||
|
this.$refs.status.blur()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
username (account) {
|
username (account) {
|
||||||
if (account.display_name !== '') {
|
if (account.display_name !== '') {
|
||||||
@ -155,6 +184,16 @@ export default {
|
|||||||
},
|
},
|
||||||
spoilerText (message) {
|
spoilerText (message) {
|
||||||
return emojify(message.spoiler_text, message.emojis)
|
return emojify(message.spoiler_text, message.emojis)
|
||||||
|
},
|
||||||
|
handleStatusControl (event) {
|
||||||
|
switch (event.srcKey) {
|
||||||
|
case 'next':
|
||||||
|
this.$emit('focusNext')
|
||||||
|
break
|
||||||
|
case 'prev':
|
||||||
|
this.$emit('focusPrev')
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="follow" tabIndex="0">
|
<div
|
||||||
|
class="follow"
|
||||||
|
tabIndex="0"
|
||||||
|
v-shortkey="{next: ['j'], prev: ['k']}"
|
||||||
|
@shortkey="handleStatusControl"
|
||||||
|
ref="status"
|
||||||
|
@click="$emit('select')"
|
||||||
|
>
|
||||||
<div class="action">
|
<div class="action">
|
||||||
<div class="action-mark">
|
<div class="action-mark">
|
||||||
<icon name="user-plus" scale="0.7"></icon>
|
<icon name="user-plus" scale="0.7"></icon>
|
||||||
@ -19,7 +26,34 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'follow',
|
name: 'follow',
|
||||||
props: ['message'],
|
props: {
|
||||||
|
message: {
|
||||||
|
type: Object,
|
||||||
|
default: {}
|
||||||
|
},
|
||||||
|
focused: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
if (this.focused) {
|
||||||
|
this.$refs.status.focus()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
focused: function (newState, oldState) {
|
||||||
|
if (newState) {
|
||||||
|
this.$nextTick(function () {
|
||||||
|
this.$refs.status.focus()
|
||||||
|
})
|
||||||
|
} else if (oldState && !newState) {
|
||||||
|
this.$nextTick(function () {
|
||||||
|
this.$refs.status.blur()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
username (account) {
|
username (account) {
|
||||||
if (account.display_name !== '') {
|
if (account.display_name !== '') {
|
||||||
@ -32,6 +66,16 @@ export default {
|
|||||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/openAccountComponent')
|
this.$store.dispatch('TimelineSpace/Contents/SideBar/openAccountComponent')
|
||||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/changeAccount', account)
|
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/changeAccount', account)
|
||||||
this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', true)
|
this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', true)
|
||||||
|
},
|
||||||
|
handleStatusControl (event) {
|
||||||
|
switch (event.srcKey) {
|
||||||
|
case 'next':
|
||||||
|
this.$emit('focusNext')
|
||||||
|
break
|
||||||
|
case 'prev':
|
||||||
|
this.$emit('focusPrev')
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="mention">
|
<div class="mention">
|
||||||
<toot :message="message.status" :filter="filter" v-on:update="updateToot"></toot>
|
<toot
|
||||||
|
:message="message.status"
|
||||||
|
:filter="filter"
|
||||||
|
:focused="focused"
|
||||||
|
v-on:update="updateToot"
|
||||||
|
@focusNext="$emit('focusNext')"
|
||||||
|
@focusPrev="$emit('focusPrev')"
|
||||||
|
@selectToot="$emit('select')"
|
||||||
|
>
|
||||||
|
</toot>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -17,6 +26,10 @@ export default {
|
|||||||
filter: {
|
filter: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
|
},
|
||||||
|
focused: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: { Toot },
|
components: { Toot },
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="status" tabIndex="0">
|
<div
|
||||||
|
class="status"
|
||||||
|
tabIndex="0"
|
||||||
|
v-shortkey="{next: ['j'], prev: ['k']}"
|
||||||
|
@shortkey="handleStatusControl"
|
||||||
|
ref="status"
|
||||||
|
@click="$emit('select')"
|
||||||
|
>
|
||||||
<div v-show="filtered(message)" class="filtered">
|
<div v-show="filtered(message)" class="filtered">
|
||||||
Filtered
|
Filtered
|
||||||
</div>
|
</div>
|
||||||
@ -80,6 +87,10 @@ export default {
|
|||||||
filter: {
|
filter: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
|
},
|
||||||
|
focused: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
@ -88,6 +99,24 @@ export default {
|
|||||||
showAttachments: false
|
showAttachments: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted () {
|
||||||
|
if (this.focused) {
|
||||||
|
this.$refs.status.focus()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
focused: function (newState, oldState) {
|
||||||
|
if (newState) {
|
||||||
|
this.$nextTick(function () {
|
||||||
|
this.$refs.status.focus()
|
||||||
|
})
|
||||||
|
} else if (oldState && !newState) {
|
||||||
|
this.$nextTick(function () {
|
||||||
|
this.$refs.status.blur()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
username (account) {
|
username (account) {
|
||||||
if (account.display_name !== '') {
|
if (account.display_name !== '') {
|
||||||
@ -155,6 +184,16 @@ export default {
|
|||||||
},
|
},
|
||||||
spoilerText (message) {
|
spoilerText (message) {
|
||||||
return emojify(message.spoiler_text, message.emojis)
|
return emojify(message.spoiler_text, message.emojis)
|
||||||
|
},
|
||||||
|
handleStatusControl (event) {
|
||||||
|
switch (event.srcKey) {
|
||||||
|
case 'next':
|
||||||
|
this.$emit('focusNext')
|
||||||
|
break
|
||||||
|
case 'prev':
|
||||||
|
this.$emit('focusPrev')
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div
|
<div
|
||||||
class="status"
|
class="status"
|
||||||
tabIndex="0"
|
tabIndex="0"
|
||||||
v-shortkey="{next: ['ctrl', 'n'], prev: ['ctrl', 'p']}"
|
v-shortkey="{next: ['j'], prev: ['k']}"
|
||||||
@shortkey="handleTootControl"
|
@shortkey="handleTootControl"
|
||||||
ref="status"
|
ref="status"
|
||||||
@click="$emit('selectToot')"
|
@click="$emit('selectToot')"
|
||||||
|
@ -4,8 +4,16 @@
|
|||||||
<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="notifications" v-for="message in notifications" v-bind:key="message.id">
|
<div class="notifications" v-for="(message, index) in notifications" v-bind:key="message.id">
|
||||||
<notification :message="message" :filter="filter"></notification>
|
<notification
|
||||||
|
:message="message"
|
||||||
|
:filter="filter"
|
||||||
|
:focused="index === focusedIndex"
|
||||||
|
@focusNext="focusNext"
|
||||||
|
@focusPrev="focusPrev"
|
||||||
|
@selectNotification="focusNotification(index)"
|
||||||
|
>
|
||||||
|
</notification>
|
||||||
</div>
|
</div>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor">
|
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor">
|
||||||
@ -25,6 +33,11 @@ import scrollTop from '../../utils/scroll'
|
|||||||
export default {
|
export default {
|
||||||
name: 'notifications',
|
name: 'notifications',
|
||||||
components: { Notification },
|
components: { Notification },
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
focusedIndex: null
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
startReload: state => state.TimelineSpace.HeaderMenu.reload,
|
startReload: state => state.TimelineSpace.HeaderMenu.reload,
|
||||||
@ -63,6 +76,14 @@ export default {
|
|||||||
this.$store.commit('TimelineSpace/HeaderMenu/changeReload', false)
|
this.$store.commit('TimelineSpace/HeaderMenu/changeReload', false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
focusedIndex: function (newState, oldState) {
|
||||||
|
if (newState >= 0 && this.heading) {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Notifications/changeHeading', false)
|
||||||
|
} else if (newState === null && !this.heading) {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Notifications/changeHeading', true)
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Notifications/mergeNotifications')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -118,6 +139,24 @@ export default {
|
|||||||
document.getElementById('scrollable'),
|
document.getElementById('scrollable'),
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
this.focusedIndex = null
|
||||||
|
},
|
||||||
|
focusNext () {
|
||||||
|
if (this.focusedIndex === null) {
|
||||||
|
this.focusedIndex = 0
|
||||||
|
} else if (this.focusedIndex < this.notifications.length) {
|
||||||
|
this.focusedIndex++
|
||||||
|
}
|
||||||
|
},
|
||||||
|
focusPrev () {
|
||||||
|
if (this.focusedIndex === 0) {
|
||||||
|
this.focusedIndex = null
|
||||||
|
} else if (this.focusedIndex > 0) {
|
||||||
|
this.focusedIndex--
|
||||||
|
}
|
||||||
|
},
|
||||||
|
focusNotification (index) {
|
||||||
|
this.focusedIndex = index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user