So I've tried to follow the docs and 2.0 PR #216
Got everything working pretty well. I can login and send messages back and forth.
(Followed this guide for the flow https://docs.feathersjs.com/guides/basics/setup.html)
I made a profile page to update the logged in users information.
The flow i used for that is
const { User } = this.$FeathersVuex.api;
let user = User.getFromStore(authUser._id);
if (!user) {
user = await User.get(authUser._id);
}
this.user = user.clone();
I then edit the copy and call this.user.save() once I'm done to commit the changes and update the server.
This does not appear to update authenticated user in the store state.auth.user.
To fix this i added the following to my makeAuthPlugin which takes the user information returned from the server upon login and creates a User model using that information and now the auth.user automatically updates since i now clone the model from auth and save that instead.
actions: {
responseHandler({ commit, state }, response) {
const apiService = "api";
if (state.userService) {
let user = response[state.responseEntityField];
const Model = Object.keys(models[apiService])
.map(modelName => models[apiService][modelName])
.find(model => model.servicePath === state.userService);
if (Model) {
user = new Model({ ...response.user });
commit("setUser", user);
}
}
}
}
Am i doing something wrong, since i would expect the auth.user to be reactive by default, or was that changed in the 2.0 pre-release? And if that is the case, is the above approach the correct one to solve the issue?
I'm using feathers: 4.3.7 on the server and client and feathers-vuex: 2.0.0-pre78
@Hiws could you try using [email protected] (non-pre). I released it yesterday.
The code you have posted is almost exactly identical to what's in the final released version.
@marshallswain
It works perfectly after upgrading!
Thanks you for all the great work, thoroughly impressed with what you've made.
Most helpful comment
@marshallswain
It works perfectly after upgrading!
Thanks you for all the great work, thoroughly impressed with what you've made.