2018-03-12 08:42:05 +01:00
|
|
|
<template>
|
|
|
|
<div class="toot">
|
|
|
|
<div class="icon">
|
|
|
|
<img :src="message.account.avatar" />
|
|
|
|
</div>
|
|
|
|
<div class="detail">
|
|
|
|
<div class="toot-header">
|
2018-03-12 11:36:13 +01:00
|
|
|
<div class="user">
|
2018-03-12 08:42:05 +01:00
|
|
|
{{ message.account.display_name }}
|
|
|
|
</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-12 08:42:05 +01:00
|
|
|
<div class="tool-box">
|
2018-03-14 13:27:26 +01:00
|
|
|
<el-button type="text" @click="openReply(message)"><icon name="reply" scale="0.9"></icon></el-button>
|
2018-03-12 11:36:13 +01:00
|
|
|
<el-button type="text"><icon name="retweet" scale="0.9"></icon></el-button>
|
2018-03-14 09:35:44 +01:00
|
|
|
<el-button type="text" @click="changeFavourite(message)" :class="message.favourited ? 'favourited' : ''"><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: {
|
|
|
|
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 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;
|
|
|
|
background-color: #f2f6fc;
|
|
|
|
margin: 4px 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.toot {
|
|
|
|
.icon {
|
|
|
|
float: left;
|
|
|
|
|
|
|
|
img {
|
|
|
|
width: 36px;
|
|
|
|
height: 36px;
|
|
|
|
border-radius: 4px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.detail {
|
|
|
|
margin-left: 42px;
|
|
|
|
margin-right: 8px;
|
|
|
|
margin-top: 8px;
|
|
|
|
|
|
|
|
.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;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tool-box {
|
|
|
|
button {
|
|
|
|
margin: 0 8px;
|
|
|
|
padding: 0;
|
|
|
|
color: #909399;
|
|
|
|
}
|
2018-03-14 09:28:12 +01:00
|
|
|
|
|
|
|
.favourited {
|
|
|
|
color: #e6a23c;
|
|
|
|
}
|
2018-03-12 11:36:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|