2018-03-09 07:21:25 +01:00
|
|
|
<template>
|
2018-08-22 02:20:42 +02:00
|
|
|
<div
|
|
|
|
class="follow"
|
|
|
|
tabIndex="0"
|
2018-11-29 15:34:03 +01:00
|
|
|
v-shortkey="shortcutEnabled ? {next: ['j'], prev: ['k'], right: ['l'], profile: ['p']} : {}"
|
2018-08-22 02:20:42 +02:00
|
|
|
@shortkey="handleStatusControl"
|
|
|
|
ref="status"
|
|
|
|
@click="$emit('select')"
|
2018-10-21 04:17:59 +02:00
|
|
|
role="article"
|
|
|
|
aria-label="follow event"
|
2018-08-22 02:20:42 +02:00
|
|
|
>
|
|
|
|
<div class="action">
|
|
|
|
<div class="action-mark">
|
|
|
|
<icon name="user-plus" scale="0.7"></icon>
|
|
|
|
</div>
|
|
|
|
<div class="action-detail">
|
|
|
|
<span class="bold" @click="openUser(message.account)">{{ username(message.account) }}</span> is now following you
|
|
|
|
</div>
|
|
|
|
<div class="action-icon">
|
2018-11-14 13:29:15 +01:00
|
|
|
<FailoverImg :src="message.account.avatar" />
|
2018-03-12 15:06:27 +01:00
|
|
|
</div>
|
2018-03-09 07:21:25 +01:00
|
|
|
</div>
|
2018-08-22 02:20:42 +02:00
|
|
|
<div class="clearfix"></div>
|
|
|
|
<div class="fill-line"></div>
|
|
|
|
</div>
|
2018-03-09 07:21:25 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-11-14 13:29:15 +01:00
|
|
|
import FailoverImg from '~/src/renderer/components/atoms/FailoverImg'
|
|
|
|
|
2018-03-09 07:21:25 +01:00
|
|
|
export default {
|
2018-03-12 14:35:31 +01:00
|
|
|
name: 'follow',
|
2018-11-19 15:57:34 +01:00
|
|
|
components: {
|
2018-11-14 13:29:15 +01:00
|
|
|
FailoverImg
|
|
|
|
},
|
2018-08-22 02:20:42 +02:00
|
|
|
props: {
|
|
|
|
message: {
|
|
|
|
type: Object,
|
|
|
|
default: {}
|
|
|
|
},
|
|
|
|
focused: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
2018-08-23 17:14:37 +02:00
|
|
|
},
|
|
|
|
overlaid: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
shortcutEnabled: function () {
|
|
|
|
return this.focused && !this.overlaid
|
2018-08-22 02:20:42 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
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()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-03-26 12:49:35 +02:00
|
|
|
methods: {
|
|
|
|
username (account) {
|
|
|
|
if (account.display_name !== '') {
|
|
|
|
return account.display_name
|
|
|
|
} else {
|
|
|
|
return account.username
|
|
|
|
}
|
2018-03-30 10:47:45 +02:00
|
|
|
},
|
|
|
|
openUser (account) {
|
|
|
|
this.$store.dispatch('TimelineSpace/Contents/SideBar/openAccountComponent')
|
|
|
|
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/changeAccount', account)
|
|
|
|
this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', true)
|
2018-08-22 02:20:42 +02:00
|
|
|
},
|
|
|
|
handleStatusControl (event) {
|
|
|
|
switch (event.srcKey) {
|
|
|
|
case 'next':
|
|
|
|
this.$emit('focusNext')
|
|
|
|
break
|
|
|
|
case 'prev':
|
|
|
|
this.$emit('focusPrev')
|
|
|
|
break
|
2018-11-29 15:34:03 +01:00
|
|
|
case 'right':
|
|
|
|
this.$emit('focusRight')
|
|
|
|
break
|
2018-09-09 18:01:38 +02:00
|
|
|
case 'profile':
|
|
|
|
this.openUser(this.message.account)
|
|
|
|
break
|
2018-08-22 02:20:42 +02:00
|
|
|
}
|
2018-03-26 12:49:35 +02:00
|
|
|
}
|
|
|
|
}
|
2018-03-09 07:21:25 +01:00
|
|
|
}
|
|
|
|
</script>
|
2018-03-12 15:06:27 +01:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.bold {
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
.follow {
|
2018-03-21 03:32:37 +01:00
|
|
|
padding: 8px 0 0 16px;
|
2018-03-12 15:06:27 +01:00
|
|
|
|
|
|
|
.action {
|
|
|
|
margin-right: 8px;
|
|
|
|
|
|
|
|
.action-mark {
|
|
|
|
color: #409eff;
|
|
|
|
float: left;
|
|
|
|
width: 32px;
|
|
|
|
text-align: right;
|
|
|
|
}
|
|
|
|
|
|
|
|
.action-detail {
|
|
|
|
margin-left: 10px;
|
|
|
|
font-size: 14px;
|
|
|
|
float: left;
|
2018-03-30 11:09:26 +02:00
|
|
|
max-width: 80%;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
2018-03-30 10:47:45 +02:00
|
|
|
|
|
|
|
.bold {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2018-03-12 15:06:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.action-icon {
|
|
|
|
width: 100%;
|
|
|
|
text-align: right;
|
|
|
|
|
|
|
|
img {
|
|
|
|
width: 16px;
|
|
|
|
height: 16px;
|
|
|
|
border-radius: 2px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-13 02:23:33 +02:00
|
|
|
|
|
|
|
.fill-line {
|
|
|
|
height: 1px;
|
|
|
|
background-color: var(--theme-border-color);
|
|
|
|
margin: 4px 0 0;
|
|
|
|
}
|
2018-03-12 15:06:27 +01:00
|
|
|
}
|
2018-03-21 03:32:37 +01:00
|
|
|
|
|
|
|
.follow:focus {
|
2018-04-14 14:46:26 +02:00
|
|
|
background-color: var(--theme-selected-background-color);
|
2018-03-21 03:32:37 +01:00
|
|
|
outline: 0;
|
|
|
|
}
|
2018-03-12 15:06:27 +01:00
|
|
|
</style>
|