station.js 2.0 KB

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