|
@@ -1146,215 +1146,208 @@ onMounted(async () => {
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
+ });
|
|
|
|
|
|
- socket.on("event:station.nextSong", res => {
|
|
|
- const { currentSong, startedAt, paused, timePaused } = res.data;
|
|
|
-
|
|
|
- setCurrentSong({
|
|
|
- currentSong,
|
|
|
- startedAt,
|
|
|
- paused,
|
|
|
- timePaused,
|
|
|
- pausedAt: 0
|
|
|
- });
|
|
|
- });
|
|
|
+ socket.onDisconnect(() => {
|
|
|
+ const _currentSong = currentSong.value;
|
|
|
+ if (nextSong.value)
|
|
|
+ setNextCurrentSong(
|
|
|
+ {
|
|
|
+ currentSong: nextSong.value,
|
|
|
+ startedAt: Date.now() + getTimeRemaining(),
|
|
|
+ paused: false,
|
|
|
+ timePaused: 0
|
|
|
+ },
|
|
|
+ true
|
|
|
+ );
|
|
|
+ else
|
|
|
+ setNextCurrentSong(
|
|
|
+ {
|
|
|
+ currentSong: null,
|
|
|
+ startedAt: 0,
|
|
|
+ paused: false,
|
|
|
+ timePaused: 0,
|
|
|
+ pausedAt: 0
|
|
|
+ },
|
|
|
+ true
|
|
|
+ );
|
|
|
+ window.stationNextSongTimeout = setTimeout(() => {
|
|
|
+ if (!noSong.value && currentSong.value._id === _currentSong._id)
|
|
|
+ skipSong();
|
|
|
+ }, getTimeRemaining());
|
|
|
+ }, true);
|
|
|
|
|
|
- socket.on("event:station.pause", res => {
|
|
|
- pausedAt.value = res.data.pausedAt;
|
|
|
- updateStationPaused(true);
|
|
|
- pauseLocalPlayer();
|
|
|
+ socket.on("event:station.nextSong", res => {
|
|
|
+ const { currentSong, startedAt, paused, timePaused } = res.data;
|
|
|
|
|
|
- clearTimeout(window.stationNextSongTimeout);
|
|
|
+ setCurrentSong({
|
|
|
+ currentSong,
|
|
|
+ startedAt,
|
|
|
+ paused,
|
|
|
+ timePaused,
|
|
|
+ pausedAt: 0
|
|
|
});
|
|
|
+ });
|
|
|
|
|
|
- socket.on("event:station.resume", res => {
|
|
|
- timePaused.value = res.data.timePaused;
|
|
|
- updateStationPaused(false);
|
|
|
- if (!localPaused.value) resumeLocalPlayer();
|
|
|
+ socket.on("event:station.pause", res => {
|
|
|
+ pausedAt.value = res.data.pausedAt;
|
|
|
+ updateStationPaused(true);
|
|
|
+ pauseLocalPlayer();
|
|
|
|
|
|
- autoRequestSong();
|
|
|
- });
|
|
|
+ clearTimeout(window.stationNextSongTimeout);
|
|
|
+ });
|
|
|
|
|
|
- socket.on("event:station.deleted", () => {
|
|
|
- router.push({
|
|
|
- path: "/",
|
|
|
- query: {
|
|
|
- toast: "The station you were in was deleted."
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
+ socket.on("event:station.resume", res => {
|
|
|
+ timePaused.value = res.data.timePaused;
|
|
|
+ updateStationPaused(false);
|
|
|
+ if (!localPaused.value) resumeLocalPlayer();
|
|
|
|
|
|
- socket.on("event:ratings.liked", res => {
|
|
|
- if (!noSong.value) {
|
|
|
- if (res.data.youtubeId === currentSong.value.youtubeId) {
|
|
|
- updateCurrentSongRatings(res.data);
|
|
|
- }
|
|
|
+ autoRequestSong();
|
|
|
+ });
|
|
|
+
|
|
|
+ socket.on("event:station.deleted", () => {
|
|
|
+ router.push({
|
|
|
+ path: "/",
|
|
|
+ query: {
|
|
|
+ toast: "The station you were in was deleted."
|
|
|
}
|
|
|
});
|
|
|
+ });
|
|
|
|
|
|
- socket.on("event:ratings.disliked", res => {
|
|
|
- if (!noSong.value) {
|
|
|
- if (res.data.youtubeId === currentSong.value.youtubeId) {
|
|
|
- updateCurrentSongRatings(res.data);
|
|
|
- }
|
|
|
+ socket.on("event:ratings.liked", res => {
|
|
|
+ if (!noSong.value) {
|
|
|
+ if (res.data.youtubeId === currentSong.value.youtubeId) {
|
|
|
+ updateCurrentSongRatings(res.data);
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- socket.on("event:ratings.unliked", res => {
|
|
|
- if (!noSong.value) {
|
|
|
- if (res.data.youtubeId === currentSong.value.youtubeId) {
|
|
|
- updateCurrentSongRatings(res.data);
|
|
|
- }
|
|
|
+ socket.on("event:ratings.disliked", res => {
|
|
|
+ if (!noSong.value) {
|
|
|
+ if (res.data.youtubeId === currentSong.value.youtubeId) {
|
|
|
+ updateCurrentSongRatings(res.data);
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- socket.on("event:ratings.undisliked", res => {
|
|
|
- if (!noSong.value) {
|
|
|
- if (res.data.youtubeId === currentSong.value.youtubeId) {
|
|
|
- updateCurrentSongRatings(res.data);
|
|
|
- }
|
|
|
+ socket.on("event:ratings.unliked", res => {
|
|
|
+ if (!noSong.value) {
|
|
|
+ if (res.data.youtubeId === currentSong.value.youtubeId) {
|
|
|
+ updateCurrentSongRatings(res.data);
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- socket.on("event:ratings.updated", res => {
|
|
|
- if (!noSong.value) {
|
|
|
- if (res.data.youtubeId === currentSong.value.youtubeId) {
|
|
|
- updateOwnCurrentSongRatings(res.data);
|
|
|
- }
|
|
|
+ socket.on("event:ratings.undisliked", res => {
|
|
|
+ if (!noSong.value) {
|
|
|
+ if (res.data.youtubeId === currentSong.value.youtubeId) {
|
|
|
+ updateCurrentSongRatings(res.data);
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- socket.on("event:station.queue.updated", res => {
|
|
|
- updateSongsList(res.data.queue);
|
|
|
+ socket.on("event:ratings.updated", res => {
|
|
|
+ if (!noSong.value) {
|
|
|
+ if (res.data.youtubeId === currentSong.value.youtubeId) {
|
|
|
+ updateOwnCurrentSongRatings(res.data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- let nextSong = null;
|
|
|
- if (songsList.value[0])
|
|
|
- nextSong = songsList.value[0].youtubeId
|
|
|
- ? songsList.value[0]
|
|
|
- : null;
|
|
|
+ socket.on("event:station.queue.updated", res => {
|
|
|
+ updateSongsList(res.data.queue);
|
|
|
|
|
|
- updateNextSong(nextSong);
|
|
|
+ let nextSong = null;
|
|
|
+ if (songsList.value[0])
|
|
|
+ nextSong = songsList.value[0].youtubeId ? songsList.value[0] : null;
|
|
|
|
|
|
- autoRequestSong();
|
|
|
- });
|
|
|
+ updateNextSong(nextSong);
|
|
|
|
|
|
- socket.on("event:station.queue.song.repositioned", res => {
|
|
|
- repositionSongInList(res.data.song);
|
|
|
+ autoRequestSong();
|
|
|
+ });
|
|
|
|
|
|
- let nextSong = null;
|
|
|
- if (songsList.value[0])
|
|
|
- nextSong = songsList.value[0].youtubeId
|
|
|
- ? songsList.value[0]
|
|
|
- : null;
|
|
|
+ socket.on("event:station.queue.song.repositioned", res => {
|
|
|
+ repositionSongInList(res.data.song);
|
|
|
|
|
|
- updateNextSong(nextSong);
|
|
|
- });
|
|
|
+ let nextSong = null;
|
|
|
+ if (songsList.value[0])
|
|
|
+ nextSong = songsList.value[0].youtubeId ? songsList.value[0] : null;
|
|
|
|
|
|
- socket.on("event:station.toggleSkipVote", res => {
|
|
|
- if (currentSong.value)
|
|
|
- updateCurrentSongSkipVotes({
|
|
|
- skipVotes: res.data.voted
|
|
|
- ? currentSong.value.skipVotes + 1
|
|
|
- : currentSong.value.skipVotes - 1,
|
|
|
- skipVotesCurrent: null,
|
|
|
- voted:
|
|
|
- res.data.userId === userId.value
|
|
|
- ? res.data.voted
|
|
|
- : currentSong.value.voted
|
|
|
- });
|
|
|
- });
|
|
|
+ updateNextSong(nextSong);
|
|
|
+ });
|
|
|
|
|
|
- socket.on("event:station.updated", async res => {
|
|
|
- const { name, theme, privacy } = res.data.station;
|
|
|
+ socket.on("event:station.toggleSkipVote", res => {
|
|
|
+ if (currentSong.value)
|
|
|
+ updateCurrentSongSkipVotes({
|
|
|
+ skipVotes: res.data.voted
|
|
|
+ ? currentSong.value.skipVotes + 1
|
|
|
+ : currentSong.value.skipVotes - 1,
|
|
|
+ skipVotesCurrent: null,
|
|
|
+ voted:
|
|
|
+ res.data.userId === userId.value
|
|
|
+ ? res.data.voted
|
|
|
+ : currentSong.value.voted
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
- if (!hasPermission("stations.view") && privacy === "private") {
|
|
|
- router.push({
|
|
|
- path: "/",
|
|
|
- query: {
|
|
|
- toast: "The station you were in was made private."
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- if (station.value.name !== name) {
|
|
|
- await router.push(
|
|
|
- `${name}?${Object.keys(route.query)
|
|
|
- .map(
|
|
|
- key =>
|
|
|
- `${encodeURIComponent(
|
|
|
- key
|
|
|
- )}=${encodeURIComponent(
|
|
|
- JSON.stringify(route.query[key])
|
|
|
- )}`
|
|
|
- )
|
|
|
- .join("&")}`
|
|
|
- );
|
|
|
+ socket.on("event:station.updated", async res => {
|
|
|
+ const { name, theme, privacy } = res.data.station;
|
|
|
|
|
|
- // eslint-disable-next-line no-restricted-globals
|
|
|
- history.replaceState({ ...history.state, ...{} }, null);
|
|
|
+ if (!hasPermission("stations.view") && privacy === "private") {
|
|
|
+ router.push({
|
|
|
+ path: "/",
|
|
|
+ query: {
|
|
|
+ toast: "The station you were in was made private."
|
|
|
}
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ if (station.value.name !== name) {
|
|
|
+ await router.push(
|
|
|
+ `${name}?${Object.keys(route.query)
|
|
|
+ .map(
|
|
|
+ key =>
|
|
|
+ `${encodeURIComponent(
|
|
|
+ key
|
|
|
+ )}=${encodeURIComponent(
|
|
|
+ JSON.stringify(route.query[key])
|
|
|
+ )}`
|
|
|
+ )
|
|
|
+ .join("&")}`
|
|
|
+ );
|
|
|
|
|
|
- if (station.value.theme !== theme)
|
|
|
- document.getElementsByTagName(
|
|
|
- "html"
|
|
|
- )[0].style.cssText = `--primary-color: var(--${theme})`;
|
|
|
-
|
|
|
- updateStation(res.data.station);
|
|
|
+ // eslint-disable-next-line no-restricted-globals
|
|
|
+ history.replaceState({ ...history.state, ...{} }, null);
|
|
|
}
|
|
|
- });
|
|
|
|
|
|
- socket.on("event:station.users.updated", res =>
|
|
|
- updateUsers(res.data.users)
|
|
|
- );
|
|
|
+ if (station.value.theme !== theme)
|
|
|
+ document.getElementsByTagName(
|
|
|
+ "html"
|
|
|
+ )[0].style.cssText = `--primary-color: var(--${theme})`;
|
|
|
|
|
|
- socket.on("event:station.userCount.updated", res =>
|
|
|
- updateUserCount(res.data.userCount)
|
|
|
- );
|
|
|
+ updateStation(res.data.station);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- socket.on("event:user.station.favorited", res => {
|
|
|
- if (res.data.stationId === station.value._id)
|
|
|
- updateIfStationIsFavorited({ isFavorited: true });
|
|
|
- });
|
|
|
+ socket.on("event:station.users.updated", res =>
|
|
|
+ updateUsers(res.data.users)
|
|
|
+ );
|
|
|
|
|
|
- socket.on("event:user.station.unfavorited", res => {
|
|
|
- if (res.data.stationId === station.value._id)
|
|
|
- updateIfStationIsFavorited({ isFavorited: false });
|
|
|
- });
|
|
|
+ socket.on("event:station.userCount.updated", res =>
|
|
|
+ updateUserCount(res.data.userCount)
|
|
|
+ );
|
|
|
|
|
|
- socket.on("event:station.djs.added", res => {
|
|
|
- if (res.data.user._id === userId.value)
|
|
|
- updatePermissions().then(() => {
|
|
|
- if (
|
|
|
- !hasPermission("stations.view") &&
|
|
|
- station.value.privacy === "private"
|
|
|
- )
|
|
|
- router.push({
|
|
|
- path: "/",
|
|
|
- query: {
|
|
|
- toast: "You no longer have access to the station you were in."
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- addDj(res.data.user);
|
|
|
- });
|
|
|
+ socket.on("event:user.station.favorited", res => {
|
|
|
+ if (res.data.stationId === station.value._id)
|
|
|
+ updateIfStationIsFavorited({ isFavorited: true });
|
|
|
+ });
|
|
|
|
|
|
- socket.on("event:station.djs.removed", res => {
|
|
|
- if (res.data.user._id === userId.value)
|
|
|
- updatePermissions().then(() => {
|
|
|
- if (
|
|
|
- !hasPermission("stations.view") &&
|
|
|
- station.value.privacy === "private"
|
|
|
- )
|
|
|
- router.push({
|
|
|
- path: "/",
|
|
|
- query: {
|
|
|
- toast: "You no longer have access to the station you were in."
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- removeDj(res.data.user);
|
|
|
- });
|
|
|
+ socket.on("event:user.station.unfavorited", res => {
|
|
|
+ if (res.data.stationId === station.value._id)
|
|
|
+ updateIfStationIsFavorited({ isFavorited: false });
|
|
|
+ });
|
|
|
|
|
|
- socket.on("keep.event:user.role.updated", () => {
|
|
|
+ socket.on("event:station.djs.added", res => {
|
|
|
+ if (res.data.user._id === userId.value)
|
|
|
updatePermissions().then(() => {
|
|
|
if (
|
|
|
!hasPermission("stations.view") &&
|
|
@@ -1367,37 +1360,40 @@ onMounted(async () => {
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
- });
|
|
|
+ addDj(res.data.user);
|
|
|
});
|
|
|
|
|
|
- socket.onDisconnect(() => {
|
|
|
- const _currentSong = currentSong.value;
|
|
|
- if (nextSong.value)
|
|
|
- setNextCurrentSong(
|
|
|
- {
|
|
|
- currentSong: nextSong.value,
|
|
|
- startedAt: Date.now() + getTimeRemaining(),
|
|
|
- paused: false,
|
|
|
- timePaused: 0
|
|
|
- },
|
|
|
- true
|
|
|
- );
|
|
|
- else
|
|
|
- setNextCurrentSong(
|
|
|
- {
|
|
|
- currentSong: null,
|
|
|
- startedAt: 0,
|
|
|
- paused: false,
|
|
|
- timePaused: 0,
|
|
|
- pausedAt: 0
|
|
|
- },
|
|
|
- true
|
|
|
- );
|
|
|
- window.stationNextSongTimeout = setTimeout(() => {
|
|
|
- if (!noSong.value && currentSong.value._id === _currentSong._id)
|
|
|
- skipSong();
|
|
|
- }, getTimeRemaining());
|
|
|
- }, true);
|
|
|
+ socket.on("event:station.djs.removed", res => {
|
|
|
+ if (res.data.user._id === userId.value)
|
|
|
+ updatePermissions().then(() => {
|
|
|
+ if (
|
|
|
+ !hasPermission("stations.view") &&
|
|
|
+ station.value.privacy === "private"
|
|
|
+ )
|
|
|
+ router.push({
|
|
|
+ path: "/",
|
|
|
+ query: {
|
|
|
+ toast: "You no longer have access to the station you were in."
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ removeDj(res.data.user);
|
|
|
+ });
|
|
|
+
|
|
|
+ socket.on("keep.event:user.role.updated", () => {
|
|
|
+ updatePermissions().then(() => {
|
|
|
+ if (
|
|
|
+ !hasPermission("stations.view") &&
|
|
|
+ station.value.privacy === "private"
|
|
|
+ )
|
|
|
+ router.push({
|
|
|
+ path: "/",
|
|
|
+ query: {
|
|
|
+ toast: "You no longer have access to the station you were in."
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
frontendDevMode.value = await lofig.get("mode");
|
|
|
mediasession.value = await lofig.get("siteSettings.mediasession");
|