mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-11 03:24:16 +00:00
56 lines
1.4 KiB
JavaScript
Executable File
56 lines
1.4 KiB
JavaScript
Executable File
export default class FeedModel {
|
|
static get bridge() {
|
|
return window.app?.cores.api.withEndpoints()
|
|
}
|
|
|
|
static async getPostsFeed({ trim, limit }) {
|
|
if (!FeedModel.bridge) {
|
|
throw new Error("Bridge is not available")
|
|
}
|
|
|
|
const { data } = await app.cores.api.customRequest( {
|
|
method: "GET",
|
|
url: `/feed/posts`,
|
|
params: {
|
|
trim: trim ?? 0,
|
|
limit: limit ?? window.app.cores.settings.get("feed_max_fetch"),
|
|
}
|
|
})
|
|
|
|
return data
|
|
}
|
|
|
|
static async getPlaylistsFeed({ trim, limit }) {
|
|
if (!FeedModel.bridge) {
|
|
throw new Error("Bridge is not available")
|
|
}
|
|
|
|
const { data } = await app.cores.api.customRequest( {
|
|
method: "GET",
|
|
url: `/feed/playlists`,
|
|
params: {
|
|
trim: trim ?? 0,
|
|
limit: limit ?? window.app.cores.settings.get("feed_max_fetch"),
|
|
}
|
|
})
|
|
|
|
return data
|
|
}
|
|
|
|
static async search(keywords, params = {}) {
|
|
if (!FeedModel.bridge) {
|
|
throw new Error("Bridge is not available")
|
|
}
|
|
|
|
const { data } = await app.cores.api.customRequest( {
|
|
method: "GET",
|
|
url: `/search`,
|
|
params: {
|
|
keywords: keywords,
|
|
params: params
|
|
}
|
|
})
|
|
|
|
return data
|
|
}
|
|
} |