mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 20:52:06 +00:00
fix(music-together): fix data integrity
This commit is contained in:
@ -218,7 +218,12 @@ export default createPlugin<
|
|||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case 'ADD_SONGS': {
|
case 'ADD_SONGS': {
|
||||||
if (conn && this.permission === 'host-only') return;
|
if (conn && this.permission === 'host-only') {
|
||||||
|
await this.connection?.broadcast('SYNC_QUEUE', {
|
||||||
|
videoList: this.queue?.videoList ?? [],
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const videoList: VideoData[] = event.payload.videoList.map(
|
const videoList: VideoData[] = event.payload.videoList.map(
|
||||||
(it) => ({
|
(it) => ({
|
||||||
@ -232,10 +237,18 @@ export default createPlugin<
|
|||||||
...event.payload,
|
...event.payload,
|
||||||
videoList,
|
videoList,
|
||||||
});
|
});
|
||||||
|
await this.connection?.broadcast('SYNC_QUEUE', {
|
||||||
|
videoList,
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'REMOVE_SONG': {
|
case 'REMOVE_SONG': {
|
||||||
if (conn && this.permission === 'host-only') return;
|
if (conn && this.permission === 'host-only') {
|
||||||
|
await this.connection?.broadcast('SYNC_QUEUE', {
|
||||||
|
videoList: this.queue?.videoList ?? [],
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.queue?.removeVideo(event.payload.index);
|
this.queue?.removeVideo(event.payload.index);
|
||||||
await this.connection?.broadcast('REMOVE_SONG', event.payload);
|
await this.connection?.broadcast('REMOVE_SONG', event.payload);
|
||||||
@ -385,7 +398,6 @@ export default createPlugin<
|
|||||||
ownerId: it.ownerId ?? this.connection!.id,
|
ownerId: it.ownerId ?? this.connection!.id,
|
||||||
})),
|
})),
|
||||||
});
|
});
|
||||||
await this.connection?.broadcast('SYNC_QUEUE', undefined);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'REMOVE_SONG': {
|
case 'REMOVE_SONG': {
|
||||||
@ -394,7 +406,6 @@ export default createPlugin<
|
|||||||
}
|
}
|
||||||
case 'MOVE_SONG': {
|
case 'MOVE_SONG': {
|
||||||
await this.connection?.broadcast('MOVE_SONG', event.payload);
|
await this.connection?.broadcast('MOVE_SONG', event.payload);
|
||||||
await this.connection?.broadcast('SYNC_QUEUE', undefined);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'SYNC_PROGRESS': {
|
case 'SYNC_PROGRESS': {
|
||||||
|
|||||||
Reference in New Issue
Block a user