Feature to show only my posts in the user page (#3753)

* Fix #3681

* Feature to show only my posts in the user page
This commit is contained in:
MeiMei 2018-12-26 23:11:51 +09:00 committed by syuilo
parent 9b746f3eb5
commit 5174e16f7b
3 changed files with 21 additions and 0 deletions

View file

@ -1374,6 +1374,7 @@ desktop/views/pages/user/user.timeline.vue:
default: "投稿" default: "投稿"
with-replies: "投稿と返信" with-replies: "投稿と返信"
with-media: "メディア" with-media: "メディア"
my-posts: "私の投稿"
empty: "このユーザーはまだ何も投稿していないようです。" empty: "このユーザーはまだ何も投稿していないようです。"
desktop/views/widgets/messaging.vue: desktop/views/widgets/messaging.vue:

View file

@ -4,6 +4,7 @@
<span :data-active="mode == 'default'" @click="mode = 'default'"><fa :icon="['far', 'comment-alt']"/> {{ $t('default') }}</span> <span :data-active="mode == 'default'" @click="mode = 'default'"><fa :icon="['far', 'comment-alt']"/> {{ $t('default') }}</span>
<span :data-active="mode == 'with-replies'" @click="mode = 'with-replies'"><fa icon="comments"/> {{ $t('with-replies') }}</span> <span :data-active="mode == 'with-replies'" @click="mode = 'with-replies'"><fa icon="comments"/> {{ $t('with-replies') }}</span>
<span :data-active="mode == 'with-media'" @click="mode = 'with-media'"><fa :icon="['far', 'images']"/> {{ $t('with-media') }}</span> <span :data-active="mode == 'with-media'" @click="mode = 'with-media'"><fa :icon="['far', 'images']"/> {{ $t('with-media') }}</span>
<span :data-active="mode == 'my-posts'" @click="mode = 'my-posts'"><fa icon="user"/> {{ $t('my-posts') }}</span>
</header> </header>
<mk-notes ref="timeline" :more="existMore ? more : null"> <mk-notes ref="timeline" :more="existMore ? more : null">
<p class="empty" slot="empty"><fa :icon="['far', 'comments']"/>{{ $t('empty') }}</p> <p class="empty" slot="empty"><fa :icon="['far', 'comments']"/>{{ $t('empty') }}</p>
@ -65,6 +66,7 @@ export default Vue.extend({
limit: fetchLimit + 1, limit: fetchLimit + 1,
untilDate: this.date ? this.date.getTime() : new Date().getTime() + 1000 * 86400 * 365, untilDate: this.date ? this.date.getTime() : new Date().getTime() + 1000 * 86400 * 365,
includeReplies: this.mode == 'with-replies', includeReplies: this.mode == 'with-replies',
includeMyRenotes: this.mode != 'my-posts',
withFiles: this.mode == 'with-media' withFiles: this.mode == 'with-media'
}).then(notes => { }).then(notes => {
if (notes.length == fetchLimit + 1) { if (notes.length == fetchLimit + 1) {
@ -85,6 +87,7 @@ export default Vue.extend({
userId: this.user.id, userId: this.user.id,
limit: fetchLimit + 1, limit: fetchLimit + 1,
includeReplies: this.mode == 'with-replies', includeReplies: this.mode == 'with-replies',
includeMyRenotes: this.mode != 'my-posts',
withFiles: this.mode == 'with-media', withFiles: this.mode == 'with-media',
untilDate: new Date((this.$refs.timeline as any).tail().createdAt).getTime() untilDate: new Date((this.$refs.timeline as any).tail().createdAt).getTime()
}); });

View file

@ -156,6 +156,7 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
const sort = { } as any; const sort = { } as any;
const query = { const query = {
$and: [ {} ],
deletedAt: null, deletedAt: null,
userId: user._id userId: user._id
} as any; } as any;
@ -188,6 +189,22 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
query.replyId = null; query.replyId = null;
} }
if (ps.includeMyRenotes === false) {
query.$and.push({
$or: [{
userId: { $ne: user._id }
}, {
renoteId: null
}, {
text: { $ne: null }
}, {
fileIds: { $ne: [] }
}, {
poll: { $ne: null }
}]
});
}
const withFiles = ps.withFiles != null ? ps.withFiles : ps.mediaOnly; const withFiles = ps.withFiles != null ? ps.withFiles : ps.mediaOnly;
if (withFiles) { if (withFiles) {