Skip to content

Always Got Triggered Mutation. #185

Closed
@takielias

Description

@takielias

Hi, I have been trying to fixing this issue for 2 days. It always Triggers Mutation but not actions.

import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex);

const roommsgs = {
  state: {
    roommsgs: []
  },
  mutations: {
    SOCKET_CONNECT(state, status) {},
    SOCKET_ROOMCHAT(state, roomchat) {
      state.roommsgs.push(roomchat);
    }
  },
  actions: {
    socket_roomChat: async ({
      commit,
      dispatch
    }, message) => {
      dispatch('socket_roomChat', message);
      commit('SOCKET_ROOMCHAT', message);
    }
  },
  getters: {
    getChatByRoom: (state) => (room_name) => {
      return state.roommsgs.find(roommsgs => roommsgs.roomname === room_name)
    }
  }
};

const notifications = {
  state: {
    notifications: []
  },
  mutations: {
    SOCKET_NOTIFICATIONS(state, message) {
      state.notifications.push({
        type: 'notifications',
        payload: message
      });
    }
  },
}

export default new Vuex.Store({
  modules: {
    roommsgs,
    notifications,
  }
})

Is there anything else should I consider?

Metadata

Metadata

Assignees

Labels

question 🤔Further information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions