mirror of
https://github.com/ragestudio/comty.js.git
synced 2025-06-09 10:34:19 +00:00
use pagination
This commit is contained in:
parent
e188676dda
commit
85e1619e29
@ -6,18 +6,18 @@ export default class FeedModel {
|
|||||||
* Retrieves music feed with optional trimming and limiting.
|
* Retrieves music feed with optional trimming and limiting.
|
||||||
*
|
*
|
||||||
* @param {Object} options - Optional parameters for trimming and limiting the feed
|
* @param {Object} options - Optional parameters for trimming and limiting the feed
|
||||||
* @param {number} options.trim - The number of items to trim from the feed
|
* @param {number} options.page - The number of items to page from the feed
|
||||||
* @param {number} options.limit - The maximum number of items to fetch from the feed
|
* @param {number} options.limit - The maximum number of items to fetch from the feed
|
||||||
* @return {Promise<Object>} The music feed data
|
* @return {Promise<Object>} The music feed data
|
||||||
*/
|
*/
|
||||||
static async getMusicFeed({ trim, limit } = {}) {
|
static async getMusicFeed({ page, limit } = {}) {
|
||||||
const { data } = await request({
|
const { data } = await request({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/music/feed/my`,
|
url: `/music/feed/my`,
|
||||||
params: {
|
params: {
|
||||||
trim: trim ?? 0,
|
page: page ?? 0,
|
||||||
limit: limit ?? Settings.get("feed_max_fetch"),
|
limit: limit ?? Settings.get("feed_max_fetch"),
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
@ -27,18 +27,18 @@ export default class FeedModel {
|
|||||||
* Retrieves the global music feed with optional trimming and limiting.
|
* Retrieves the global music feed with optional trimming and limiting.
|
||||||
*
|
*
|
||||||
* @param {Object} options - An object containing optional parameters:
|
* @param {Object} options - An object containing optional parameters:
|
||||||
* @param {number} options.trim - The number of items to trim from the feed
|
* @param {number} options.page - The number of items to page from the feed
|
||||||
* @param {number} options.limit - The maximum number of items to fetch from the feed
|
* @param {number} options.limit - The maximum number of items to fetch from the feed
|
||||||
* @return {Promise<Object>} The global music feed data
|
* @return {Promise<Object>} The global music feed data
|
||||||
*/
|
*/
|
||||||
static async getGlobalMusicFeed({ trim, limit } = {}) {
|
static async getGlobalMusicFeed({ page, limit } = {}) {
|
||||||
const { data } = await request({
|
const { data } = await request({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/music/feed`,
|
url: `/music/feed`,
|
||||||
params: {
|
params: {
|
||||||
trim: trim ?? 0,
|
page: page ?? 0,
|
||||||
limit: limit ?? Settings.get("feed_max_fetch"),
|
limit: limit ?? Settings.get("feed_max_fetch"),
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
@ -47,40 +47,40 @@ export default class FeedModel {
|
|||||||
/**
|
/**
|
||||||
* Retrieves the timeline feed with optional trimming and limiting.
|
* Retrieves the timeline feed with optional trimming and limiting.
|
||||||
*
|
*
|
||||||
* @param {object} options - Object containing trim and limit properties
|
* @param {object} options - Object containing page and limit properties
|
||||||
* @param {number} options.trim - The number of feed items to trim
|
* @param {number} options.page - The number of feed items to page
|
||||||
* @param {number} options.limit - The maximum number of feed items to retrieve
|
* @param {number} options.limit - The maximum number of feed items to retrieve
|
||||||
* @return {Promise<object>} The timeline feed data
|
* @return {Promise<object>} The timeline feed data
|
||||||
*/
|
*/
|
||||||
static async getTimelineFeed({ trim, limit } = {}) {
|
static async getTimelineFeed({ page, limit } = {}) {
|
||||||
const { data } = await request({
|
const { data } = await request({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/posts/feed/timeline`,
|
url: `/posts/feed/timeline`,
|
||||||
params: {
|
params: {
|
||||||
trim: trim ?? 0,
|
page: page ?? 0,
|
||||||
limit: limit ?? Settings.get("feed_max_fetch"),
|
limit: limit ?? Settings.get("feed_max_fetch"),
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the posts feed with options to trim and limit the results.
|
* Retrieves the posts feed with options to page and limit the results.
|
||||||
*
|
*
|
||||||
* @param {Object} options - An object containing optional parameters for trimming and limiting the feed.
|
* @param {Object} options - An object containing optional parameters for trimming and limiting the feed.
|
||||||
* @param {number} options.trim - The number of characters to trim the feed content.
|
* @param {number} options.page - The number of characters to page the feed content.
|
||||||
* @param {number} options.limit - The maximum number of posts to fetch from the feed.
|
* @param {number} options.limit - The maximum number of posts to fetch from the feed.
|
||||||
* @return {Promise<Object>} The posts feed data.
|
* @return {Promise<Object>} The posts feed data.
|
||||||
*/
|
*/
|
||||||
static async getGlobalTimelineFeed({ trim, limit } = {}) {
|
static async getGlobalTimelineFeed({ page, limit } = {}) {
|
||||||
const { data } = await request({
|
const { data } = await request({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/posts/feed/global`,
|
url: `/posts/feed/global`,
|
||||||
params: {
|
params: {
|
||||||
trim: trim ?? 0,
|
page: page ?? 0,
|
||||||
limit: limit ?? Settings.get("feed_max_fetch"),
|
limit: limit ?? Settings.get("feed_max_fetch"),
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
@ -62,12 +62,12 @@ export default class Post {
|
|||||||
*
|
*
|
||||||
* @param {Object} options - The options for retrieving the replies.
|
* @param {Object} options - The options for retrieving the replies.
|
||||||
* @param {string} options.post_id - The ID of the post to retrieve replies for.
|
* @param {string} options.post_id - The ID of the post to retrieve replies for.
|
||||||
* @param {number} [options.trim=0] - The number of characters to trim the reply content.
|
* @param {number} [options.page=0] - The number of characters to page the reply content.
|
||||||
* @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of replies to fetch.
|
* @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of replies to fetch.
|
||||||
* @throws {Error} If the post_id is not provided.
|
* @throws {Error} If the post_id is not provided.
|
||||||
* @return {Promise<Object>} The data of the replies.
|
* @return {Promise<Object>} The data of the replies.
|
||||||
*/
|
*/
|
||||||
static async replies({ post_id, trim, limit }) {
|
static async replies({ post_id, page, limit }) {
|
||||||
if (!post_id) {
|
if (!post_id) {
|
||||||
throw new Error("Post ID is required")
|
throw new Error("Post ID is required")
|
||||||
}
|
}
|
||||||
@ -76,9 +76,9 @@ export default class Post {
|
|||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/posts/${post_id}/replies`,
|
url: `/posts/${post_id}/replies`,
|
||||||
params: {
|
params: {
|
||||||
trim: trim ?? 0,
|
page: page ?? 0,
|
||||||
limit: limit ?? Settings.get("feed_max_fetch"),
|
limit: limit ?? Settings.get("feed_max_fetch"),
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
@ -88,18 +88,18 @@ export default class Post {
|
|||||||
* Retrieves the saved posts with optional trimming and limiting.
|
* Retrieves the saved posts with optional trimming and limiting.
|
||||||
*
|
*
|
||||||
* @param {Object} options - The options for retrieving the saved posts.
|
* @param {Object} options - The options for retrieving the saved posts.
|
||||||
* @param {number} [options.trim=0] - The number of posts to trim from the result.
|
* @param {number} [options.page=0] - The number of posts to page from the result.
|
||||||
* @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of posts to fetch.
|
* @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of posts to fetch.
|
||||||
* @return {Promise<Object>} The data of the saved posts.
|
* @return {Promise<Object>} The data of the saved posts.
|
||||||
*/
|
*/
|
||||||
static async getSavedPosts({ trim, limit }) {
|
static async getSavedPosts({ page, limit }) {
|
||||||
const { data } = await request({
|
const { data } = await request({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/posts/saved`,
|
url: `/posts/saved`,
|
||||||
params: {
|
params: {
|
||||||
trim: trim ?? 0,
|
page: page ?? 0,
|
||||||
limit: limit ?? Settings.get("feed_max_fetch"),
|
limit: limit ?? Settings.get("feed_max_fetch"),
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
@ -108,18 +108,18 @@ export default class Post {
|
|||||||
/**
|
/**
|
||||||
* Retrieves the liked posts with optional trimming and limiting.
|
* Retrieves the liked posts with optional trimming and limiting.
|
||||||
*
|
*
|
||||||
* @param {number} trim - The number of characters to trim the post content.
|
* @param {number} page - The number of characters to page the post content.
|
||||||
* @param {number} limit - The maximum number of liked posts to fetch.
|
* @param {number} limit - The maximum number of liked posts to fetch.
|
||||||
* @return {Promise<Object>} The data of the liked posts.
|
* @return {Promise<Object>} The data of the liked posts.
|
||||||
*/
|
*/
|
||||||
static async getLikedPosts({ trim, limit }) {
|
static async getLikedPosts({ page, limit }) {
|
||||||
const { data } = await request({
|
const { data } = await request({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/posts/liked`,
|
url: `/posts/liked`,
|
||||||
params: {
|
params: {
|
||||||
trim: trim ?? 0,
|
page: page ?? 0,
|
||||||
limit: limit ?? Settings.get("feed_max_fetch"),
|
limit: limit ?? Settings.get("feed_max_fetch"),
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
@ -130,11 +130,11 @@ export default class Post {
|
|||||||
*
|
*
|
||||||
* @param {Object} options - The options for retrieving the user's posts.
|
* @param {Object} options - The options for retrieving the user's posts.
|
||||||
* @param {string} options.user_id - The ID of the user whose posts to retrieve. If not provided, the current user's ID will be used.
|
* @param {string} options.user_id - The ID of the user whose posts to retrieve. If not provided, the current user's ID will be used.
|
||||||
* @param {number} [options.trim=0] - The number of characters to trim the post content.
|
* @param {number} [options.page=0] - The number of characters to page the post content.
|
||||||
* @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of posts to fetch.
|
* @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of posts to fetch.
|
||||||
* @return {Promise<Object>} The data of the user's posts.
|
* @return {Promise<Object>} The data of the user's posts.
|
||||||
*/
|
*/
|
||||||
static async getUserPosts({ user_id, trim, limit }) {
|
static async getUserPosts({ user_id, page, limit }) {
|
||||||
if (!user_id) {
|
if (!user_id) {
|
||||||
// use current user_id
|
// use current user_id
|
||||||
user_id = app.userData?._id
|
user_id = app.userData?._id
|
||||||
@ -144,9 +144,9 @@ export default class Post {
|
|||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/posts/user/${user_id}`,
|
url: `/posts/user/${user_id}`,
|
||||||
params: {
|
params: {
|
||||||
trim: trim ?? 0,
|
page: page ?? 0,
|
||||||
limit: limit ?? Settings.get("feed_max_fetch"),
|
limit: limit ?? Settings.get("feed_max_fetch"),
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
@ -326,18 +326,18 @@ export default class Post {
|
|||||||
*
|
*
|
||||||
* @param {Object} options - The options for retrieving trending posts.
|
* @param {Object} options - The options for retrieving trending posts.
|
||||||
* @param {string} options.trending - The hashtag to retrieve trending posts for.
|
* @param {string} options.trending - The hashtag to retrieve trending posts for.
|
||||||
* @param {number} [options.trim=0] - The number of characters to trim the post content.
|
* @param {number} [options.page=0] - The number of characters to page the post content.
|
||||||
* @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of posts to fetch.
|
* @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of posts to fetch.
|
||||||
* @return {Promise<Object[]>} An array of posts that are trending for the given hashtag.
|
* @return {Promise<Object[]>} An array of posts that are trending for the given hashtag.
|
||||||
*/
|
*/
|
||||||
static async getTrending({ trending, trim, limit } = {}) {
|
static async getTrending({ trending, page, limit } = {}) {
|
||||||
const { data } = await request({
|
const { data } = await request({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/posts/trending/${trending}`,
|
url: `/posts/trending/${trending}`,
|
||||||
params: {
|
params: {
|
||||||
trim: trim ?? 0,
|
page: page ?? 0,
|
||||||
limit: limit ?? Settings.get("feed_max_fetch"),
|
limit: limit ?? Settings.get("feed_max_fetch"),
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user