2018-03-12 08:42:05 +01:00
|
|
|
<template>
|
2018-08-21 16:02:05 +02:00
|
|
|
<div
|
|
|
|
class="status"
|
|
|
|
tabIndex="0"
|
2018-08-27 18:17:05 +02:00
|
|
|
v-shortkey="shortcutEnabled ? {next: ['j'], prev: ['k'], reply: ['r'], boost: ['b'], fav: ['f'], open: ['o'], profile: ['p'], image: ['i'], cw: ['x']} : {}"
|
2018-08-21 16:02:05 +02:00
|
|
|
@shortkey="handleTootControl"
|
|
|
|
ref="status"
|
|
|
|
@click="$emit('selectToot')"
|
2018-10-21 04:17:59 +02:00
|
|
|
role="article"
|
|
|
|
aria-label="toot"
|
2018-08-21 16:02:05 +02:00
|
|
|
>
|
2018-07-15 03:34:08 +02:00
|
|
|
<div v-show="filtered(message)" class="filtered">
|
2018-07-10 15:10:57 +02:00
|
|
|
Filtered
|
2018-07-09 01:49:49 +02:00
|
|
|
</div>
|
2018-07-15 03:34:08 +02:00
|
|
|
<div v-show="!filtered(message)" class="toot">
|
2018-03-12 08:42:05 +01:00
|
|
|
<div class="icon">
|
2018-10-21 04:17:59 +02:00
|
|
|
<img
|
|
|
|
:src="originalMessage(message).account.avatar"
|
|
|
|
@click="openUser(originalMessage(message).account)"
|
|
|
|
role="img"
|
|
|
|
:alt="`Avatar of ${originalMessage(message).account.username}`"
|
|
|
|
/>
|
2018-03-12 08:42:05 +01:00
|
|
|
</div>
|
2018-04-14 14:38:29 +02:00
|
|
|
<div class="detail" v-on:dblclick="openDetail(message)">
|
2018-03-12 08:42:05 +01:00
|
|
|
<div class="toot-header">
|
2018-03-29 15:41:28 +02:00
|
|
|
<div class="user" @click="openUser(originalMessage(message).account)">
|
2018-11-13 16:14:57 +01:00
|
|
|
<span class="display-name" v-html="username(originalMessage(message).account)"></span>
|
2018-04-18 16:37:00 +02:00
|
|
|
<span class="acct">{{ accountName(originalMessage(message).account) }}</span>
|
2018-03-12 08:42:05 +01:00
|
|
|
</div>
|
|
|
|
<div class="timestamp">
|
2018-05-10 01:49:06 +02:00
|
|
|
{{ parseDatetime(originalMessage(message).created_at) }}
|
2018-03-12 08:42:05 +01:00
|
|
|
</div>
|
2018-05-28 14:54:35 +02:00
|
|
|
<div class="clearfix"></div>
|
2018-03-12 08:42:05 +01:00
|
|
|
</div>
|
2018-05-22 18:20:36 +02:00
|
|
|
<div class="content-wrapper">
|
|
|
|
<div class="spoiler" v-show="spoilered(message)">
|
2018-08-18 15:22:25 +02:00
|
|
|
<span v-html="spoilerText(message)"></span>
|
2018-05-22 18:20:36 +02:00
|
|
|
<el-button v-show="!isShowContent(message)" type="text" @click="showContent = true">
|
2018-08-12 14:26:44 +02:00
|
|
|
{{ $t('cards.toot.show_more') }}
|
2018-05-22 18:20:36 +02:00
|
|
|
</el-button>
|
|
|
|
<el-button v-show="isShowContent(message)" type="text" @click="showContent = false">
|
2018-08-12 14:26:44 +02:00
|
|
|
{{ $t('cards.toot.hide')}}
|
2018-05-22 18:20:36 +02:00
|
|
|
</el-button>
|
|
|
|
</div>
|
2018-08-18 15:15:46 +02:00
|
|
|
<div class="content" v-show="isShowContent(message)" v-html="status(message)" @click.capture.prevent="tootClick"></div>
|
2018-05-22 18:20:36 +02:00
|
|
|
</div>
|
2018-03-24 15:55:23 +01:00
|
|
|
<div class="attachments">
|
2018-05-24 01:46:03 +02:00
|
|
|
<el-button v-show="sensitive(message) && !isShowAttachments(message)" class="show-sensitive" type="info" @click="showAttachments = true">
|
2018-08-12 14:26:44 +02:00
|
|
|
{{ $t('cards.toot.sensitive') }}
|
2018-05-24 01:46:03 +02:00
|
|
|
</el-button>
|
|
|
|
<div v-show="isShowAttachments(message)">
|
2018-08-20 18:04:47 +02:00
|
|
|
<el-button v-show="sensitive(message) && isShowAttachments(message)" class="hide-sensitive" type="text" @click="showAttachments = false" :title="$t('cards.toot.hide')">
|
2018-05-24 01:46:03 +02:00
|
|
|
<icon name="eye" class="hide"></icon>
|
|
|
|
</el-button>
|
2018-10-31 15:04:49 +01:00
|
|
|
<div class="media" v-bind:key="media.preview_url" v-for="media in mediaAttachments(message)">
|
|
|
|
<img :src="media.preview_url" @click="openImage(media.url, mediaAttachments(message))"/>
|
|
|
|
<span class="media-label" v-if="media.type == 'gifv'">GIF</span>
|
|
|
|
<span class="media-label" v-else-if="media.type == 'video'">VIDEO</span>
|
2018-05-24 01:46:03 +02:00
|
|
|
</div>
|
2018-03-24 15:55:23 +01:00
|
|
|
</div>
|
2018-04-04 12:56:00 +02:00
|
|
|
<div class="clearfix"></div>
|
2018-03-24 15:55:23 +01:00
|
|
|
</div>
|
2018-07-15 03:34:08 +02:00
|
|
|
<div class="reblogger" v-show="message.reblog !== null">
|
2018-03-14 15:09:04 +01:00
|
|
|
<icon name="retweet"></icon>
|
2018-04-04 13:35:18 +02:00
|
|
|
<span class="reblogger-icon" @click="openUser(message.account)">
|
2018-10-21 04:17:59 +02:00
|
|
|
<img :src="message.account.avatar"
|
|
|
|
:alt="`Avatar of ${message.account.username}`" />
|
2018-03-14 15:09:04 +01:00
|
|
|
</span>
|
2018-11-13 16:14:57 +01:00
|
|
|
<span class="reblogger-name" @click="openUser(message.account)" :title="`Reblogged by ${message.account.username}`" v-html="username(message.account)">
|
2018-03-14 15:09:04 +01:00
|
|
|
</span>
|
|
|
|
</div>
|
2018-03-12 08:42:05 +01:00
|
|
|
<div class="tool-box">
|
2018-08-20 18:04:47 +02:00
|
|
|
<el-button type="text" @click="openReply(message)" class="reply" :title="$t('cards.toot.reply')">
|
2018-03-14 14:38:42 +01:00
|
|
|
<icon name="reply" scale="0.9"></icon>
|
|
|
|
</el-button>
|
2018-07-15 07:35:08 +02:00
|
|
|
<el-button v-show="locked(message)" type="text" class="locked">
|
|
|
|
<icon name="lock" scale="0.9"></icon>
|
|
|
|
</el-button>
|
2018-08-20 15:07:22 +02:00
|
|
|
<el-button v-show="directed(message)" type="text" class="directed">
|
|
|
|
<icon name="envelope" scale="0.9"></icon>
|
|
|
|
</el-button>
|
2018-08-20 18:04:47 +02:00
|
|
|
<el-button v-show="!locked(message)&&!directed(message)" type="text" @click="changeReblog(originalMessage(message))" :class="originalMessage(message).reblogged ? 'reblogged' : 'reblog'" :title="$t('cards.toot.reblog')">
|
2018-03-14 14:38:42 +01:00
|
|
|
<icon name="retweet" scale="0.9"></icon>
|
|
|
|
</el-button>
|
2018-04-29 02:40:02 +02:00
|
|
|
<span class="count">
|
|
|
|
{{ reblogsCount(message) }}
|
|
|
|
</span>
|
2018-08-20 18:04:47 +02:00
|
|
|
<el-button type="text" @click="changeFavourite(originalMessage(message))" :class="originalMessage(message).favourited ? 'favourited animated bounceIn' : 'favourite'" :title="$t('cards.toot.fav')">
|
2018-03-14 14:38:42 +01:00
|
|
|
<icon name="star" scale="0.9"></icon>
|
|
|
|
</el-button>
|
2018-04-29 02:51:08 +02:00
|
|
|
<span class="count">
|
|
|
|
{{ favouritesCount(message) }}
|
|
|
|
</span>
|
2018-07-01 14:51:05 +02:00
|
|
|
<popper trigger="click" :options="{placement: 'bottom'}" ref="popper">
|
2018-04-15 10:45:14 +02:00
|
|
|
<div class="popper toot-menu">
|
|
|
|
<ul class="menu-list">
|
|
|
|
<li role="button" @click="openDetail(message)">
|
2018-08-12 14:26:44 +02:00
|
|
|
{{ $t('cards.toot.view_toot_detail') }}
|
2018-04-15 10:45:14 +02:00
|
|
|
</li>
|
2018-07-01 14:32:00 +02:00
|
|
|
<li role="button" @click="openBrowser(originalMessage(message))">
|
2018-08-12 14:26:44 +02:00
|
|
|
{{ $t('cards.toot.open_in_browser') }}
|
2018-04-15 10:45:14 +02:00
|
|
|
</li>
|
2018-07-01 14:32:00 +02:00
|
|
|
<li role="button" @click="copyLink(originalMessage(message))">
|
2018-08-12 14:26:44 +02:00
|
|
|
{{ $t('cards.toot.copy_link_to_toot') }}
|
2018-04-27 01:46:44 +02:00
|
|
|
</li>
|
2018-09-30 16:55:33 +02:00
|
|
|
<li role="button" class="separate" @click="confirmMute(message)">
|
|
|
|
{{ $t('cards.toot.mute') }}
|
|
|
|
</li>
|
|
|
|
<li role="button" @click="block(message)">
|
|
|
|
{{ $t('cards.toot.block') }}
|
|
|
|
</li>
|
|
|
|
<li role="button" @click="reportUser(message)" v-if="!isMyMessage(message)">
|
2018-09-30 16:01:40 +02:00
|
|
|
{{ $t('cards.toot.report') }}
|
|
|
|
</li>
|
|
|
|
<li role="button" class="separate" @click="deleteToot(message)" v-if="isMyMessage(message)">
|
2018-08-12 14:26:44 +02:00
|
|
|
{{ $t('cards.toot.delete') }}
|
2018-04-30 14:33:12 +02:00
|
|
|
</li>
|
2018-04-15 10:45:14 +02:00
|
|
|
</ul>
|
|
|
|
</div>
|
2018-08-20 18:04:47 +02:00
|
|
|
<el-button slot="reference" type="text" :title="$t('cards.toot.detail')">
|
2018-04-15 10:45:14 +02:00
|
|
|
<icon name="ellipsis-h" scale="0.9"></icon>
|
|
|
|
</el-button>
|
|
|
|
</popper>
|
2018-03-12 08:42:05 +01:00
|
|
|
</div>
|
2018-07-15 03:34:08 +02:00
|
|
|
<div class="application" v-show="application(message) !== null">
|
2018-08-12 14:26:44 +02:00
|
|
|
{{ $t('cards.toot.via', { application: application(message) }) }}
|
2018-05-14 15:16:51 +02:00
|
|
|
</div>
|
2018-03-12 08:42:05 +01:00
|
|
|
</div>
|
2018-03-12 11:36:13 +01:00
|
|
|
<div class="clearfix"></div>
|
2018-03-12 08:42:05 +01:00
|
|
|
</div>
|
2018-07-09 01:49:49 +02:00
|
|
|
<div class="fill-line"></div>
|
|
|
|
</div>
|
2018-03-12 08:42:05 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-03-12 12:04:30 +01:00
|
|
|
import moment from 'moment'
|
2018-04-27 01:46:44 +02:00
|
|
|
import { shell, clipboard } from 'electron'
|
2018-04-18 16:37:00 +02:00
|
|
|
import { mapState } from 'vuex'
|
2018-11-03 04:35:03 +01:00
|
|
|
import { findAccount, findLink, findTag } from '~/src/renderer/utils/tootParser'
|
2018-08-12 16:17:57 +02:00
|
|
|
import DisplayStyle from '~/src/constants/displayStyle'
|
2018-08-30 17:54:40 +02:00
|
|
|
import TimeFormat from '~/src/constants/timeFormat'
|
2018-08-18 15:15:46 +02:00
|
|
|
import emojify from '~/src/renderer/utils/emojify'
|
2018-03-12 12:04:30 +01:00
|
|
|
|
2018-03-12 08:42:05 +01:00
|
|
|
export default {
|
|
|
|
name: 'toot',
|
2018-05-22 18:20:36 +02:00
|
|
|
data () {
|
|
|
|
return {
|
2018-05-24 01:46:03 +02:00
|
|
|
showContent: false,
|
|
|
|
showAttachments: false
|
2018-05-22 18:20:36 +02:00
|
|
|
}
|
|
|
|
},
|
2018-07-09 01:49:49 +02:00
|
|
|
props: {
|
|
|
|
message: {
|
|
|
|
type: Object,
|
|
|
|
default: {}
|
|
|
|
},
|
|
|
|
filter: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
2018-08-21 16:02:05 +02:00
|
|
|
},
|
|
|
|
focused: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
2018-08-23 17:14:37 +02:00
|
|
|
},
|
|
|
|
overlaid: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
2018-07-09 01:49:49 +02:00
|
|
|
}
|
|
|
|
},
|
2018-04-18 16:37:00 +02:00
|
|
|
computed: {
|
|
|
|
...mapState({
|
2018-08-30 17:54:40 +02:00
|
|
|
displayNameStyle: state => state.App.displayNameStyle,
|
2018-08-30 18:08:07 +02:00
|
|
|
timeFormat: state => state.App.timeFormat,
|
|
|
|
language: state => state.App.language
|
2018-08-23 17:14:37 +02:00
|
|
|
}),
|
|
|
|
shortcutEnabled: function () {
|
|
|
|
return this.focused && !this.overlaid
|
|
|
|
}
|
2018-04-18 16:37:00 +02:00
|
|
|
},
|
2018-08-21 16:02:05 +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 12:04:30 +01:00
|
|
|
methods: {
|
2018-03-14 15:27:36 +01:00
|
|
|
originalMessage (message) {
|
2018-03-14 15:09:04 +01:00
|
|
|
if (message.reblog !== null) {
|
2018-03-14 15:27:36 +01:00
|
|
|
return message.reblog
|
2018-03-14 15:09:04 +01:00
|
|
|
} else {
|
2018-03-14 15:27:36 +01:00
|
|
|
return message
|
2018-03-14 15:09:04 +01:00
|
|
|
}
|
|
|
|
},
|
2018-03-26 12:49:35 +02:00
|
|
|
username (account) {
|
2018-04-18 16:37:00 +02:00
|
|
|
switch (this.displayNameStyle) {
|
2018-08-11 04:44:13 +02:00
|
|
|
case DisplayStyle.DisplayNameAndUsername.value:
|
2018-04-18 16:37:00 +02:00
|
|
|
if (account.display_name !== '') {
|
2018-11-13 16:14:57 +01:00
|
|
|
return emojify(account.display_name, account.emojis)
|
2018-04-18 16:37:00 +02:00
|
|
|
} else {
|
2018-08-20 15:12:07 +02:00
|
|
|
return account.acct
|
2018-04-18 16:37:00 +02:00
|
|
|
}
|
2018-08-11 04:44:13 +02:00
|
|
|
case DisplayStyle.DisplayName.value:
|
2018-04-18 16:37:00 +02:00
|
|
|
if (account.display_name !== '') {
|
2018-11-13 16:14:57 +01:00
|
|
|
return emojify(account.display_name, account.emojis)
|
2018-04-18 16:37:00 +02:00
|
|
|
} else {
|
2018-08-20 15:12:07 +02:00
|
|
|
return account.acct
|
2018-04-18 16:37:00 +02:00
|
|
|
}
|
2018-08-11 04:44:13 +02:00
|
|
|
case DisplayStyle.Username.value:
|
2018-08-20 15:12:07 +02:00
|
|
|
return account.acct
|
2018-04-18 16:37:00 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
accountName (account) {
|
|
|
|
switch (this.displayNameStyle) {
|
2018-08-11 04:44:13 +02:00
|
|
|
case DisplayStyle.DisplayNameAndUsername.value:
|
2018-08-20 15:12:07 +02:00
|
|
|
return `@${account.acct}`
|
2018-08-11 04:44:13 +02:00
|
|
|
case DisplayStyle.DisplayName.value:
|
|
|
|
case DisplayStyle.Username.value:
|
2018-04-18 16:37:00 +02:00
|
|
|
return ''
|
2018-03-26 12:49:35 +02:00
|
|
|
}
|
|
|
|
},
|
2018-03-12 12:04:30 +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-14 07:45:34 +01:00
|
|
|
},
|
|
|
|
tootClick (e) {
|
2018-11-03 04:35:03 +01:00
|
|
|
const parsedTag = findTag(e.target, 'toot')
|
|
|
|
if (parsedTag !== null) {
|
|
|
|
const tag = `/${this.$route.params.id}/hashtag/${parsedTag}`
|
2018-06-02 17:46:56 +02:00
|
|
|
this.$router.push({ path: tag })
|
|
|
|
return tag
|
|
|
|
}
|
2018-10-29 16:54:11 +01:00
|
|
|
const parsedAccount = findAccount(e.target, 'toot')
|
2018-10-20 14:55:25 +02:00
|
|
|
if (parsedAccount !== null) {
|
2018-06-05 17:42:15 +02:00
|
|
|
this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', true)
|
2018-10-20 14:55:25 +02:00
|
|
|
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/searchAccount', parsedAccount)
|
2018-06-05 17:42:15 +02:00
|
|
|
.then((account) => {
|
|
|
|
this.$store.dispatch('TimelineSpace/Contents/SideBar/openAccountComponent')
|
|
|
|
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/changeAccount', account)
|
|
|
|
})
|
2018-11-13 15:30:30 +01:00
|
|
|
.catch((err) => {
|
|
|
|
console.error(err)
|
|
|
|
this.openLink(e)
|
2018-06-05 17:42:15 +02:00
|
|
|
this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', false)
|
|
|
|
})
|
2018-10-20 14:55:25 +02:00
|
|
|
return parsedAccount.acct
|
2018-06-05 17:42:15 +02:00
|
|
|
}
|
2018-11-13 15:30:30 +01:00
|
|
|
this.openLink(e)
|
|
|
|
},
|
|
|
|
openLink (e) {
|
2018-10-29 16:54:11 +01:00
|
|
|
const link = findLink(e.target, 'toot')
|
2018-03-14 07:45:34 +01:00
|
|
|
if (link !== null) {
|
2018-06-02 17:46:56 +02:00
|
|
|
return shell.openExternal(link)
|
2018-03-14 07:45:34 +01:00
|
|
|
}
|
2018-03-14 08:59:39 +01:00
|
|
|
},
|
2018-03-14 13:27:26 +01:00
|
|
|
openReply (message) {
|
2018-05-14 17:37:11 +02:00
|
|
|
this.$store.dispatch('TimelineSpace/Modals/NewToot/openReply', this.originalMessage(message))
|
2018-04-10 07:18:39 +02:00
|
|
|
},
|
2018-04-10 10:45:23 +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-07-01 14:51:05 +02:00
|
|
|
this.$refs.popper.doClose()
|
2018-04-10 10:45:23 +02:00
|
|
|
},
|
2018-04-27 01:46:44 +02:00
|
|
|
openBrowser (message) {
|
|
|
|
shell.openExternal(message.url)
|
2018-07-01 14:51:05 +02:00
|
|
|
this.$refs.popper.doClose()
|
2018-04-27 01:46:44 +02:00
|
|
|
},
|
|
|
|
copyLink (message) {
|
|
|
|
clipboard.writeText(message.url, 'toot-link')
|
2018-07-01 14:51:05 +02:00
|
|
|
this.$refs.popper.doClose()
|
2018-04-15 06:41:20 +02:00
|
|
|
},
|
2018-09-30 16:01:40 +02:00
|
|
|
reportUser (message) {
|
|
|
|
this.$store.dispatch('TimelineSpace/Modals/Report/openReport', this.originalMessage(message))
|
|
|
|
this.$refs.popper.doClose()
|
|
|
|
},
|
2018-09-30 16:55:33 +02:00
|
|
|
confirmMute (message) {
|
|
|
|
this.$store.dispatch('TimelineSpace/Modals/MuteConfirm/changeAccount', this.originalMessage(message).account)
|
|
|
|
this.$store.dispatch('TimelineSpace/Modals/MuteConfirm/changeModal', true)
|
|
|
|
this.$refs.popper.doClose()
|
|
|
|
},
|
|
|
|
block (message) {
|
|
|
|
this.$store.dispatch('TimelineSpace/Contents/Cards/Toot/block', this.originalMessage(message).account)
|
|
|
|
this.$refs.popper.doClose()
|
|
|
|
},
|
2018-03-14 14:38:42 +01:00
|
|
|
changeReblog (message) {
|
|
|
|
if (message.reblogged) {
|
2018-03-29 17:20:15 +02:00
|
|
|
this.$store.dispatch('TimelineSpace/Contents/Cards/Toot/unreblog', message)
|
2018-03-14 14:38:42 +01:00
|
|
|
.then((data) => {
|
|
|
|
this.$emit('update', data)
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
this.$message({
|
2018-08-13 08:27:53 +02:00
|
|
|
message: this.$t('message.unreblog_error'),
|
2018-03-14 14:38:42 +01:00
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else {
|
2018-03-29 17:20:15 +02:00
|
|
|
this.$store.dispatch('TimelineSpace/Contents/Cards/Toot/reblog', message)
|
2018-03-14 14:38:42 +01:00
|
|
|
.then((data) => {
|
|
|
|
this.$emit('update', data)
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
this.$message({
|
2018-08-13 08:27:53 +02:00
|
|
|
message: this.$t('message.reblog_error'),
|
2018-03-14 14:38:42 +01:00
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2018-03-14 09:35:44 +01:00
|
|
|
changeFavourite (message) {
|
|
|
|
if (message.favourited) {
|
2018-03-29 17:20:15 +02:00
|
|
|
this.$store.dispatch('TimelineSpace/Contents/Cards/Toot/removeFavourite', message)
|
2018-03-14 10:08:07 +01:00
|
|
|
.then((data) => {
|
|
|
|
this.$emit('update', data)
|
|
|
|
})
|
2018-03-14 09:35:44 +01:00
|
|
|
.catch(() => {
|
|
|
|
this.$message({
|
2018-08-13 08:27:53 +02:00
|
|
|
message: this.$t('message.unfavourite_error'),
|
2018-03-14 09:35:44 +01:00
|
|
|
type: 'error'
|
|
|
|
})
|
2018-03-14 08:59:39 +01:00
|
|
|
})
|
2018-03-14 09:35:44 +01:00
|
|
|
} else {
|
2018-03-29 17:20:15 +02:00
|
|
|
this.$store.dispatch('TimelineSpace/Contents/Cards/Toot/addFavourite', message)
|
2018-03-14 10:08:07 +01:00
|
|
|
.then((data) => {
|
|
|
|
this.$emit('update', data)
|
|
|
|
})
|
2018-03-14 09:35:44 +01:00
|
|
|
.catch(() => {
|
|
|
|
this.$message({
|
2018-08-13 08:27:53 +02:00
|
|
|
message: this.$t('message.favourite_error'),
|
2018-03-14 09:35:44 +01:00
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
2018-03-28 02:57:21 +02:00
|
|
|
},
|
2018-04-27 12:15:14 +02:00
|
|
|
openImage (url, rawMediaList) {
|
|
|
|
const mediaList = rawMediaList.map((media) => {
|
|
|
|
return media.url
|
|
|
|
})
|
|
|
|
const currentIndex = mediaList.indexOf(url)
|
|
|
|
this.$store.dispatch(
|
|
|
|
'TimelineSpace/Modals/ImageViewer/openModal',
|
|
|
|
{
|
|
|
|
currentIndex: currentIndex,
|
2018-10-31 15:04:49 +01:00
|
|
|
mediaList: rawMediaList
|
2018-04-27 12:15:14 +02:00
|
|
|
})
|
2018-03-29 15:41:28 +02:00
|
|
|
},
|
|
|
|
openUser (account) {
|
2018-03-30 09:48:32 +02:00
|
|
|
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-04-27 12:15:14 +02:00
|
|
|
},
|
2018-05-24 01:46:03 +02:00
|
|
|
mediaAttachments (message) {
|
2018-04-27 12:15:14 +02:00
|
|
|
return this.originalMessage(message).media_attachments
|
2018-04-29 02:40:02 +02:00
|
|
|
},
|
|
|
|
reblogsCount (message) {
|
|
|
|
if (this.originalMessage(message).reblogs_count > 0) {
|
|
|
|
return this.originalMessage(message).reblogs_count
|
2018-04-29 02:51:08 +02:00
|
|
|
}
|
|
|
|
return ''
|
|
|
|
},
|
|
|
|
favouritesCount (message) {
|
|
|
|
if (this.originalMessage(message).favourites_count > 0) {
|
|
|
|
return this.originalMessage(message).favourites_count
|
2018-04-29 02:40:02 +02:00
|
|
|
}
|
|
|
|
return ''
|
2018-04-30 14:33:12 +02:00
|
|
|
},
|
|
|
|
isMyMessage (message) {
|
|
|
|
return this.$store.state.TimelineSpace.account.accountId === this.originalMessage(message).account.id
|
|
|
|
},
|
|
|
|
deleteToot (message) {
|
2018-04-30 15:04:33 +02:00
|
|
|
this.$store.dispatch('TimelineSpace/Contents/Cards/Toot/deleteToot', message)
|
|
|
|
.then((message) => {
|
|
|
|
this.$emit('delete', message)
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
this.$message({
|
2018-08-13 08:27:53 +02:00
|
|
|
message: this.$t('message.delete_error'),
|
2018-04-30 15:04:33 +02:00
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
})
|
2018-05-14 15:16:51 +02:00
|
|
|
},
|
|
|
|
application (message) {
|
|
|
|
let msg = this.originalMessage(message)
|
|
|
|
if (msg.application !== undefined &&
|
|
|
|
msg.application !== null) {
|
|
|
|
return msg.application.name
|
|
|
|
}
|
2018-05-25 01:39:03 +02:00
|
|
|
return null
|
2018-05-22 18:20:36 +02:00
|
|
|
},
|
|
|
|
spoilered (message) {
|
|
|
|
return this.originalMessage(message).spoiler_text.length > 0
|
|
|
|
},
|
|
|
|
isShowContent (message) {
|
2018-05-24 01:46:03 +02:00
|
|
|
return !this.spoilered(message) || this.showContent
|
|
|
|
},
|
|
|
|
sensitive (message) {
|
|
|
|
return this.originalMessage(message).sensitive && this.mediaAttachments(message).length > 0
|
|
|
|
},
|
|
|
|
isShowAttachments (message) {
|
|
|
|
return !this.sensitive(message) || this.showAttachments
|
2018-07-09 01:49:49 +02:00
|
|
|
},
|
2018-07-10 15:10:57 +02:00
|
|
|
filtered (message) {
|
2018-07-10 15:52:08 +02:00
|
|
|
return this.filter.length > 0 && this.originalMessage(message).content.search(this.filter) >= 0
|
2018-07-15 07:35:08 +02:00
|
|
|
},
|
|
|
|
locked (message) {
|
2018-08-20 15:07:22 +02:00
|
|
|
return message.visibility === 'private'
|
|
|
|
},
|
|
|
|
directed (message) {
|
|
|
|
return message.visibility === 'direct'
|
2018-08-18 15:15:46 +02:00
|
|
|
},
|
|
|
|
status (message) {
|
|
|
|
const original = this.originalMessage(message)
|
|
|
|
return emojify(original.content, original.emojis)
|
2018-08-18 15:22:25 +02:00
|
|
|
},
|
|
|
|
spoilerText (message) {
|
|
|
|
const original = this.originalMessage(message)
|
|
|
|
return emojify(original.spoiler_text, original.emojis)
|
2018-08-21 16:02:05 +02:00
|
|
|
},
|
|
|
|
handleTootControl (event) {
|
|
|
|
switch (event.srcKey) {
|
|
|
|
case 'next':
|
|
|
|
this.$emit('focusNext')
|
|
|
|
break
|
|
|
|
case 'prev':
|
|
|
|
this.$emit('focusPrev')
|
|
|
|
break
|
2018-08-22 07:32:29 +02:00
|
|
|
case 'reply':
|
|
|
|
this.openReply(this.message)
|
|
|
|
break
|
|
|
|
case 'boost':
|
|
|
|
this.changeReblog(this.message)
|
|
|
|
break
|
|
|
|
case 'fav':
|
|
|
|
this.changeFavourite(this.message)
|
|
|
|
break
|
|
|
|
case 'open':
|
|
|
|
this.openDetail(this.message)
|
|
|
|
break
|
|
|
|
case 'profile':
|
|
|
|
this.openUser(this.originalMessage(this.message).account)
|
|
|
|
break
|
2018-08-27 18:17:05 +02:00
|
|
|
case 'image':
|
|
|
|
const images = this.mediaAttachments(this.message)
|
|
|
|
if (images.length === 0) {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
this.openImage(images[0].url, images)
|
|
|
|
break
|
|
|
|
case 'cw':
|
|
|
|
this.showContent = !this.showContent
|
|
|
|
this.showAttachments = !this.showAttachments
|
|
|
|
break
|
2018-08-21 16:02:05 +02:00
|
|
|
}
|
2018-03-12 12:04:30 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-12 08:42:05 +01:00
|
|
|
}
|
|
|
|
</script>
|
2018-03-12 11:36:13 +01:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
|
|
.toot {
|
2018-04-17 16:09:56 +02:00
|
|
|
padding: 8px 0 0 16px;
|
2018-03-21 03:32:37 +01:00
|
|
|
|
2018-03-12 11:36:13 +01:00
|
|
|
.icon {
|
|
|
|
float: left;
|
|
|
|
|
|
|
|
img {
|
|
|
|
width: 36px;
|
|
|
|
height: 36px;
|
|
|
|
border-radius: 4px;
|
2018-03-30 09:48:32 +02:00
|
|
|
cursor: pointer;
|
2018-03-12 11:36:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.detail {
|
2018-05-28 14:54:35 +02:00
|
|
|
margin: 0 8px 0 8px;
|
|
|
|
float: left;
|
|
|
|
width: calc(100% - 52px);
|
2018-03-12 11:36:13 +01:00
|
|
|
|
|
|
|
.toot-header {
|
|
|
|
.user {
|
|
|
|
float: left;
|
2018-04-21 11:59:34 +02:00
|
|
|
font-size: var(--base-font-size);
|
2018-03-30 09:48:32 +02:00
|
|
|
cursor: pointer;
|
2018-04-17 16:09:56 +02:00
|
|
|
white-space: nowrap;
|
|
|
|
max-width: 100%;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
2018-04-17 16:46:16 +02:00
|
|
|
|
2018-11-13 16:14:57 +01:00
|
|
|
.display-name /deep/ {
|
2018-04-17 16:46:16 +02:00
|
|
|
font-weight: 800;
|
|
|
|
color: var(--theme-primary-color);
|
2018-11-13 16:14:57 +01:00
|
|
|
|
|
|
|
.emojione {
|
|
|
|
max-width: 14px;
|
|
|
|
max-height: 14px;
|
|
|
|
}
|
2018-04-17 16:46:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.acct {
|
|
|
|
font-weight: normal;
|
|
|
|
color: var(--theme-secondary-color);
|
|
|
|
}
|
2018-03-12 11:36:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.timestamp {
|
2018-04-21 11:59:34 +02:00
|
|
|
font-size: var(--base-font-size);
|
2018-03-12 11:36:13 +01:00
|
|
|
text-align: right;
|
|
|
|
color: #909399;
|
2018-09-21 16:46:08 +02:00
|
|
|
float: right;
|
2018-03-12 11:36:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-18 15:22:25 +02:00
|
|
|
.content-wrapper /deep/ {
|
2018-04-21 11:59:34 +02:00
|
|
|
font-size: var(--base-font-size);
|
2018-04-13 02:09:51 +02:00
|
|
|
color: var(--theme-primary-color);
|
2018-05-22 18:20:36 +02:00
|
|
|
|
2018-08-18 15:22:25 +02:00
|
|
|
.content {
|
2018-05-22 18:20:36 +02:00
|
|
|
margin: 4px 0 8px;
|
|
|
|
word-wrap: break-word;
|
2018-08-18 15:22:25 +02:00
|
|
|
}
|
2018-08-18 15:15:46 +02:00
|
|
|
|
2018-08-18 15:22:25 +02:00
|
|
|
.emojione {
|
|
|
|
width: 20px;
|
|
|
|
height: 20px;
|
2018-05-22 18:20:36 +02:00
|
|
|
}
|
2018-03-12 11:36:13 +01:00
|
|
|
}
|
|
|
|
|
2018-03-24 15:55:23 +01:00
|
|
|
.attachments {
|
2018-05-24 01:46:03 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-24 15:55:23 +01:00
|
|
|
.media {
|
2018-04-04 12:56:00 +02:00
|
|
|
float: left;
|
|
|
|
margin-right: 8px;
|
2018-03-24 15:55:23 +01:00
|
|
|
img {
|
2018-03-28 02:57:21 +02:00
|
|
|
cursor: zoom-in;
|
2018-04-04 02:06:41 +02:00
|
|
|
max-width: 200px;
|
|
|
|
max-height: 200px;
|
2018-03-24 15:58:38 +01:00
|
|
|
border-radius: 8px;
|
2018-03-24 15:55:23 +01:00
|
|
|
}
|
2018-10-31 15:04:49 +01:00
|
|
|
|
|
|
|
.media-label {
|
|
|
|
position: absolute;
|
|
|
|
bottom: 8px;
|
|
|
|
left: 8px;
|
|
|
|
color: #fff;
|
|
|
|
background: rgba(0, 0, 0, 0.5);
|
|
|
|
font-size: 0.8rem;
|
|
|
|
border-radius: 2px;
|
|
|
|
}
|
2018-03-24 15:55:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-14 15:09:04 +01:00
|
|
|
.reblogger {
|
|
|
|
color: #909399;
|
|
|
|
|
|
|
|
.reblogger-icon {
|
|
|
|
img {
|
|
|
|
width: 16px;
|
|
|
|
height: 16px;
|
|
|
|
border-radius: 2px;
|
2018-04-04 13:35:18 +02:00
|
|
|
cursor: pointer;
|
2018-03-14 15:09:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-13 16:14:57 +01:00
|
|
|
.reblogger-name /deep/ {
|
2018-04-21 11:59:34 +02:00
|
|
|
font-size: calc(var(--base-font-size) * 0.86);
|
2018-04-04 13:35:18 +02:00
|
|
|
cursor: pointer;
|
2018-11-13 16:14:57 +01:00
|
|
|
|
|
|
|
.emojione {
|
|
|
|
max-width: 10px;
|
|
|
|
max-height: 10px;
|
|
|
|
}
|
2018-03-14 15:09:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-12 11:36:13 +01:00
|
|
|
.tool-box {
|
2018-05-14 15:16:51 +02:00
|
|
|
float: left;
|
|
|
|
|
2018-03-12 11:36:13 +01:00
|
|
|
button {
|
|
|
|
margin: 0 8px;
|
|
|
|
padding: 0;
|
|
|
|
color: #909399;
|
|
|
|
}
|
2018-03-14 09:28:12 +01:00
|
|
|
|
2018-03-14 14:54:19 +01:00
|
|
|
.reblogged {
|
|
|
|
color: #409eff;
|
|
|
|
}
|
|
|
|
|
2018-03-14 09:28:12 +01:00
|
|
|
.favourited {
|
|
|
|
color: #e6a23c;
|
|
|
|
}
|
2018-04-15 10:45:14 +02:00
|
|
|
|
2018-04-29 02:40:02 +02:00
|
|
|
.count {
|
|
|
|
font-size: 0.8em;
|
|
|
|
color: #909399;
|
|
|
|
margin: 0 0 4px -8px;
|
|
|
|
}
|
|
|
|
|
2018-04-15 10:45:14 +02:00
|
|
|
.toot-menu {
|
2018-09-13 14:38:03 +02:00
|
|
|
padding: 2px 0;
|
|
|
|
border-color: #909399;
|
|
|
|
|
2018-04-15 10:45:14 +02:00
|
|
|
.menu-list {
|
|
|
|
padding: 0;
|
2018-04-30 14:33:12 +02:00
|
|
|
margin: 4px 0;
|
2018-09-13 14:38:03 +02:00
|
|
|
font-size: 0.9rem;
|
2018-04-15 10:45:14 +02:00
|
|
|
list-style-type: none;
|
2018-09-13 14:38:03 +02:00
|
|
|
line-height: 32px;
|
2018-04-15 10:45:14 +02:00
|
|
|
text-align: left;
|
|
|
|
color: #303133;
|
|
|
|
|
|
|
|
li {
|
|
|
|
box-sizing: border-box;
|
2018-09-13 14:38:03 +02:00
|
|
|
padding: 0 32px 0 16px;
|
2018-04-15 10:45:14 +02:00
|
|
|
|
|
|
|
&:hover {
|
2018-09-13 14:38:03 +02:00
|
|
|
background-color: #409eff;
|
|
|
|
color: #fff;
|
2018-04-15 10:45:14 +02:00
|
|
|
cursor: pointer;
|
|
|
|
}
|
2018-04-30 14:33:12 +02:00
|
|
|
|
|
|
|
&.separate {
|
|
|
|
border-top: 1px solid var(--theme-border-color);
|
|
|
|
padding-top: 4px;
|
|
|
|
margin-top: 2px;
|
|
|
|
}
|
2018-04-15 10:45:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-12 11:36:13 +01:00
|
|
|
}
|
2018-03-21 03:04:28 +01:00
|
|
|
|
2018-05-14 15:16:51 +02:00
|
|
|
.application {
|
|
|
|
float: right;
|
|
|
|
color: #909399;
|
|
|
|
}
|
|
|
|
|
2018-03-21 03:04:28 +01:00
|
|
|
.reply:hover,
|
|
|
|
.reblog:hover,
|
|
|
|
.favourite:hover {
|
|
|
|
color: #409eff;
|
|
|
|
}
|
2018-03-12 11:36:13 +01:00
|
|
|
}
|
2018-04-13 02:09:51 +02:00
|
|
|
|
2018-04-13 16:42:00 +02:00
|
|
|
.action-pop-over {
|
|
|
|
color: #303133;
|
|
|
|
}
|
2018-03-12 11:36:13 +01:00
|
|
|
}
|
2018-03-21 03:32:37 +01:00
|
|
|
|
2018-07-10 15:10:57 +02:00
|
|
|
.filtered {
|
2018-07-09 01:49:49 +02:00
|
|
|
align-items: center;
|
|
|
|
display: flex;
|
|
|
|
height: 40px;
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.status:focus {
|
2018-04-13 02:09:51 +02:00
|
|
|
background-color: var(--theme-selected-background-color);
|
2018-03-21 03:32:37 +01:00
|
|
|
outline: 0;
|
|
|
|
}
|
2018-07-09 01:49:49 +02:00
|
|
|
|
|
|
|
.fill-line {
|
|
|
|
height: 1px;
|
|
|
|
background-color: var(--theme-border-color);
|
|
|
|
margin: 4px 0 0;
|
|
|
|
}
|
2018-03-12 11:36:13 +01:00
|
|
|
</style>
|