123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- import { defineStore } from "pinia";
- export const useStationStore = defineStore("station", {
- state: () => ({
- station: {},
- autoRequest: [],
- autoRequestLock: false,
- editing: {},
- userCount: 0,
- users: {
- loggedIn: [],
- loggedOut: []
- },
- currentSong: {},
- nextSong: null,
- songsList: [],
- stationPaused: true,
- localPaused: false,
- noSong: true,
- autofill: [],
- blacklist: []
- }),
- actions: {
- joinStation(station) {
- this.station = { ...station };
- },
- leaveStation() {
- this.station = {};
- this.autoRequest = [];
- this.autoRequestLock = false;
- this.editing = {};
- this.userCount = 0;
- this.users = {
- loggedIn: [],
- loggedOut: []
- };
- this.currentSong = {};
- this.nextSong = null;
- this.songsList = [];
- this.stationPaused = true;
- this.localPaused = false;
- this.noSong = true;
- this.autofill = [];
- this.blacklist = [];
- },
- editStation(station) {
- this.editing = { ...station };
- },
- updateStation(station) {
- this.station = { ...this.station, ...station };
- },
- updateUserCount(userCount) {
- this.userCount = userCount;
- },
- updateUsers(users) {
- this.users = users;
- },
- updateCurrentSong(currentSong) {
- this.currentSong = currentSong;
- },
- updateNextSong(nextSong) {
- this.nextSong = nextSong;
- },
- updateSongsList(songsList) {
- this.songsList = songsList;
- },
- repositionSongInList(song) {
- if (
- this.songsList[song.newIndex] &&
- this.songsList[song.newIndex].youtubeId === song.youtubeId
- )
- return;
- this.songsList.splice(
- song.newIndex,
- 0,
- this.songsList.splice(song.oldIndex, 1)[0]
- );
- },
- updateStationPaused(stationPaused) {
- this.stationPaused = stationPaused;
- },
- updateLocalPaused(localPaused) {
- this.localPaused = localPaused;
- },
- updateNoSong(noSong) {
- this.noSong = noSong;
- },
- updateAutoRequest(playlists) {
- this.autoRequest = playlists;
- },
- updateAutoRequestLock(lock) {
- this.autoRequestLock = lock;
- },
- updateIfStationIsFavorited(isFavorited) {
- this.station.isFavorited = isFavorited;
- },
- setAutofillPlaylists(autofillPlaylists) {
- this.autofill = JSON.parse(JSON.stringify(autofillPlaylists));
- },
- setBlacklist(blacklist) {
- this.blacklist = JSON.parse(JSON.stringify(blacklist));
- },
- updateCurrentSongRatings(songRatings) {
- this.currentSong.likes = songRatings.likes;
- this.currentSong.dislikes = songRatings.dislikes;
- },
- updateOwnCurrentSongRatings(ownSongRatings) {
- this.currentSong.liked = ownSongRatings.liked;
- this.currentSong.disliked = ownSongRatings.disliked;
- },
- updateCurrentSongSkipVotes({ skipVotes, skipVotesCurrent }) {
- this.currentSong.skipVotes = skipVotes;
- if (skipVotesCurrent !== null)
- this.currentSong.skipVotesCurrent = skipVotesCurrent;
- },
- addPlaylistToAutoRequest(playlist) {
- this.autoRequest.push(playlist);
- },
- removePlaylistFromAutoRequest(playlistId) {
- this.autoRequest.forEach((playlist, index) => {
- if (playlist._id === playlistId) {
- this.autoRequest.splice(index, 1);
- }
- });
- }
- }
- });
|