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

@@ -49,7 +49,7 @@ export type API = {
post: (opts?: {
reply?: any;
repost?: any;
renote?: any;
}) => void;
notify: (message: string) => void;
@@ -312,7 +312,7 @@ export default class MiOS extends EventEmitter {
// Finish init
callback();
//#region Post
//#region Note
// Init service worker
if (this.shouldRegisterSw) this.registerSw();

View File

@@ -1,4 +1,4 @@
import getPostSummary from '../../../../renderers/get-post-summary';
import getNoteSummary from '../../../../renderers/get-note-summary';
import getReactionEmoji from '../../../../renderers/get-reaction-emoji';
import getUserName from '../../../../renderers/get-user-name';
@@ -23,28 +23,28 @@ export default function(type, data): Notification {
case 'mention':
return {
title: `${getUserName(data.user)}さんから:`,
body: getPostSummary(data),
body: getNoteSummary(data),
icon: data.user.avatarUrl + '?thumbnail&size=64'
};
case 'reply':
return {
title: `${getUserName(data.user)}さんから返信:`,
body: getPostSummary(data),
body: getNoteSummary(data),
icon: data.user.avatarUrl + '?thumbnail&size=64'
};
case 'quote':
return {
title: `${getUserName(data.user)}さんが引用:`,
body: getPostSummary(data),
body: getNoteSummary(data),
icon: data.user.avatarUrl + '?thumbnail&size=64'
};
case 'reaction':
return {
title: `${getUserName(data.user)}: ${getReactionEmoji(data.reaction)}:`,
body: getPostSummary(data.post),
body: getNoteSummary(data.note),
icon: data.user.avatarUrl + '?thumbnail&size=64'
};

View File

@@ -19,8 +19,8 @@ export default function(qs: string) {
case 'reply':
q['reply'] = value == 'null' ? null : value == 'true';
break;
case 'repost':
q['repost'] = value == 'null' ? null : value == 'true';
case 'renote':
q['renote'] = value == 'null' ? null : value == 'true';
break;
case 'media':
q['media'] = value == 'null' ? null : value == 'true';

View File

@@ -4,7 +4,7 @@ import signin from './signin.vue';
import signup from './signup.vue';
import forkit from './forkit.vue';
import nav from './nav.vue';
import postHtml from './post-html';
import noteHtml from './note-html';
import poll from './poll.vue';
import pollEditor from './poll-editor.vue';
import reactionIcon from './reaction-icon.vue';
@@ -29,7 +29,7 @@ Vue.component('mk-signin', signin);
Vue.component('mk-signup', signup);
Vue.component('mk-forkit', forkit);
Vue.component('mk-nav', nav);
Vue.component('mk-post-html', postHtml);
Vue.component('mk-note-html', noteHtml);
Vue.component('mk-poll', poll);
Vue.component('mk-poll-editor', pollEditor);
Vue.component('mk-reaction-icon', reactionIcon);

View File

@@ -10,7 +10,7 @@
<img src="/assets/desktop/messaging/delete.png" alt="Delete"/>
</button>
<div class="content" v-if="!message.isDeleted">
<mk-post-html class="text" v-if="message.text" ref="text" :text="message.text" :i="os.i"/>
<mk-note-html class="text" v-if="message.text" ref="text" :text="message.text" :i="os.i"/>
<div class="file" v-if="message.file">
<a :href="message.file.url" target="_blank" :title="message.file.name">
<img v-if="message.file.type.split('/')[0] == 'image'" :src="message.file.url" :alt="message.file.name"/>

View File

@@ -9,7 +9,7 @@ const flatten = list => list.reduce(
(a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []
);
export default Vue.component('mk-post-html', {
export default Vue.component('mk-note-html', {
props: {
text: {
type: String,

View File

@@ -1,8 +1,8 @@
<template>
<div class="mk-post-menu">
<div class="mk-note-menu">
<div class="backdrop" ref="backdrop" @click="close"></div>
<div class="popover" :class="{ compact }" ref="popover">
<button v-if="post.userId == os.i.id" @click="pin">%i18n:common.tags.mk-post-menu.pin%</button>
<button v-if="note.userId == os.i.id" @click="pin">%i18n:common.tags.mk-note-menu.pin%</button>
</div>
</div>
</template>
@@ -12,7 +12,7 @@ import Vue from 'vue';
import * as anime from 'animejs';
export default Vue.extend({
props: ['post', 'source', 'compact'],
props: ['note', 'source', 'compact'],
mounted() {
this.$nextTick(() => {
const popover = this.$refs.popover as any;
@@ -51,7 +51,7 @@ export default Vue.extend({
methods: {
pin() {
(this as any).api('i/pin', {
postId: this.post.id
noteId: this.note.id
}).then(() => {
this.$destroy();
});
@@ -83,7 +83,7 @@ export default Vue.extend({
<style lang="stylus" scoped>
$border-color = rgba(27, 31, 35, 0.15)
.mk-post-menu
.mk-note-menu
position initial
> .backdrop

View File

@@ -22,7 +22,7 @@
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: ['post'],
props: ['note'],
data() {
return {
showResult: false
@@ -30,7 +30,7 @@ export default Vue.extend({
},
computed: {
poll(): any {
return this.post.poll;
return this.note.poll;
},
total(): number {
return this.poll.choices.reduce((a, b) => a + b.votes, 0);
@@ -48,8 +48,8 @@ export default Vue.extend({
},
vote(id) {
if (this.poll.choices.some(c => c.isVoted)) return;
(this as any).api('posts/polls/vote', {
postId: this.post.id,
(this as any).api('notes/polls/vote', {
noteId: this.note.id,
choice: id
}).then(() => {
this.poll.choices.forEach(c => {

View File

@@ -25,7 +25,7 @@ import * as anime from 'animejs';
const placeholder = '%i18n:common.tags.mk-reaction-picker.choose-reaction%';
export default Vue.extend({
props: ['post', 'source', 'compact', 'cb'],
props: ['note', 'source', 'compact', 'cb'],
data() {
return {
title: placeholder
@@ -68,8 +68,8 @@ export default Vue.extend({
},
methods: {
react(reaction) {
(this as any).api('posts/reactions/create', {
postId: this.post.id,
(this as any).api('notes/reactions/create', {
noteId: this.note.id,
reaction: reaction
}).then(() => {
if (this.cb) this.cb();

View File

@@ -17,10 +17,10 @@
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: ['post'],
props: ['note'],
computed: {
reactions(): number {
return this.post.reactionCounts;
return this.note.reactionCounts;
}
}
});

View File

@@ -1,21 +1,21 @@
<template>
<div class="mk-welcome-timeline">
<div v-for="post in posts">
<router-link class="avatar-anchor" :to="`/@${getAcct(post.user)}`" v-user-preview="post.user.id">
<img class="avatar" :src="`${post.user.avatarUrl}?thumbnail&size=96`" alt="avatar"/>
<div v-for="note in notes">
<router-link class="avatar-anchor" :to="`/@${getAcct(note.user)}`" v-user-preview="note.user.id">
<img class="avatar" :src="`${note.user.avatarUrl}?thumbnail&size=96`" alt="avatar"/>
</router-link>
<div class="body">
<header>
<router-link class="name" :to="`/@${getAcct(post.user)}`" v-user-preview="post.user.id">{{ getUserName(post.user) }}</router-link>
<span class="username">@{{ getAcct(post.user) }}</span>
<router-link class="name" :to="`/@${getAcct(note.user)}`" v-user-preview="note.user.id">{{ getUserName(note.user) }}</router-link>
<span class="username">@{{ getAcct(note.user) }}</span>
<div class="info">
<router-link class="created-at" :to="`/@${getAcct(post.user)}/${post.id}`">
<mk-time :time="post.createdAt"/>
<router-link class="created-at" :to="`/@${getAcct(note.user)}/${note.id}`">
<mk-time :time="note.createdAt"/>
</router-link>
</div>
</header>
<div class="text">
<mk-post-html :text="post.text"/>
<mk-note-html :text="note.text"/>
</div>
</div>
</div>
@@ -31,7 +31,7 @@ export default Vue.extend({
data() {
return {
fetching: true,
posts: []
notes: []
};
},
mounted() {
@@ -42,14 +42,14 @@ export default Vue.extend({
getUserName,
fetch(cb?) {
this.fetching = true;
(this as any).api('posts', {
(this as any).api('notes', {
reply: false,
repost: false,
renote: false,
media: false,
poll: false,
bot: false
}).then(posts => {
this.posts = posts;
}).then(notes => {
this.notes = notes;
this.fetching = false;
});
}