@@ -7,7 +7,7 @@
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import Progress from '../../../common/scripts/loading';
|
||||
import getPostSummary from '../../../../../renderers/get-post-summary';
|
||||
import getNoteSummary from '../../../../../renderers/get-note-summary';
|
||||
|
||||
export default Vue.extend({
|
||||
props: {
|
||||
@@ -29,13 +29,13 @@ export default Vue.extend({
|
||||
this.connection = (this as any).os.stream.getConnection();
|
||||
this.connectionId = (this as any).os.stream.use();
|
||||
|
||||
this.connection.on('post', this.onStreamPost);
|
||||
this.connection.on('note', this.onStreamNote);
|
||||
document.addEventListener('visibilitychange', this.onVisibilitychange, false);
|
||||
|
||||
Progress.start();
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.connection.off('post', this.onStreamPost);
|
||||
this.connection.off('note', this.onStreamNote);
|
||||
(this as any).os.stream.dispose(this.connectionId);
|
||||
document.removeEventListener('visibilitychange', this.onVisibilitychange);
|
||||
},
|
||||
@@ -44,10 +44,10 @@ export default Vue.extend({
|
||||
Progress.done();
|
||||
},
|
||||
|
||||
onStreamPost(post) {
|
||||
if (document.hidden && post.userId != (this as any).os.i.id) {
|
||||
onStreamNote(note) {
|
||||
if (document.hidden && note.userId != (this as any).os.i.id) {
|
||||
this.unreadCount++;
|
||||
document.title = `(${this.unreadCount}) ${getPostSummary(post)}`;
|
||||
document.title = `(${this.unreadCount}) ${getNoteSummary(note)}`;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<mk-ui>
|
||||
<main v-if="!fetching">
|
||||
<a v-if="post.next" :href="post.next">%fa:angle-up%%i18n:desktop.tags.mk-post-page.next%</a>
|
||||
<mk-post-detail :post="post"/>
|
||||
<a v-if="post.prev" :href="post.prev">%fa:angle-down%%i18n:desktop.tags.mk-post-page.prev%</a>
|
||||
<a v-if="note.next" :href="note.next">%fa:angle-up%%i18n:desktop.tags.mk-note-page.next%</a>
|
||||
<mk-note-detail :note="note"/>
|
||||
<a v-if="note.prev" :href="note.prev">%fa:angle-down%%i18n:desktop.tags.mk-note-page.prev%</a>
|
||||
</main>
|
||||
</mk-ui>
|
||||
</template>
|
||||
@@ -16,7 +16,7 @@ export default Vue.extend({
|
||||
data() {
|
||||
return {
|
||||
fetching: true,
|
||||
post: null
|
||||
note: null
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
@@ -30,10 +30,10 @@ export default Vue.extend({
|
||||
Progress.start();
|
||||
this.fetching = true;
|
||||
|
||||
(this as any).api('posts/show', {
|
||||
postId: this.$route.params.post
|
||||
}).then(post => {
|
||||
this.post = post;
|
||||
(this as any).api('notes/show', {
|
||||
noteId: this.$route.params.note
|
||||
}).then(note => {
|
||||
this.note = note;
|
||||
this.fetching = false;
|
||||
|
||||
Progress.done();
|
||||
@@ -60,7 +60,7 @@ main
|
||||
> [data-fa]
|
||||
margin-right 4px
|
||||
|
||||
> .mk-post-detail
|
||||
> .mk-note-detail
|
||||
margin 0 auto
|
||||
width 640px
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
<mk-ellipsis-icon/>
|
||||
</div>
|
||||
<p :class="$style.empty" v-if="!fetching && empty">%fa:search%「{{ q }}」に関する投稿は見つかりませんでした。</p>
|
||||
<mk-posts ref="timeline" :class="$style.posts" :posts="posts">
|
||||
<mk-notes ref="timeline" :class="$style.notes" :notes="notes">
|
||||
<div slot="footer">
|
||||
<template v-if="!moreFetching">%fa:search%</template>
|
||||
<template v-if="moreFetching">%fa:spinner .pulse .fw%</template>
|
||||
</div>
|
||||
</mk-posts>
|
||||
</mk-notes>
|
||||
</mk-ui>
|
||||
</template>
|
||||
|
||||
@@ -30,7 +30,7 @@ export default Vue.extend({
|
||||
moreFetching: false,
|
||||
existMore: false,
|
||||
offset: 0,
|
||||
posts: []
|
||||
notes: []
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
@@ -38,7 +38,7 @@ export default Vue.extend({
|
||||
},
|
||||
computed: {
|
||||
empty(): boolean {
|
||||
return this.posts.length == 0;
|
||||
return this.notes.length == 0;
|
||||
},
|
||||
q(): string {
|
||||
return this.$route.query.q;
|
||||
@@ -66,33 +66,33 @@ export default Vue.extend({
|
||||
this.fetching = true;
|
||||
Progress.start();
|
||||
|
||||
(this as any).api('posts/search', Object.assign({
|
||||
(this as any).api('notes/search', Object.assign({
|
||||
limit: limit + 1,
|
||||
offset: this.offset
|
||||
}, parse(this.q))).then(posts => {
|
||||
if (posts.length == limit + 1) {
|
||||
posts.pop();
|
||||
}, parse(this.q))).then(notes => {
|
||||
if (notes.length == limit + 1) {
|
||||
notes.pop();
|
||||
this.existMore = true;
|
||||
}
|
||||
this.posts = posts;
|
||||
this.notes = notes;
|
||||
this.fetching = false;
|
||||
Progress.done();
|
||||
});
|
||||
},
|
||||
more() {
|
||||
if (this.moreFetching || this.fetching || this.posts.length == 0 || !this.existMore) return;
|
||||
if (this.moreFetching || this.fetching || this.notes.length == 0 || !this.existMore) return;
|
||||
this.offset += limit;
|
||||
this.moreFetching = true;
|
||||
return (this as any).api('posts/search', Object.assign({
|
||||
return (this as any).api('notes/search', Object.assign({
|
||||
limit: limit + 1,
|
||||
offset: this.offset
|
||||
}, parse(this.q))).then(posts => {
|
||||
if (posts.length == limit + 1) {
|
||||
posts.pop();
|
||||
}, parse(this.q))).then(notes => {
|
||||
if (notes.length == limit + 1) {
|
||||
notes.pop();
|
||||
} else {
|
||||
this.existMore = false;
|
||||
}
|
||||
this.posts = this.posts.concat(posts);
|
||||
this.notes = this.notes.concat(notes);
|
||||
this.moreFetching = false;
|
||||
});
|
||||
},
|
||||
@@ -111,7 +111,7 @@ export default Vue.extend({
|
||||
margin 0 auto
|
||||
color #555
|
||||
|
||||
.posts
|
||||
.notes
|
||||
max-width 600px
|
||||
margin 0 auto
|
||||
border solid 1px rgba(0, 0, 0, 0.075)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<main>
|
||||
<mk-post-detail v-if="user.pinnedPost" :post="user.pinnedPost" :compact="true"/>
|
||||
<mk-note-detail v-if="user.pinnedNote" :note="user.pinnedNote" :compact="true"/>
|
||||
<x-timeline class="timeline" ref="tl" :user="user"/>
|
||||
</main>
|
||||
<div>
|
||||
|
||||
@@ -22,13 +22,13 @@ export default Vue.extend({
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
(this as any).api('users/posts', {
|
||||
(this as any).api('users/notes', {
|
||||
userId: this.user.id,
|
||||
withMedia: true,
|
||||
limit: 9
|
||||
}).then(posts => {
|
||||
posts.forEach(post => {
|
||||
post.media.forEach(media => {
|
||||
}).then(notes => {
|
||||
notes.forEach(note => {
|
||||
note.media.forEach(media => {
|
||||
if (this.images.length < 9) this.images.push(media);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<p>%fa:B twitter%<a :href="`https://twitter.com/${user.account.twitter.screenName}`" target="_blank">@{{ user.account.twitter.screenName }}</a></p>
|
||||
</div>
|
||||
<div class="status">
|
||||
<p class="posts-count">%fa:angle-right%<a>{{ user.postsCount }}</a><b>投稿</b></p>
|
||||
<p class="notes-count">%fa:angle-right%<a>{{ user.notesCount }}</a><b>投稿</b></p>
|
||||
<p class="following">%fa:angle-right%<a @click="showFollowing">{{ user.followingCount }}</a>人を<b>フォロー</b></p>
|
||||
<p class="followers">%fa:angle-right%<a @click="showFollowers">{{ user.followersCount }}</a>人の<b>フォロワー</b></p>
|
||||
</div>
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
<mk-ellipsis-icon/>
|
||||
</div>
|
||||
<p class="empty" v-if="empty">%fa:R comments%このユーザーはまだ何も投稿していないようです。</p>
|
||||
<mk-posts ref="timeline" :posts="posts">
|
||||
<mk-notes ref="timeline" :notes="notes">
|
||||
<div slot="footer">
|
||||
<template v-if="!moreFetching">%fa:moon%</template>
|
||||
<template v-if="moreFetching">%fa:spinner .pulse .fw%</template>
|
||||
</div>
|
||||
</mk-posts>
|
||||
</mk-notes>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -27,7 +27,7 @@ export default Vue.extend({
|
||||
moreFetching: false,
|
||||
mode: 'default',
|
||||
unreadCount: 0,
|
||||
posts: [],
|
||||
notes: [],
|
||||
date: null
|
||||
};
|
||||
},
|
||||
@@ -38,7 +38,7 @@ export default Vue.extend({
|
||||
},
|
||||
computed: {
|
||||
empty(): boolean {
|
||||
return this.posts.length == 0;
|
||||
return this.notes.length == 0;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@@ -60,26 +60,26 @@ export default Vue.extend({
|
||||
}
|
||||
},
|
||||
fetch(cb?) {
|
||||
(this as any).api('users/posts', {
|
||||
(this as any).api('users/notes', {
|
||||
userId: this.user.id,
|
||||
untilDate: this.date ? this.date.getTime() : undefined,
|
||||
with_replies: this.mode == 'with-replies'
|
||||
}).then(posts => {
|
||||
this.posts = posts;
|
||||
}).then(notes => {
|
||||
this.notes = notes;
|
||||
this.fetching = false;
|
||||
if (cb) cb();
|
||||
});
|
||||
},
|
||||
more() {
|
||||
if (this.moreFetching || this.fetching || this.posts.length == 0) return;
|
||||
if (this.moreFetching || this.fetching || this.notes.length == 0) return;
|
||||
this.moreFetching = true;
|
||||
(this as any).api('users/posts', {
|
||||
(this as any).api('users/notes', {
|
||||
userId: this.user.id,
|
||||
with_replies: this.mode == 'with-replies',
|
||||
untilId: this.posts[this.posts.length - 1].id
|
||||
}).then(posts => {
|
||||
untilId: this.notes[this.notes.length - 1].id
|
||||
}).then(notes => {
|
||||
this.moreFetching = false;
|
||||
this.posts = this.posts.concat(posts);
|
||||
this.notes = this.notes.concat(notes);
|
||||
});
|
||||
},
|
||||
onScroll() {
|
||||
|
||||
Reference in New Issue
Block a user