Added playlist
This commit is contained in:
parent
9345dd1fd0
commit
829e9c599b
10
dataTypes.ts
10
dataTypes.ts
@ -26,3 +26,13 @@ export class Playlist {
|
||||
constructor(public title: string, public listener: string, public songs: Song[]) {
|
||||
}
|
||||
}
|
||||
export class PlaylistDescription {
|
||||
public title: string;
|
||||
|
||||
public listener: string;
|
||||
|
||||
constructor(title: string, listener: string) {
|
||||
this.title = title;
|
||||
this.listener = listener;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {Song, PlayingSong, QueuedSong, Playlist} from "./dataTypes";
|
||||
import {Song, PlayingSong, QueuedSong, Playlist, PlaylistDescription} from "./dataTypes";
|
||||
|
||||
export type StuenMessages =
|
||||
ListenerLeft
|
||||
@ -15,11 +15,13 @@ export type StuenMessages =
|
||||
| ReorderSong
|
||||
| SkipSong
|
||||
| SongLikes
|
||||
| CreatePlaylist
|
||||
| ToggleSongLike
|
||||
| CreatePlaylist
|
||||
| AddSongToPlaylist
|
||||
| RemoveSongFromPlaylist
|
||||
| Playlists;
|
||||
| Playlists
|
||||
| GetPlaylist
|
||||
| PlaylistSongs
|
||||
|
||||
export abstract class StuenMessage {
|
||||
constructor(public type: string) {
|
||||
@ -132,11 +134,22 @@ export class CreatePlaylist extends StuenMessage {
|
||||
}
|
||||
|
||||
export class Playlists extends StuenMessage {
|
||||
constructor(public playlists: Playlist[]) {
|
||||
constructor(public playlists: PlaylistDescription[]) {
|
||||
super('Playlists');
|
||||
}
|
||||
}
|
||||
|
||||
export class GetPlaylist extends StuenMessage {
|
||||
constructor(public playlist: PlaylistDescription) {
|
||||
super('GetPlaylist');
|
||||
}
|
||||
}
|
||||
export class PlaylistSongs extends StuenMessage {
|
||||
constructor(public playlist: Playlist) {
|
||||
super('PlaylistSongs');
|
||||
}
|
||||
}
|
||||
|
||||
export class AddSongToPlaylist extends StuenMessage {
|
||||
constructor(public song: Song, public playlist: string) {
|
||||
super('AddSongToPlaylist');
|
||||
@ -145,6 +158,6 @@ export class AddSongToPlaylist extends StuenMessage {
|
||||
|
||||
export class RemoveSongFromPlaylist extends StuenMessage {
|
||||
constructor(public song: Song, public playlist: string) {
|
||||
super('RemoveSongToPlaylist');
|
||||
super('RemoveSongFromPlaylist');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "stuen-common",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"main": "dist/common.js",
|
||||
"type": "commonjs",
|
||||
"types": "dist/common.d.ts",
|
||||
|
||||
@ -1,12 +1,27 @@
|
||||
import {
|
||||
AddSongToPlaylist,
|
||||
ChatMessage, CreatePlaylist, CurrentQueue, CurrentSong,
|
||||
ChatMessage,
|
||||
CreatePlaylist,
|
||||
CurrentQueue,
|
||||
CurrentSong,
|
||||
GetPlaylist,
|
||||
Join,
|
||||
ListenerJoined,
|
||||
ListenerLeft,
|
||||
ListenerList, Playlists, QueueSong, RemoveSongFromPlaylist, ReorderSong, SearchSong, SearchSongResult,
|
||||
SendChatMessage, SkipSong, SongLikes,
|
||||
StuenMessage, ToggleSongLike, UnqueueSong
|
||||
ListenerList,
|
||||
Playlists,
|
||||
PlaylistSongs,
|
||||
QueueSong,
|
||||
RemoveSongFromPlaylist,
|
||||
ReorderSong,
|
||||
SearchSong,
|
||||
SearchSongResult,
|
||||
SendChatMessage,
|
||||
SkipSong,
|
||||
SongLikes,
|
||||
StuenMessage,
|
||||
ToggleSongLike,
|
||||
UnqueueSong
|
||||
} from "./messageTypes";
|
||||
|
||||
export default function parseMessage(message: string): StuenMessage | null {
|
||||
@ -48,6 +63,10 @@ export default function parseMessage(message: string): StuenMessage | null {
|
||||
return new SongLikes(data.listeners);
|
||||
case 'Playlists':
|
||||
return new Playlists(data.playlists);
|
||||
case 'GetPlaylist':
|
||||
return new GetPlaylist(data.playlist);
|
||||
case 'PlaylistSongs':
|
||||
return new PlaylistSongs(data.playlist);
|
||||
case 'CreatePlaylist':
|
||||
return new CreatePlaylist(data.title);
|
||||
case 'AddSongToPlaylist':
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user