Fix account email update (#6551)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2024-09-13 14:38:59 +05:00 committed by GitHub
parent 4eee28641f
commit bf6496d217
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -263,22 +263,25 @@ export abstract class MemDb extends TxProcessor implements Storage {
} }
updateDoc (_id: Ref<Doc>, doc: Doc, update: TxUpdateDoc<Doc> | TxMixin<Doc, Doc>): void { updateDoc (_id: Ref<Doc>, doc: Doc, update: TxUpdateDoc<Doc> | TxMixin<Doc, Doc>): void {
if ( if (this.hierarchy.isDerived(doc._class, core.class.Account) && update._class === core.class.TxUpdateDoc) {
this.hierarchy.isDerived(doc._class, core.class.Account) && const newEmail = (update as TxUpdateDoc<Account>).operations.email
update._class === core.class.TxUpdateDoc && if ((update as TxUpdateDoc<Account>).operations.person !== undefined) {
(update as TxUpdateDoc<Account>).operations.person !== undefined const account = doc as Account
) { if (account.person !== undefined) {
const account = doc as Account const acc = this.accountByPersonId.get(account.person) ?? []
if (account.person !== undefined) { this.accountByPersonId.set(
const acc = this.accountByPersonId.get(account.person) ?? [] account.person,
this.accountByPersonId.set( acc.filter((it) => it._id !== _id)
account.person, )
acc.filter((it) => it._id !== _id) }
) const newPerson = (update as TxUpdateDoc<Account>).operations.person
} if (newPerson !== undefined) {
const newPerson = (update as TxUpdateDoc<Account>).operations.person this.accountByPersonId.set(newPerson, [...(this.accountByPersonId.get(newPerson) ?? []), account])
if (newPerson !== undefined) { }
this.accountByPersonId.set(newPerson, [...(this.accountByPersonId.get(newPerson) ?? []), account]) } else if (newEmail !== undefined) {
const account = doc as Account
this.accountByEmail.delete(account.email)
this.accountByEmail.set(newEmail, account)
} }
} }
} }