szurubooru/client/js/models/post_list.js

37 lines
1 KiB
JavaScript
Raw Normal View History

'use strict';
const api = require('../api.js');
const uri = require('../util/uri.js');
const AbstractList = require('./abstract_list.js');
const Post = require('./post.js');
class PostList extends AbstractList {
static getAround(id, searchQuery) {
return api.get(
uri.formatApiLink(
'post', id, 'around', {query: searchQuery, fields: 'id'}));
}
2017-02-09 00:48:06 +01:00
static search(text, offset, limit, fields) {
return api.get(
uri.formatApiLink(
'posts', {
query: text,
2017-02-09 00:48:06 +01:00
offset: offset,
limit: limit,
fields: fields.join(','),
}))
.then(response => {
return Promise.resolve(Object.assign(
{},
response,
{results: PostList.fromResponse(response.results)}));
});
}
}
PostList._itemClass = Post;
PostList._itemName = 'post';
module.exports = PostList;