update
This commit is contained in:
1 parent
a4b4e07687
commit
e7a4eab102
11 files changed
+99
-32
No files matched your search
@@ -45,7 +45,8 @@ function album() {
|
||||
const processAlbum = async album => {
|
||||
album.url = `/album/${album.id}`;
|
||||
|
||||
const previewImageId = album.images.length ? album.images[0] : null;
|
||||
const previewFromImage = imgs => imgs.length ? imgs[0] : null;
|
||||
const previewImageId = album.preview ? album.preview : previewFromImage(album.images);
|
||||
if (previewImageId) {
|
||||
const image = await c('images').findOne({_id: previewImageId});
|
||||
album.preview = image.data.medium;
|
||||
|
||||
+8
-11
@@ -26,11 +26,8 @@ function news() {
|
||||
const limit = parseInt(ctx.query['limit']) || 20;
|
||||
const skip = parseInt(ctx.query['skip']) || 0;
|
||||
|
||||
const query = {};
|
||||
if (ctx.query.type) query.type = ctx.query.type;
|
||||
|
||||
const now = new Date();
|
||||
const pinned = skip != 0 ? [] : await c('timeline')
|
||||
const pinned = skip !== 0 ? [] : await c('timeline')
|
||||
.find({until: {$gte: now}})
|
||||
.toArray();
|
||||
|
||||
@@ -38,18 +35,18 @@ function news() {
|
||||
const pinnedIds = pinned.map(id);
|
||||
|
||||
let posts = await c('timeline')
|
||||
.find(query)
|
||||
.find({
|
||||
_id: {$nin: pinnedIds}
|
||||
})
|
||||
.sort({date: -1})
|
||||
.skip(skip)
|
||||
.limit(limit)
|
||||
.toArray();
|
||||
|
||||
ctx.body = [
|
||||
...pinned.sort(sortNewsByDate),
|
||||
...posts.filter(
|
||||
i => !pinnedIds.includes(id(i))
|
||||
)
|
||||
];
|
||||
ctx.body = [
|
||||
...pinned.sort(sortNewsByDate),
|
||||
...posts
|
||||
];
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user