2018-03-12 08:42:05 +01:00
|
|
|
<template>
|
2018-04-13 02:09:51 +02:00
|
|
|
<div class="toot" tabIndex="0" :style="theme">
|
2018-03-12 08:42:05 +01:00
|
|
|
<div class="icon">
|
2018-03-29 15:41:28 +02:00
|
|
|
<img :src="originalMessage(message).account.avatar" @click="openUser(originalMessage(message).account)"/>
|
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-03-26 12:49:35 +02:00
|
|
|
{{ username(originalMessage(message).account) }}
|
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">
|
2018-03-28 02:57:21 +02:00
|
|
|
<img :src="media.preview_url" @click="openImage(media.url)"/>
|
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-04-04 13:35:18 +02:00
|
|
|
<div class="reblogger" v-if="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-03-14 15:09:04 +01:00
|
|
|
<img :src="message.account.avatar" />
|
|
|
|
</span>
|
2018-04-04 13:35:18 +02:00
|
|
|
<span class="reblogger-name" @click="openUser(message.account)">
|
2018-03-26 12:49:35 +02:00
|
|
|
{{ 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-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-04-15 10:45:14 +02:00
|
|
|
<popper trigger="click" :options="{placement: 'bottom'}">
|
|
|
|
<div class="popper toot-menu">
|
|
|
|
<ul class="menu-list">
|
|
|
|
<li role="button" @click="openDetail(message)">
|
|
|
|
View Toot Detail
|
|
|
|
</li>
|
|
|
|
<li role="button" @click="openBrowser(message)">
|
|
|
|
Open in Browser
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<el-button slot="reference" type="text">
|
|
|
|
<icon name="ellipsis-h" scale="0.9"></icon>
|
|
|
|
</el-button>
|
|
|
|
</popper>
|
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-04-13 02:09:51 +02:00
|
|
|
import { mapState } from 'vuex'
|
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'],
|
2018-04-13 02:09:51 +02:00
|
|
|
computed: {
|
|
|
|
...mapState({
|
|
|
|
theme: (state) => {
|
|
|
|
return {
|
|
|
|
'--theme-primary-color': state.App.theme.primary_color,
|
|
|
|
'--theme-selected-background-color': state.App.theme.selected_background_color,
|
|
|
|
'--theme-border-color': state.App.theme.border_color
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
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) {
|
|
|
|
if (account.display_name !== '') {
|
|
|
|
return account.display_name
|
|
|
|
} else {
|
|
|
|
return account.username
|
|
|
|
}
|
|
|
|
},
|
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-29 04:25:35 +02:00
|
|
|
this.$store.dispatch('TimelineSpace/Modals/NewToot/openReply', 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-04-15 10:45:14 +02:00
|
|
|
openBrowser () {
|
|
|
|
shell.openExternal(this.message.url)
|
2018-04-15 06:41:20 +02:00
|
|
|
},
|
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({
|
|
|
|
message: 'Faild to unreblog',
|
|
|
|
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({
|
|
|
|
message: 'Faild to reblog',
|
|
|
|
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({
|
|
|
|
message: 'Failed to unfavourite',
|
|
|
|
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({
|
|
|
|
message: 'Failed to favourite',
|
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
2018-03-28 02:57:21 +02:00
|
|
|
},
|
|
|
|
openImage (url) {
|
|
|
|
this.$store.dispatch('TimelineSpace/Modals/ImageViewer/openModal', url)
|
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-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
|
|
|
|
}
|
2018-03-26 15:27:45 +02:00
|
|
|
if (target.parentNode.getAttribute('class') === 'toot') {
|
|
|
|
return null
|
|
|
|
}
|
2018-03-14 07:45:34 +01:00
|
|
|
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>
|
|
|
|
|
|
|
|
.toot {
|
2018-04-13 02:09:51 +02:00
|
|
|
--theme-primary-color: #303133;
|
|
|
|
--theme-border-color: #ebeef5;
|
|
|
|
|
2018-03-21 03:32:37 +01:00
|
|
|
padding: 4px 0 0 16px;
|
|
|
|
|
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-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;
|
2018-04-13 02:09:51 +02:00
|
|
|
color: var(--theme-primary-color);
|
2018-03-12 11:36:13 +01:00
|
|
|
font-size: 14px;
|
2018-03-30 09:48:32 +02:00
|
|
|
cursor: pointer;
|
2018-03-12 11:36:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.timestamp {
|
|
|
|
font-size: 14px;
|
|
|
|
text-align: right;
|
|
|
|
width: 100%;
|
|
|
|
color: #909399;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.content {
|
|
|
|
font-size: 14px;
|
2018-04-13 02:09:51 +02:00
|
|
|
color: var(--theme-primary-color);
|
2018-03-12 11:36:13 +01:00
|
|
|
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 {
|
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-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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.reblogger-name {
|
|
|
|
font-size: 12px;
|
2018-04-04 13:35:18 +02:00
|
|
|
cursor: pointer;
|
2018-03-14 15:09:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-04-15 10:45:14 +02:00
|
|
|
|
|
|
|
.toot-menu {
|
|
|
|
padding-right: 8px;
|
|
|
|
|
|
|
|
.menu-list {
|
|
|
|
padding: 0;
|
|
|
|
font-size: 0.8em;
|
|
|
|
list-style-type: none;
|
|
|
|
line-height: 20px;
|
|
|
|
text-align: left;
|
|
|
|
color: #303133;
|
|
|
|
|
|
|
|
li {
|
|
|
|
box-sizing: border-box;
|
|
|
|
padding-left: 0.5em;
|
|
|
|
padding-bottom: 0.5em;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
background-color: #f2f6fc;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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-04-13 02:09:51 +02:00
|
|
|
|
|
|
|
.fill-line {
|
|
|
|
height: 1px;
|
|
|
|
background-color: var(--theme-border-color);
|
|
|
|
margin: 4px 0 0;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
.toot:focus {
|
2018-04-13 02:09:51 +02:00
|
|
|
--theme-selected-background-color: #f2f6fc;
|
|
|
|
background-color: var(--theme-selected-background-color);
|
2018-03-21 03:32:37 +01:00
|
|
|
outline: 0;
|
|
|
|
}
|
2018-03-12 11:36:13 +01:00
|
|
|
</style>
|