mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
added music feed
This commit is contained in:
parent
8a079444b7
commit
d202a955bc
@ -1,5 +1,31 @@
|
||||
export default class FeedModel {
|
||||
static async getTimelineFeed({ trim, limit }) {
|
||||
static async getMusicFeed({ trim, limit } = {}) {
|
||||
const { data } = await app.cores.api.customRequest({
|
||||
method: "GET",
|
||||
url: `/feed/music`,
|
||||
params: {
|
||||
trim: trim ?? 0,
|
||||
limit: limit ?? window.app.cores.settings.get("feed_max_fetch"),
|
||||
}
|
||||
})
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
static async getGlobalMusicFeed({ trim, limit } = {}) {
|
||||
const { data } = await app.cores.api.customRequest({
|
||||
method: "GET",
|
||||
url: `/feed/music/global`,
|
||||
params: {
|
||||
trim: trim ?? 0,
|
||||
limit: limit ?? window.app.cores.settings.get("feed_max_fetch"),
|
||||
}
|
||||
})
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
static async getTimelineFeed({ trim, limit } = {}) {
|
||||
const { data } = await app.cores.api.customRequest({
|
||||
method: "GET",
|
||||
url: `/feed/timeline`,
|
||||
@ -12,7 +38,7 @@ export default class FeedModel {
|
||||
return data
|
||||
}
|
||||
|
||||
static async getPostsFeed({ trim, limit }) {
|
||||
static async getPostsFeed({ trim, limit } = {}) {
|
||||
const { data } = await app.cores.api.customRequest({
|
||||
method: "GET",
|
||||
url: `/feed/posts`,
|
||||
@ -25,7 +51,7 @@ export default class FeedModel {
|
||||
return data
|
||||
}
|
||||
|
||||
static async getPlaylistsFeed({ trim, limit }) {
|
||||
static async getPlaylistsFeed({ trim, limit } = {}) {
|
||||
const { data } = await app.cores.api.customRequest({
|
||||
method: "GET",
|
||||
url: `/feed/playlists`,
|
||||
|
@ -1,13 +1,5 @@
|
||||
export default class PlaylistsModel {
|
||||
static get bridge() {
|
||||
return window.app?.cores.api.withEndpoints()
|
||||
}
|
||||
|
||||
static async uploadTrack(file, payload) {
|
||||
if (!PlaylistsModel.bridge) {
|
||||
throw new Error("Bridge is not available")
|
||||
}
|
||||
|
||||
// get the file from the payload
|
||||
if (!file) {
|
||||
throw new Error("File is required")
|
||||
@ -22,7 +14,7 @@ export default class PlaylistsModel {
|
||||
formData.append("files", file)
|
||||
|
||||
// send the request
|
||||
const uploadRequest = await app.cores.api.customRequest( {
|
||||
const uploadRequest = await app.cores.api.customRequest({
|
||||
method: "POST",
|
||||
url: "/upload",
|
||||
data: formData,
|
||||
@ -38,7 +30,7 @@ export default class PlaylistsModel {
|
||||
const source = uploadRequest.data.files[0].url
|
||||
|
||||
// send the request for the track to be created
|
||||
const trackRequest = await app.cores.api.customRequest( {
|
||||
const trackRequest = await app.cores.api.customRequest({
|
||||
method: "POST",
|
||||
url: "/tracks/publish",
|
||||
data: {
|
||||
@ -51,7 +43,7 @@ export default class PlaylistsModel {
|
||||
}
|
||||
|
||||
static async publishTrack(payload) {
|
||||
const { data } = await app.cores.api.customRequest( {
|
||||
const { data } = await app.cores.api.customRequest({
|
||||
method: "POST",
|
||||
url: "/tracks/publish",
|
||||
data: payload,
|
||||
@ -61,7 +53,7 @@ export default class PlaylistsModel {
|
||||
}
|
||||
|
||||
static async publish(payload) {
|
||||
const { data } = await app.cores.api.customRequest( {
|
||||
const { data } = await app.cores.api.customRequest({
|
||||
method: "POST",
|
||||
url: `/playlist/publish`,
|
||||
data: payload,
|
||||
@ -71,7 +63,7 @@ export default class PlaylistsModel {
|
||||
}
|
||||
|
||||
static async getPlaylist(id) {
|
||||
const { data } = await app.cores.api.customRequest( {
|
||||
const { data } = await app.cores.api.customRequest({
|
||||
method: "GET",
|
||||
url: `/playlist/data/${id}`,
|
||||
})
|
||||
@ -80,7 +72,7 @@ export default class PlaylistsModel {
|
||||
}
|
||||
|
||||
static async getMyReleases() {
|
||||
const { data } = await app.cores.api.customRequest( {
|
||||
const { data } = await app.cores.api.customRequest({
|
||||
method: "GET",
|
||||
url: `/playlist/self`,
|
||||
})
|
||||
@ -93,7 +85,7 @@ export default class PlaylistsModel {
|
||||
throw new Error("Payload is required")
|
||||
}
|
||||
|
||||
const { data } = await app.cores.api.customRequest( {
|
||||
const { data } = await app.cores.api.customRequest({
|
||||
method: "PUT",
|
||||
url: `/tracks/${payload._id}`,
|
||||
data: {
|
||||
@ -109,7 +101,7 @@ export default class PlaylistsModel {
|
||||
throw new Error("Payload is required")
|
||||
}
|
||||
|
||||
const { data } = await app.cores.api.customRequest( {
|
||||
const { data } = await app.cores.api.customRequest({
|
||||
method: "PUT",
|
||||
url: `/playlist/${payload._id}`,
|
||||
data: {
|
||||
@ -125,7 +117,7 @@ export default class PlaylistsModel {
|
||||
throw new Error("ID is required")
|
||||
}
|
||||
|
||||
const { data } = await app.cores.api.customRequest( {
|
||||
const { data } = await app.cores.api.customRequest({
|
||||
method: "DELETE",
|
||||
url: `/playlist/${id}`,
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user