This commit is contained in:
syuilo 2018-10-19 09:20:11 +09:00
parent 0a4015b8a2
commit 8533663b26
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
2 changed files with 26 additions and 3 deletions

View file

@ -41,6 +41,7 @@ import parseAcct from '../../../../../../misc/acct/parse';
import XColumn from './deck.column.vue'; import XColumn from './deck.column.vue';
import XNotes from './deck.notes.vue'; import XNotes from './deck.notes.vue';
import XNote from '../../components/note.vue'; import XNote from '../../components/note.vue';
import { concat } from '../../../../../../prelude/array';
const fetchLimit = 10; const fetchLimit = 10;
@ -93,17 +94,24 @@ export default Vue.extend({
(this.$refs.timeline as any).init(() => this.initTl()); (this.$refs.timeline as any).init(() => this.initTl());
}); });
const image = [
'image/jpeg',
'image/png',
'image/gif'
];
(this as any).api('users/notes', { (this as any).api('users/notes', {
userId: this.user.id, userId: this.user.id,
withFiles: true, fileType: image,
limit: 9 limit: 9
}).then(notes => { }).then(notes => {
notes.forEach(note => { notes.forEach(note => {
note.files.forEach(file => { note.files.forEach(file => {
file._note = note; file._note = note;
if (this.images.length < 9) this.images.push(file);
}); });
}); });
const files = concat(notes.map((n: any): any[] => n.files));
this.images = files.filter(f => image.includes(f.type)).slice(0, 6);
}); });
}); });
}, },

View file

@ -99,6 +99,12 @@ export const meta = {
'ja-JP': 'true にすると、ファイルが添付された投稿だけ取得します (このパラメータは廃止予定です。代わりに withFiles を使ってください。)' 'ja-JP': 'true にすると、ファイルが添付された投稿だけ取得します (このパラメータは廃止予定です。代わりに withFiles を使ってください。)'
} }
}), }),
fileType: $.arr($.str).optional.note({
desc: {
'ja-JP': '指定された種類のファイルが添付された投稿のみを取得します'
}
}),
} }
}; };
@ -137,7 +143,8 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
const query = { const query = {
deletedAt: null, deletedAt: null,
userId: user._id userId: user._id,
visibility: { $in: ['public', 'home'] }
} as any; } as any;
if (ps.sinceId) { if (ps.sinceId) {
@ -172,6 +179,14 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
$ne: [] $ne: []
}; };
} }
if (ps.fileType) {
query.fileIds = { $exists: true, $ne: [] };
query['_files.contentType'] = {
$in: ps.fileType
};
}
//#endregion //#endregion
// Issue query // Issue query