123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- /* eslint no-param-reassign: 0 */
- const state = {
- station: {},
- partyPlaylists: [],
- editing: {},
- userCount: 0,
- users: {
- loggedIn: [],
- loggedOut: []
- },
- currentSong: {},
- nextSong: null,
- songsList: [],
- stationPaused: true,
- localPaused: false,
- noSong: true,
- includedPlaylists: [],
- excludedPlaylists: []
- };
- const getters = {};
- const actions = {
- joinStation: ({ commit }, station) => {
- commit("joinStation", station);
- },
- leaveStation: ({ commit }, station) => {
- commit("leaveStation", station);
- },
- editStation: ({ commit }, station) => {
- commit("editStation", station);
- },
- updateUserCount: ({ commit }, userCount) => {
- commit("updateUserCount", userCount);
- },
- updateUsers: ({ commit }, users) => {
- commit("updateUsers", users);
- },
- updateCurrentSong: ({ commit }, currentSong) => {
- commit("updateCurrentSong", currentSong);
- },
- updateNextSong: ({ commit }, nextSong) => {
- commit("updateNextSong", nextSong);
- },
- updateSongsList: ({ commit }, songsList) => {
- commit("updateSongsList", songsList);
- },
- repositionSongInList: ({ commit }, song) => {
- commit("repositionSongInList", song);
- },
- updateStationPaused: ({ commit }, stationPaused) => {
- commit("updateStationPaused", stationPaused);
- },
- updateLocalPaused: ({ commit }, localPaused) => {
- commit("updateLocalPaused", localPaused);
- },
- updateNoSong: ({ commit }, noSong) => {
- commit("updateNoSong", noSong);
- },
- updatePartyPlaylists: ({ commit }, playlists) => {
- commit("updatePartyPlaylists", playlists);
- },
- updateIfStationIsFavorited: ({ commit }, { isFavorited }) => {
- commit("updateIfStationIsFavorited", isFavorited);
- },
- setIncludedPlaylists: ({ commit }, includedPlaylists) => {
- commit("setIncludedPlaylists", includedPlaylists);
- },
- setExcludedPlaylists: ({ commit }, excludedPlaylists) => {
- commit("setExcludedPlaylists", excludedPlaylists);
- }
- };
- const mutations = {
- joinStation(state, station) {
- state.station = { ...station };
- },
- leaveStation(state) {
- state.station = {};
- state.partyPlaylists = [];
- state.editing = {};
- state.userCount = 0;
- state.users = {
- loggedIn: [],
- loggedOut: []
- };
- state.currentSong = {};
- state.nextSong = null;
- state.songsList = [];
- state.stationPaused = true;
- state.localPaused = false;
- state.noSong = true;
- state.includedPlaylists = [];
- state.excludedPlaylists = [];
- },
- editStation(state, station) {
- state.editing = { ...station };
- },
- updateUserCount(state, userCount) {
- state.userCount = userCount;
- },
- updateUsers(state, users) {
- state.users = users;
- },
- updateCurrentSong(state, currentSong) {
- state.currentSong = currentSong;
- },
- updateNextSong(state, nextSong) {
- state.nextSong = nextSong;
- },
- updateSongsList(state, songsList) {
- state.songsList = songsList;
- },
- repositionSongInList(state, song) {
- if (
- state.songsList[song.newIndex] &&
- state.songsList[song.newIndex].youtubeId === song.youtubeId
- )
- return;
- const { songsList } = state;
- songsList.splice(
- song.newIndex,
- 0,
- songsList.splice(song.oldIndex, 1)[0]
- );
- state.songsList = songsList;
- },
- updateStationPaused(state, stationPaused) {
- state.stationPaused = stationPaused;
- },
- updateLocalPaused(state, localPaused) {
- state.localPaused = localPaused;
- },
- updateNoSong(state, noSong) {
- state.noSong = noSong;
- },
- updatePartyPlaylists(state, playlists) {
- state.partyPlaylists = playlists;
- },
- updateIfStationIsFavorited(state, isFavorited) {
- state.station.isFavorited = isFavorited;
- },
- setIncludedPlaylists(state, includedPlaylists) {
- state.includedPlaylists = JSON.parse(JSON.stringify(includedPlaylists));
- },
- setExcludedPlaylists(state, excludedPlaylists) {
- state.excludedPlaylists = JSON.parse(JSON.stringify(excludedPlaylists));
- }
- };
- export default {
- namespaced: true,
- state,
- getters,
- actions,
- mutations
- };
|