2018-03-12 08:42:05 +01:00
|
|
|
<template>
|
2018-03-21 03:32:37 +01:00
|
|
|
<div class="toot" tabIndex="0">
|
2018-03-12 08:42:05 +01:00
|
|
|
<div class="icon">
|
2018-03-14 15:27:36 +01:00
|
|
|
<img :src="originalMessage(message).account.avatar" />
|
2018-03-12 08:42:05 +01:00
|
|
|
</div>
|
|
|
|
<div class="detail">
|
|
|
|
<div class="toot-header">
|
2018-03-12 11:36:13 +01:00
|
|
|
<div class="user">
|
2018-03-14 15:27:36 +01:00
|
|
|
{{ originalMessage(message).account.display_name }}
|
2018-03-12 08:42:05 +01:00
|
|
|
</div>
|
|
|
|
<div class="timestamp">
|
2018-03-12 12:04:30 +01:00
|
|
|
{{ parseDatetime(message.created_at) }}
|
2018-03-12 08:42:05 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-03-14 07:45:34 +01:00
|
|
|
<div class="content" v-html="message.content" @click.capture.prevent="tootClick"></div>
|
2018-03-24 15:55:23 +01:00
|
|
|
<div class="attachments">
|
|
|
|
<div class="media" v-for="media in originalMessage(message).media_attachments">
|
|
|
|
<img :src="media.preview_url" />
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-03-14 15:09:04 +01:00
|
|
|
<div class="reblogger" v-if="message.reblog !== null">
|
|
|
|
<icon name="retweet"></icon>
|
|
|
|
<span class="reblogger-icon">
|
|
|
|
<img :src="message.account.avatar" />
|
|
|
|
</span>
|
|
|
|
<span class="reblogger-name">
|
|
|
|
{{ message.account.display_name }}
|
|
|
|
</span>
|
|
|
|
</div>
|
2018-03-12 08:42:05 +01:00
|
|
|
<div class="tool-box">
|
2018-03-21 03:04:28 +01:00
|
|
|
<el-button type="text" @click="openReply(message)" class="reply">
|
2018-03-14 14:38:42 +01:00
|
|
|
<icon name="reply" scale="0.9"></icon>
|
|
|
|
</el-button>
|
2018-03-21 03:04:28 +01:00
|
|
|
<el-button type="text" @click="changeReblog(originalMessage(message))" :class="originalMessage(message).reblogged ? 'reblogged' : 'reblog'">
|
2018-03-14 14:38:42 +01:00
|
|
|
<icon name="retweet" scale="0.9"></icon>
|
|
|
|
</el-button>
|
2018-03-21 03:04:28 +01:00
|
|
|
<el-button type="text" @click="changeFavourite(originalMessage(message))" :class="originalMessage(message).favourited ? 'favourited' : 'favourite'">
|
2018-03-14 14:38:42 +01:00
|
|
|
<icon name="star" scale="0.9"></icon>
|
|
|
|
</el-button>
|
2018-03-12 08:42:05 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-03-12 11:36:13 +01:00
|
|
|
<div class="clearfix"></div>
|
|
|
|
<div class="fill-line"></div>
|
2018-03-12 08:42:05 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-03-12 12:04:30 +01:00
|
|
|
import moment from 'moment'
|
2018-03-14 07:45:34 +01:00
|
|
|
import { shell } from 'electron'
|
2018-03-12 12:04:30 +01:00
|
|
|
|
2018-03-12 08:42:05 +01:00
|
|
|
export default {
|
|
|
|
name: 'toot',
|
2018-03-12 12:04:30 +01:00
|
|
|
props: ['message'],
|
|
|
|
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-12 12:04:30 +01:00
|
|
|
parseDatetime (datetime) {
|
|
|
|
return moment(datetime).format('YYYY-MM-DD HH:mm:ss')
|
2018-03-14 07:45:34 +01:00
|
|
|
},
|
|
|
|
tootClick (e) {
|
|
|
|
const link = findLink(e.target)
|
|
|
|
if (link !== null) {
|
|
|
|
shell.openExternal(link)
|
|
|
|
}
|
2018-03-14 08:59:39 +01:00
|
|
|
},
|
2018-03-14 13:27:26 +01:00
|
|
|
openReply (message) {
|
2018-03-14 14:19:17 +01:00
|
|
|
this.$store.dispatch('TimelineSpace/NewTootModal/openReply', message)
|
2018-03-14 13:27:26 +01:00
|
|
|
},
|
2018-03-14 14:38:42 +01:00
|
|
|
changeReblog (message) {
|
|
|
|
if (message.reblogged) {
|
|
|
|
this.$store.dispatch('TimelineSpace/Cards/Toot/unreblog', message)
|
|
|
|
.then((data) => {
|
|
|
|
this.$emit('update', data)
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
this.$message({
|
|
|
|
message: 'Faild to unreblog',
|
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.$store.dispatch('TimelineSpace/Cards/Toot/reblog', message)
|
|
|
|
.then((data) => {
|
|
|
|
this.$emit('update', data)
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
this.$message({
|
|
|
|
message: 'Faild to reblog',
|
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2018-03-14 09:35:44 +01:00
|
|
|
changeFavourite (message) {
|
|
|
|
if (message.favourited) {
|
|
|
|
this.$store.dispatch('TimelineSpace/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({
|
|
|
|
message: 'Failed to unfavourite',
|
|
|
|
type: 'error'
|
|
|
|
})
|
2018-03-14 08:59:39 +01:00
|
|
|
})
|
2018-03-14 09:35:44 +01:00
|
|
|
} else {
|
|
|
|
this.$store.dispatch('TimelineSpace/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({
|
|
|
|
message: 'Failed to favourite',
|
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
2018-03-12 12:04:30 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-12 08:42:05 +01:00
|
|
|
}
|
2018-03-14 07:45:34 +01:00
|
|
|
|
|
|
|
function findLink (target) {
|
|
|
|
if (target.localName === 'a') {
|
|
|
|
return target.href
|
|
|
|
}
|
|
|
|
if (target.parentNode === undefined || target.parentNode === null) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
return findLink(target.parentNode)
|
|
|
|
}
|
2018-03-12 08:42:05 +01:00
|
|
|
</script>
|
2018-03-12 11:36:13 +01:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.fill-line {
|
|
|
|
height: 1px;
|
2018-03-21 03:32:37 +01:00
|
|
|
background-color: #ebeef5;
|
|
|
|
margin: 4px 0 0;
|
2018-03-12 11:36:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.toot {
|
2018-03-21 03:32:37 +01:00
|
|
|
padding: 4px 0 0 16px;
|
2018-03-22 10:09:58 +01:00
|
|
|
background-color: #ffffff;
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.detail {
|
2018-03-21 03:32:37 +01:00
|
|
|
margin: 0 8px 0 42px;
|
2018-03-12 11:36:13 +01:00
|
|
|
|
|
|
|
.toot-header {
|
|
|
|
.user {
|
|
|
|
float: left;
|
|
|
|
font-weight: 800;
|
|
|
|
color: #303133;
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.timestamp {
|
|
|
|
font-size: 14px;
|
|
|
|
text-align: right;
|
|
|
|
width: 100%;
|
|
|
|
color: #909399;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.content {
|
|
|
|
font-size: 14px;
|
|
|
|
color: #303133;
|
|
|
|
margin: 4px 0 8px;
|
2018-03-24 02:00:35 +01:00
|
|
|
word-wrap: break-word;
|
2018-03-12 11:36:13 +01:00
|
|
|
}
|
|
|
|
|
2018-03-24 15:55:23 +01:00
|
|
|
.attachments {
|
|
|
|
.media {
|
|
|
|
img {
|
|
|
|
width: 200px;
|
|
|
|
max-width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-14 15:09:04 +01:00
|
|
|
.reblogger {
|
|
|
|
color: #909399;
|
|
|
|
|
|
|
|
.reblogger-icon {
|
|
|
|
img {
|
|
|
|
width: 16px;
|
|
|
|
height: 16px;
|
|
|
|
border-radius: 2px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.reblogger-name {
|
|
|
|
font-size: 12px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-12 11:36:13 +01:00
|
|
|
.tool-box {
|
|
|
|
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-03-12 11:36:13 +01:00
|
|
|
}
|
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-03-21 03:32:37 +01:00
|
|
|
|
|
|
|
.toot:focus {
|
|
|
|
background-color: #f2f6fc;
|
|
|
|
outline: 0;
|
|
|
|
}
|
2018-03-12 11:36:13 +01:00
|
|
|
</style>
|