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

@@ -24,11 +24,11 @@ export default Vue.extend({
if (/^>>([0-9]+) /.test(this.text)) {
const index = this.text.match(/^>>([0-9]+) /)[1];
reply = (this.$parent as any).posts.find(p => p.index.toString() == index);
reply = (this.$parent as any).notes.find(p => p.index.toString() == index);
this.text = this.text.replace(/^>>([0-9]+) /, '');
}
(this as any).api('posts/create', {
(this as any).api('notes/create', {
text: this.text,
replyId: reply ? reply.id : undefined,
channelId: (this.$parent as any).channel.id

View File

@@ -1,15 +1,15 @@
<template>
<div class="post">
<div class="note">
<header>
<a class="index" @click="reply">{{ post.index }}:</a>
<router-link class="name" :to="`/@${acct}`" v-user-preview="post.user.id"><b>{{ name }}</b></router-link>
<a class="index" @click="reply">{{ note.index }}:</a>
<router-link class="name" :to="`/@${acct}`" v-user-preview="note.user.id"><b>{{ name }}</b></router-link>
<span>ID:<i>{{ acct }}</i></span>
</header>
<div>
<a v-if="post.reply">&gt;&gt;{{ post.reply.index }}</a>
{{ post.text }}
<div class="media" v-if="post.media">
<a v-for="file in post.media" :href="file.url" target="_blank">
<a v-if="note.reply">&gt;&gt;{{ note.reply.index }}</a>
{{ note.text }}
<div class="media" v-if="note.media">
<a v-for="file in note.media" :href="file.url" target="_blank">
<img :src="`${file.url}?thumbnail&size=512`" :alt="file.name" :title="file.name"/>
</a>
</div>
@@ -23,25 +23,25 @@ import getAcct from '../../../../../acct/render';
import getUserName from '../../../../../renderers/get-user-name';
export default Vue.extend({
props: ['post'],
props: ['note'],
computed: {
acct() {
return getAcct(this.post.user);
return getAcct(this.note.user);
},
name() {
return getUserName(this.post.user);
return getUserName(this.note.user);
}
},
methods: {
reply() {
this.$emit('reply', this.post);
this.$emit('reply', this.note);
}
}
});
</script>
<style lang="stylus" scoped>
.post
.note
margin 0
padding 0
color #444

View File

@@ -1,9 +1,9 @@
<template>
<div class="channel">
<p v-if="fetching">読み込み中<mk-ellipsis/></p>
<div v-if="!fetching" ref="posts" class="posts">
<p v-if="posts.length == 0">まだ投稿がありません</p>
<x-post class="post" v-for="post in posts.slice().reverse()" :post="post" :key="post.id" @reply="reply"/>
<div v-if="!fetching" ref="notes" class="notes">
<p v-if="notes.length == 0">まだ投稿がありません</p>
<x-note class="note" v-for="note in notes.slice().reverse()" :note="note" :key="note.id" @reply="reply"/>
</div>
<x-form class="form" ref="form"/>
</div>
@@ -13,18 +13,18 @@
import Vue from 'vue';
import ChannelStream from '../../../common/scripts/streaming/channel';
import XForm from './channel.channel.form.vue';
import XPost from './channel.channel.post.vue';
import XNote from './channel.channel.note.vue';
export default Vue.extend({
components: {
XForm,
XPost
XNote
},
props: ['channel'],
data() {
return {
fetching: true,
posts: [],
notes: [],
connection: null
};
},
@@ -43,10 +43,10 @@ export default Vue.extend({
zap() {
this.fetching = true;
(this as any).api('channels/posts', {
(this as any).api('channels/notes', {
channelId: this.channel.id
}).then(posts => {
this.posts = posts;
}).then(notes => {
this.notes = notes;
this.fetching = false;
this.$nextTick(() => {
@@ -55,24 +55,24 @@ export default Vue.extend({
this.disconnect();
this.connection = new ChannelStream((this as any).os, this.channel.id);
this.connection.on('post', this.onPost);
this.connection.on('note', this.onNote);
});
},
disconnect() {
if (this.connection) {
this.connection.off('post', this.onPost);
this.connection.off('note', this.onNote);
this.connection.close();
}
},
onPost(post) {
this.posts.unshift(post);
onNote(note) {
this.notes.unshift(note);
this.scrollToBottom();
},
scrollToBottom() {
(this.$refs.posts as any).scrollTop = (this.$refs.posts as any).scrollHeight;
(this.$refs.notes as any).scrollTop = (this.$refs.notes as any).scrollHeight;
},
reply(post) {
(this.$refs.form as any).text = `>>${ post.index } `;
reply(note) {
(this.$refs.form as any).text = `>>${ note.index } `;
}
}
});
@@ -87,12 +87,12 @@ export default Vue.extend({
text-align center
color #aaa
> .posts
> .notes
height calc(100% - 38px)
overflow auto
font-size 0.9em
> .post
> .note
border-bottom solid 1px #eee
&:last-child

View File

@@ -7,7 +7,7 @@
<div class="poll" v-if="!fetching && poll != null">
<p v-if="poll.text"><router-link to="`/@${ acct }/${ poll.id }`">{{ poll.text }}</router-link></p>
<p v-if="!poll.text"><router-link to="`/@${ acct }/${ poll.id }`">%fa:link%</router-link></p>
<mk-poll :post="poll"/>
<mk-poll :note="poll"/>
</div>
<p class="empty" v-if="!fetching && poll == null">%i18n:desktop.tags.mk-recommended-polls-home-widget.nothing%</p>
<p class="fetching" v-if="fetching">%fa:spinner .pulse .fw%%i18n:common.loading%<mk-ellipsis/></p>
@@ -47,11 +47,11 @@ export default define({
this.fetching = true;
this.poll = null;
(this as any).api('posts/polls/recommendation', {
(this as any).api('notes/polls/recommendation', {
limit: 1,
offset: this.offset
}).then(posts => {
const poll = posts ? posts[0] : null;
}).then(notes => {
const poll = notes ? notes[0] : null;
if (poll == null) {
this.offset = 0;
} else {

View File

@@ -4,7 +4,7 @@
<p class="title">%fa:pencil-alt%%i18n:desktop.tags.mk-post-form-home-widget.title%</p>
</template>
<textarea :disabled="posting" v-model="text" @keydown="onKeydown" placeholder="%i18n:desktop.tags.mk-post-form-home-widget.placeholder%"></textarea>
<button @click="post" :disabled="posting">%i18n:desktop.tags.mk-post-form-home-widget.post%</button>
<button @click="post" :disabled="posting">%i18n:desktop.tags.mk-post-form-home-widget.note%</button>
</div>
</template>
@@ -36,7 +36,7 @@ export default define({
post() {
this.posting = true;
(this as any).api('posts/create', {
(this as any).api('notes/create', {
text: this.text
}).then(data => {
this.clear();

View File

@@ -5,8 +5,8 @@
<button @click="fetch" title="%i18n:desktop.tags.mk-trends-home-widget.refresh%">%fa:sync%</button>
</template>
<p class="fetching" v-if="fetching">%fa:spinner .pulse .fw%%i18n:common.loading%<mk-ellipsis/></p>
<div class="post" v-else-if="post != null">
<p class="text"><router-link :to="`/@${ acct }/${ post.id }`">{{ post.text }}</router-link></p>
<div class="note" v-else-if="note != null">
<p class="text"><router-link :to="`/@${ acct }/${ note.id }`">{{ note.text }}</router-link></p>
<p class="author"><router-link :to="`/@${ acct }`">@{{ acct }}</router-link></p>
</div>
<p class="empty" v-else>%i18n:desktop.tags.mk-trends-home-widget.nothing%</p>
@@ -25,12 +25,12 @@ export default define({
}).extend({
computed: {
acct() {
return getAcct(this.post.user);
return getAcct(this.note.user);
},
},
data() {
return {
post: null,
note: null,
fetching: true,
offset: 0
};
@@ -44,23 +44,23 @@ export default define({
},
fetch() {
this.fetching = true;
this.post = null;
this.note = null;
(this as any).api('posts/trend', {
(this as any).api('notes/trend', {
limit: 1,
offset: this.offset,
repost: false,
renote: false,
reply: false,
media: false,
poll: false
}).then(posts => {
const post = posts ? posts[0] : null;
if (post == null) {
}).then(notes => {
const note = notes ? notes[0] : null;
if (note == null) {
this.offset = 0;
} else {
this.offset++;
}
this.post = post;
this.note = note;
this.fetching = false;
});
}
@@ -103,7 +103,7 @@ export default define({
&:active
color #999
> .post
> .note
padding 16px
font-size 12px
font-style oblique