fix user info update logic

This commit is contained in:
syuilo 2021-01-03 15:04:08 +09:00
parent e8b2ff4d62
commit e6706df8f9

View file

@ -59,7 +59,8 @@ export default class Friend {
this.doc = inserted; this.doc = inserted;
} else { } else {
this.doc = exist; this.doc = exist;
this.doc.user = opts.user; this.doc.user = { ...this.doc.user, ...opts.user };
console.log(this.doc.user);
this.save(); this.save();
} }
} else if (opts.doc) { } else if (opts.doc) {
@ -70,8 +71,11 @@ export default class Friend {
} }
@autobind @autobind
public updateUser(user: User) { public updateUser(user: Partial<User>) {
this.doc.user = user; this.doc.user = {
...this.doc.user,
...user,
};
this.save(); this.save();
} }