station.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* eslint no-param-reassign: 0 */
  2. const state = {
  3. station: {},
  4. privatePlaylistQueueSelected: null,
  5. editing: {},
  6. userCount: 0,
  7. users: [],
  8. currentSong: {},
  9. previousSong: null,
  10. songsList: [],
  11. paused: true,
  12. noSong: true
  13. };
  14. const getters = {};
  15. const actions = {
  16. joinStation: ({ commit }, station) => {
  17. commit("joinStation", station);
  18. },
  19. editStation: ({ commit }, station) => {
  20. commit("editStation", station);
  21. },
  22. updateUserCount: ({ commit }, userCount) => {
  23. commit("updateUserCount", userCount);
  24. },
  25. updateUsers: ({ commit }, users) => {
  26. commit("updateUsers", users);
  27. },
  28. updateCurrentSong: ({ commit }, currentSong) => {
  29. commit("updateCurrentSong", currentSong);
  30. },
  31. updatePreviousSong: ({ commit }, previousSong) => {
  32. commit("updatePreviousSong", previousSong);
  33. },
  34. updateSongsList: ({ commit }, songsList) => {
  35. commit("updateSongsList", songsList);
  36. },
  37. updatePaused: ({ commit }, paused) => {
  38. commit("updatePaused", paused);
  39. },
  40. updateNoSong: ({ commit }, noSong) => {
  41. commit("updateNoSong", noSong);
  42. },
  43. updatePrivatePlaylistQueueSelected: ({ commit }, status) => {
  44. commit("updatePrivatePlaylistQueueSelected", status);
  45. }
  46. };
  47. const mutations = {
  48. joinStation(state, station) {
  49. state.station = { ...station };
  50. },
  51. editStation(state, station) {
  52. state.editing = { ...station };
  53. },
  54. updateUserCount(state, userCount) {
  55. state.userCount = userCount;
  56. },
  57. updateUsers(state, users) {
  58. state.users = users;
  59. },
  60. updateCurrentSong(state, currentSong) {
  61. if (currentSong.likes === -1 && currentSong.dislikes === -1) {
  62. currentSong.skipDuration = 0;
  63. currentSong.simpleSong = true;
  64. } else {
  65. currentSong.simpleSong = false;
  66. }
  67. state.currentSong = currentSong;
  68. },
  69. updatePreviousSong(state, previousSong) {
  70. state.previousSong = previousSong;
  71. },
  72. updateSongsList(state, songsList) {
  73. state.songsList = songsList;
  74. },
  75. updatePaused(state, paused) {
  76. state.paused = paused;
  77. },
  78. updateNoSong(state, noSong) {
  79. state.noSong = noSong;
  80. },
  81. updatePrivatePlaylistQueueSelected(state, status) {
  82. state.privatePlaylistQueueSelected = status;
  83. }
  84. };
  85. export default {
  86. namespaced: true,
  87. state,
  88. getters,
  89. actions,
  90. mutations
  91. };