Post --> Note

Closes #1411
This commit is contained in:
syuilo
2018-04-08 02:30:37 +09:00
parent c7106d250c
commit a1b490afa7
167 changed files with 4440 additions and 1762 deletions

View File

@@ -1,19 +1,19 @@
<template>
<div class="post" :class="{ repost: isRepost }">
<div class="note" :class="{ renote: isRenote }">
<div class="reply-to" v-if="p.reply">
<x-sub :post="p.reply"/>
<x-sub :note="p.reply"/>
</div>
<div class="repost" v-if="isRepost">
<div class="renote" v-if="isRenote">
<p>
<router-link class="avatar-anchor" :to="`/@${acct}`">
<img class="avatar" :src="`${post.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/>
<img class="avatar" :src="`${note.user.avatarUrl}?thumbnail&size=64`" alt="avatar"/>
</router-link>
%fa:retweet%
<span>{{ '%i18n:mobile.tags.mk-timeline-post.reposted-by%'.substr(0, '%i18n:mobile.tags.mk-timeline-post.reposted-by%'.indexOf('{')) }}</span>
<span>{{ '%i18n:mobile.tags.mk-timeline-note.reposted-by%'.substr(0, '%i18n:mobile.tags.mk-timeline-note.reposted-by%'.indexOf('{')) }}</span>
<router-link class="name" :to="`/@${acct}`">{{ name }}</router-link>
<span>{{ '%i18n:mobile.tags.mk-timeline-post.reposted-by%'.substr('%i18n:mobile.tags.mk-timeline-post.reposted-by%'.indexOf('}') + 1) }}</span>
<span>{{ '%i18n:mobile.tags.mk-timeline-note.reposted-by%'.substr('%i18n:mobile.tags.mk-timeline-note.reposted-by%'.indexOf('}') + 1) }}</span>
</p>
<mk-time :time="post.createdAt"/>
<mk-time :time="note.createdAt"/>
</div>
<article>
<router-link class="avatar-anchor" :to="`/@${pAcct}`">
@@ -37,13 +37,13 @@
<a class="reply" v-if="p.reply">
%fa:reply%
</a>
<mk-post-html v-if="p.text" :text="p.text" :i="os.i" :class="$style.text"/>
<a class="rp" v-if="p.repost != null">RP:</a>
<mk-note-html v-if="p.text" :text="p.text" :i="os.i" :class="$style.text"/>
<a class="rp" v-if="p.renote != null">RP:</a>
</div>
<div class="media" v-if="p.media.length > 0">
<mk-media-list :media-list="p.media"/>
</div>
<mk-poll v-if="p.poll" :post="p" ref="pollViewer"/>
<mk-poll v-if="p.poll" :note="p" ref="pollViewer"/>
<div class="tags" v-if="p.tags && p.tags.length > 0">
<router-link v-for="tag in p.tags" :key="tag" :to="`/search?q=#${tag}`">{{ tag }}</router-link>
</div>
@@ -51,17 +51,17 @@
<a class="location" v-if="p.geo" :href="`http://maps.google.com/maps?q=${p.geo.coordinates[1]},${p.geo.coordinates[0]}`" target="_blank">%fa:map-marker-alt% 位置情報</a>
<div class="map" v-if="p.geo" ref="map"></div>
<span class="app" v-if="p.app">via <b>{{ p.app.name }}</b></span>
<div class="repost" v-if="p.repost">
<mk-post-preview :post="p.repost"/>
<div class="renote" v-if="p.renote">
<mk-note-preview :note="p.renote"/>
</div>
</div>
<footer>
<mk-reactions-viewer :post="p" ref="reactionsViewer"/>
<mk-reactions-viewer :note="p" ref="reactionsViewer"/>
<button @click="reply">
%fa:reply%<p class="count" v-if="p.repliesCount > 0">{{ p.repliesCount }}</p>
</button>
<button @click="repost" title="Repost">
%fa:retweet%<p class="count" v-if="p.repostCount > 0">{{ p.repostCount }}</p>
<button @click="renote" title="Renote">
%fa:retweet%<p class="count" v-if="p.renoteCount > 0">{{ p.renoteCount }}</p>
</button>
<button :class="{ reacted: p.myReaction != null }" @click="react" ref="reactButton">
%fa:plus%<p class="count" v-if="p.reactions_count > 0">{{ p.reactions_count }}</p>
@@ -81,16 +81,16 @@ import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
import parse from '../../../../../text/parse';
import MkPostMenu from '../../../common/views/components/post-menu.vue';
import MkNoteMenu from '../../../common/views/components/note-menu.vue';
import MkReactionPicker from '../../../common/views/components/reaction-picker.vue';
import XSub from './post.sub.vue';
import XSub from './note.sub.vue';
export default Vue.extend({
components: {
XSub
},
props: ['post'],
props: ['note'],
data() {
return {
@@ -101,10 +101,10 @@ export default Vue.extend({
computed: {
acct(): string {
return getAcct(this.post.user);
return getAcct(this.note.user);
},
name(): string {
return getUserName(this.post.user);
return getUserName(this.note.user);
},
pAcct(): string {
return getAcct(this.p.user);
@@ -112,14 +112,14 @@ export default Vue.extend({
pName(): string {
return getUserName(this.p.user);
},
isRepost(): boolean {
return (this.post.repost &&
this.post.text == null &&
this.post.mediaIds == null &&
this.post.poll == null);
isRenote(): boolean {
return (this.note.renote &&
this.note.text == null &&
this.note.mediaIds == null &&
this.note.poll == null);
},
p(): any {
return this.isRepost ? this.post.repost : this.post;
return this.isRenote ? this.note.renote : this.note;
},
reactionsCount(): number {
return this.p.reactionCounts
@@ -192,7 +192,7 @@ export default Vue.extend({
type: 'capture',
id: this.p.id
});
if (withHandler) this.connection.on('post-updated', this.onStreamPostUpdated);
if (withHandler) this.connection.on('note-updated', this.onStreamNoteUpdated);
}
},
decapture(withHandler = false) {
@@ -201,18 +201,18 @@ export default Vue.extend({
type: 'decapture',
id: this.p.id
});
if (withHandler) this.connection.off('post-updated', this.onStreamPostUpdated);
if (withHandler) this.connection.off('note-updated', this.onStreamNoteUpdated);
}
},
onStreamConnected() {
this.capture();
},
onStreamPostUpdated(data) {
const post = data.post;
if (post.id == this.post.id) {
this.$emit('update:post', post);
} else if (post.id == this.post.repostId) {
this.post.repost = post;
onStreamNoteUpdated(data) {
const note = data.note;
if (note.id == this.note.id) {
this.$emit('update:note', note);
} else if (note.id == this.note.renoteId) {
this.note.renote = note;
}
},
reply() {
@@ -220,22 +220,22 @@ export default Vue.extend({
reply: this.p
});
},
repost() {
renote() {
(this as any).apis.post({
repost: this.p
renote: this.p
});
},
react() {
(this as any).os.new(MkReactionPicker, {
source: this.$refs.reactButton,
post: this.p,
note: this.p,
compact: true
});
},
menu() {
(this as any).os.new(MkPostMenu, {
(this as any).os.new(MkNoteMenu, {
source: this.$refs.menuButton,
post: this.p,
note: this.p,
compact: true
});
}
@@ -246,14 +246,14 @@ export default Vue.extend({
<style lang="stylus" scoped>
@import '~const.styl'
.post
.note
font-size 12px
border-bottom solid 1px #eaeaea
&:first-child
border-radius 8px 8px 0 0
> .repost
> .renote
border-radius 8px 8px 0 0
&:last-of-type
@@ -265,7 +265,7 @@ export default Vue.extend({
@media (min-width 500px)
font-size 16px
> .repost
> .renote
color #9dbb00
background linear-gradient(to bottom, #edfde2 0%, #fff 100%)
@@ -309,7 +309,7 @@ export default Vue.extend({
> .reply-to
background rgba(0, 0, 0, 0.0125)
> .mk-post-preview
> .mk-note-preview
background transparent
> article
@@ -485,10 +485,10 @@ export default Vue.extend({
> .mk-poll
font-size 80%
> .repost
> .renote
margin 8px 0
> .mk-post-preview
> .mk-note-preview
padding 16px
border dashed 1px #c0dac6
border-radius 8px