2018-03-09 07:21:25 +01:00
|
|
|
<template>
|
2018-08-22 02:20:42 +02:00
|
|
|
<div
|
|
|
|
class="status"
|
|
|
|
tabIndex="0"
|
2018-09-09 17:53:43 +02:00
|
|
|
v-shortkey="shortcutEnabled ? {next: ['j'], prev: ['k'], open: ['o'], profile: ['p']} : {}"
|
2018-08-22 02:20:42 +02:00
|
|
|
@shortkey="handleStatusControl"
|
|
|
|
ref="status"
|
|
|
|
@click="$emit('select')"
|
|
|
|
>
|
2018-07-15 03:34:08 +02:00
|
|
|
<div v-show="filtered(message)" class="filtered">
|
2018-07-10 01:24:32 +02:00
|
|
|
Filtered
|
|
|
|
</div>
|
2018-07-15 03:34:08 +02:00
|
|
|
<div v-show="!filtered(message)" class="reblog">
|
2018-03-12 15:22:21 +01:00
|
|
|
<div class="action">
|
|
|
|
<div class="action-mark">
|
|
|
|
<icon name="retweet" scala="0.7"></icon>
|
|
|
|
</div>
|
|
|
|
<div class="action-detail">
|
2018-03-31 15:02:26 +02:00
|
|
|
<span class="bold" @click="openUser(message.account)">{{ username(message.account) }}</span> boosted your status
|
2018-03-12 15:22:21 +01:00
|
|
|
</div>
|
|
|
|
<div class="action-icon">
|
|
|
|
<img :src="message.account.avatar" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="clearfix"></div>
|
2018-10-02 16:03:40 +02:00
|
|
|
<div class="target" v-on:dblclick="openDetail(message.status)">
|
2018-04-17 15:47:37 +02:00
|
|
|
<div class="icon" @click="openUser(message.status.account)">
|
2018-03-12 15:22:21 +01:00
|
|
|
<img :src="message.status.account.avatar" />
|
|
|
|
</div>
|
|
|
|
<div class="detail">
|
|
|
|
<div class="toot-header">
|
|
|
|
<div class="user">
|
2018-03-26 12:49:35 +02:00
|
|
|
{{ username(message.status.account) }}
|
2018-03-12 15:22:21 +01:00
|
|
|
</div>
|
|
|
|
<div class="timestamp">
|
|
|
|
{{ parseDatetime(message.status.created_at) }}
|
|
|
|
</div>
|
2018-08-19 11:08:07 +02:00
|
|
|
<div class="clearfix"></div>
|
2018-03-12 15:22:21 +01:00
|
|
|
</div>
|
2018-08-19 08:53:31 +02:00
|
|
|
<div class="content-wrapper">
|
|
|
|
<div class="spoiler" v-show="spoilered(message.status)">
|
|
|
|
<span v-html="spoilerText(message.status)"></span>
|
|
|
|
<el-button v-show="!isShowContent(message.status)" type="text" @click="showContent = true">
|
|
|
|
{{ $t('cards.toot.show_more') }}
|
|
|
|
</el-button>
|
|
|
|
<el-button v-show="isShowContent(message.status)" type="text" @click="showContent = false">
|
|
|
|
{{ $t('cards.toot.hide')}}
|
|
|
|
</el-button>
|
|
|
|
</div>
|
|
|
|
<div class="content" v-show="isShowContent(message.status)" v-html="status(message.status)" @click.capture.prevent="tootClick"></div>
|
|
|
|
</div>
|
2018-08-19 09:17:10 +02:00
|
|
|
<div class="attachments">
|
|
|
|
<el-button v-show="sensitive(message.status) && !isShowAttachments(message.status)" class="show-sensitive" type="info" @click="showAttachments = true">
|
|
|
|
{{ $t('cards.toot.sensitive') }}
|
|
|
|
</el-button>
|
|
|
|
<div v-show="isShowAttachments(message.status)">
|
|
|
|
<el-button v-show="sensitive(message.status) && isShowAttachments(message.status)" class="hide-sensitive" type="text" @click="showAttachments = false">
|
|
|
|
<icon name="eye" class="hide"></icon>
|
|
|
|
</el-button>
|
|
|
|
<div class="media" v-for="media in mediaAttachments(message.status)">
|
|
|
|
<img :src="media.preview_url" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="clearfix"></div>
|
|
|
|
</div>
|
2018-03-12 15:22:21 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="clearfix"></div>
|
2018-03-09 07:21:25 +01:00
|
|
|
</div>
|
2018-07-10 01:24:32 +02:00
|
|
|
<div class="fill-line"></div>
|
|
|
|
</div>
|
2018-03-09 07:21:25 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-08-30 17:54:40 +02:00
|
|
|
import { mapState } from 'vuex'
|
2018-03-12 15:22:21 +01:00
|
|
|
import moment from 'moment'
|
2018-03-26 15:18:15 +02:00
|
|
|
import { shell } from 'electron'
|
2018-06-20 01:54:26 +02:00
|
|
|
import { findAccount, findLink, isTag } from '../../../../utils/link'
|
2018-08-19 08:53:31 +02:00
|
|
|
import emojify from '~/src/renderer/utils/emojify'
|
2018-08-30 17:54:40 +02:00
|
|
|
import TimeFormat from '~/src/constants/timeFormat'
|
2018-03-12 15:22:21 +01:00
|
|
|
|
2018-03-09 07:21:25 +01:00
|
|
|
export default {
|
2018-03-12 14:35:31 +01:00
|
|
|
name: 'reblog',
|
2018-07-10 01:24:32 +02:00
|
|
|
props: {
|
|
|
|
message: {
|
|
|
|
type: Object,
|
|
|
|
default: {}
|
|
|
|
},
|
|
|
|
filter: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
2018-08-22 02:20:42 +02:00
|
|
|
},
|
|
|
|
focused: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
2018-08-23 17:14:37 +02:00
|
|
|
},
|
|
|
|
overlaid: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
2018-07-10 01:24:32 +02:00
|
|
|
}
|
|
|
|
},
|
2018-08-19 08:53:31 +02:00
|
|
|
data () {
|
|
|
|
return {
|
2018-08-19 09:17:10 +02:00
|
|
|
showContent: false,
|
|
|
|
showAttachments: false
|
2018-08-19 08:53:31 +02:00
|
|
|
}
|
|
|
|
},
|
2018-08-23 17:14:37 +02:00
|
|
|
computed: {
|
2018-08-30 17:54:40 +02:00
|
|
|
...mapState({
|
2018-08-30 18:08:07 +02:00
|
|
|
timeFormat: state => state.App.timeFormat,
|
|
|
|
language: state => state.App.language
|
2018-08-30 17:54:40 +02:00
|
|
|
}),
|
2018-08-23 17:14:37 +02:00
|
|
|
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-12 15:22:21 +01:00
|
|
|
methods: {
|
2018-03-26 12:49:35 +02:00
|
|
|
username (account) {
|
|
|
|
if (account.display_name !== '') {
|
|
|
|
return account.display_name
|
|
|
|
} else {
|
|
|
|
return account.username
|
|
|
|
}
|
|
|
|
},
|
2018-03-12 15:22:21 +01:00
|
|
|
parseDatetime (datetime) {
|
2018-08-30 17:54:40 +02:00
|
|
|
switch (this.timeFormat) {
|
|
|
|
case TimeFormat.Absolute.value:
|
|
|
|
return moment(datetime).format('YYYY-MM-DD HH:mm:ss')
|
|
|
|
case TimeFormat.Relative.value:
|
2018-08-30 18:08:07 +02:00
|
|
|
moment.locale(this.language)
|
2018-08-30 17:54:40 +02:00
|
|
|
return moment(datetime).fromNow()
|
|
|
|
}
|
2018-03-26 15:18:15 +02:00
|
|
|
},
|
|
|
|
tootClick (e) {
|
2018-06-02 18:08:05 +02:00
|
|
|
if (isTag(e.target)) {
|
|
|
|
const tag = `/${this.$route.params.id}/hashtag/${e.target.innerText}`
|
|
|
|
this.$router.push({ path: tag })
|
|
|
|
return tag
|
|
|
|
}
|
2018-06-20 01:54:26 +02:00
|
|
|
const accountURL = findAccount(e.target)
|
|
|
|
if (accountURL !== null) {
|
|
|
|
this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', true)
|
|
|
|
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/searchAccount', accountURL)
|
|
|
|
.then((account) => {
|
|
|
|
this.$store.dispatch('TimelineSpace/Contents/SideBar/openAccountComponent')
|
|
|
|
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/changeAccount', account)
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
this.$message({
|
2018-08-13 08:27:53 +02:00
|
|
|
message: this.$t('message.find_account_error'),
|
2018-06-20 01:54:26 +02:00
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', false)
|
|
|
|
})
|
|
|
|
return accountURL
|
|
|
|
}
|
2018-03-26 15:18:15 +02:00
|
|
|
const link = findLink(e.target)
|
|
|
|
if (link !== null) {
|
2018-06-02 18:08:05 +02:00
|
|
|
return shell.openExternal(link)
|
2018-03-26 15:18:15 +02:00
|
|
|
}
|
2018-03-30 10:50:21 +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-07-10 01:24:32 +02:00
|
|
|
},
|
2018-09-09 17:53:43 +02:00
|
|
|
openDetail (message) {
|
|
|
|
this.$store.dispatch('TimelineSpace/Contents/SideBar/openTootComponent')
|
|
|
|
this.$store.dispatch('TimelineSpace/Contents/SideBar/TootDetail/changeToot', message)
|
|
|
|
this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', true)
|
|
|
|
},
|
2018-08-19 09:17:10 +02:00
|
|
|
mediaAttachments (message) {
|
|
|
|
return message.media_attachments
|
|
|
|
},
|
2018-07-10 01:24:32 +02:00
|
|
|
filtered (message) {
|
2018-07-10 15:52:08 +02:00
|
|
|
return this.filter.length > 0 && message.status.content.search(this.filter) >= 0
|
2018-08-19 08:53:31 +02:00
|
|
|
},
|
|
|
|
spoilered (message) {
|
|
|
|
return message.spoiler_text.length > 0
|
|
|
|
},
|
|
|
|
isShowContent (message) {
|
|
|
|
return !this.spoilered(message) || this.showContent
|
|
|
|
},
|
2018-08-19 09:17:10 +02:00
|
|
|
sensitive (message) {
|
|
|
|
return message.sensitive && this.mediaAttachments(message).length > 0
|
|
|
|
},
|
|
|
|
isShowAttachments (message) {
|
|
|
|
return !this.sensitive(message) || this.showAttachments
|
|
|
|
},
|
2018-08-19 08:53:31 +02:00
|
|
|
status (message) {
|
|
|
|
return emojify(message.content, message.emojis)
|
|
|
|
},
|
|
|
|
spoilerText (message) {
|
|
|
|
return emojify(message.spoiler_text, message.emojis)
|
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-09-09 17:53:43 +02:00
|
|
|
case 'open':
|
|
|
|
this.openDetail(this.message.status)
|
|
|
|
break
|
|
|
|
case 'profile':
|
|
|
|
this.openUser(this.message.account)
|
|
|
|
break
|
2018-08-22 02:20:42 +02:00
|
|
|
}
|
2018-03-12 15:22:21 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-09 07:21:25 +01:00
|
|
|
}
|
|
|
|
</script>
|
2018-03-12 15:22:21 +01:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.bold {
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
.reblog {
|
2018-03-21 03:32:37 +01:00
|
|
|
padding: 8px 0 0 16px;
|
2018-03-12 15:22:21 +01:00
|
|
|
|
|
|
|
.action {
|
|
|
|
margin-right: 8px;
|
|
|
|
|
|
|
|
.action-mark {
|
|
|
|
color: #409eff;
|
|
|
|
float: left;
|
|
|
|
width: 32px;
|
|
|
|
text-align: right;
|
|
|
|
}
|
|
|
|
|
|
|
|
.action-detail {
|
|
|
|
margin-left: 10px;
|
2018-04-21 11:59:34 +02:00
|
|
|
font-size: var(--base-font-size);
|
2018-03-12 15:22:21 +01:00
|
|
|
float: left;
|
2018-03-30 11:09:26 +02:00
|
|
|
max-width: 80%;
|
2018-03-30 10:50:21 +02:00
|
|
|
|
|
|
|
.bold {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2018-03-12 15:22:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.action-icon {
|
|
|
|
width: 100%;
|
|
|
|
text-align: right;
|
|
|
|
|
|
|
|
img {
|
|
|
|
width: 16px;
|
|
|
|
height: 16px;
|
|
|
|
border-radius: 2px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.target {
|
|
|
|
.icon {
|
|
|
|
float: left;
|
|
|
|
width: 42px;
|
2018-04-17 15:47:37 +02:00
|
|
|
cursor: pointer;
|
2018-03-12 15:22:21 +01:00
|
|
|
|
|
|
|
img {
|
|
|
|
width: 32px;
|
|
|
|
height: 32px;
|
|
|
|
border-radius: 4px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.detail {
|
2018-03-21 03:32:37 +01:00
|
|
|
margin: 8px 8px 0 42px;;
|
2018-03-12 15:22:21 +01:00
|
|
|
color: #909399;
|
|
|
|
|
|
|
|
.toot-header {
|
2018-08-19 11:08:07 +02:00
|
|
|
height: 24px;
|
|
|
|
|
2018-03-12 15:22:21 +01:00
|
|
|
.user {
|
|
|
|
float: left;
|
2018-04-21 11:59:34 +02:00
|
|
|
font-size: var(--base-font-size);
|
2018-03-12 15:22:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.timestamp {
|
2018-04-21 11:59:34 +02:00
|
|
|
font-size: var(--base-font-size);
|
2018-03-12 15:22:21 +01:00
|
|
|
text-align: right;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-19 08:53:31 +02:00
|
|
|
.content-wrapper /deep/ {
|
2018-04-21 11:59:34 +02:00
|
|
|
font-size: var(--base-font-size);
|
2018-08-19 11:08:07 +02:00
|
|
|
margin: 0;
|
2018-08-19 08:53:31 +02:00
|
|
|
|
|
|
|
.content {
|
|
|
|
font-size: var(--base-font-size);
|
|
|
|
word-wrap: break-word;
|
|
|
|
}
|
|
|
|
|
|
|
|
.emojione {
|
|
|
|
width: 20px;
|
|
|
|
height: 20px;
|
|
|
|
}
|
2018-03-12 15:22:21 +01:00
|
|
|
}
|
2018-08-19 09:17:10 +02:00
|
|
|
|
|
|
|
.attachments {
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
.show-sensitive {
|
|
|
|
padding: 20px 32px;
|
|
|
|
margin-bottom: 4px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.hide-sensitive {
|
|
|
|
position: absolute;
|
|
|
|
top: 2px;
|
|
|
|
left: 2px;
|
|
|
|
background-color: rgba(0, 0, 0, 0.5);
|
|
|
|
padding: 4px;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
background-color: rgba(0, 0, 0, 0.9);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.media {
|
|
|
|
float: left;
|
|
|
|
margin-right: 8px;
|
|
|
|
|
|
|
|
img {
|
|
|
|
max-width: 200px;
|
|
|
|
max-height: 200px;
|
|
|
|
border-radius: 8px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-12 15:22:21 +01:00
|
|
|
}
|
|
|
|
}
|
2018-07-10 01:24:32 +02:00
|
|
|
}
|
2018-04-13 02:23:33 +02:00
|
|
|
|
2018-07-10 01:24:32 +02:00
|
|
|
.filtered {
|
|
|
|
align-items: center;
|
|
|
|
display: flex;
|
|
|
|
height: 40px;
|
|
|
|
justify-content: center;
|
2018-03-12 15:22:21 +01:00
|
|
|
}
|
2018-03-21 03:32:37 +01:00
|
|
|
|
2018-07-10 01:24:32 +02:00
|
|
|
.status: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-07-10 01:24:32 +02:00
|
|
|
|
|
|
|
.fill-line {
|
|
|
|
height: 1px;
|
|
|
|
background-color: var(--theme-border-color);
|
|
|
|
margin: 4px 0 0;
|
|
|
|
}
|
2018-03-12 15:22:21 +01:00
|
|
|
</style>
|