bkper-js 1.35.1 → 1.35.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/model/Account.js +2 -1
- package/lib/model/Book.js +11 -6
- package/package.json +1 -1
package/lib/model/Account.js
CHANGED
|
@@ -350,8 +350,9 @@ export class Account {
|
|
|
350
350
|
*/
|
|
351
351
|
update() {
|
|
352
352
|
return __awaiter(this, void 0, void 0, function* () {
|
|
353
|
+
const previousGroupIds = [...(this.payload.groups || [])].map(g => g.id || "");
|
|
353
354
|
this.payload = yield AccountService.updateAccount(this.book.getId(), this.payload);
|
|
354
|
-
this.book.updateAccountCache(this);
|
|
355
|
+
this.book.updateAccountCache(this, previousGroupIds);
|
|
355
356
|
return this;
|
|
356
357
|
});
|
|
357
358
|
}
|
package/lib/model/Book.js
CHANGED
|
@@ -596,12 +596,15 @@ export class Book {
|
|
|
596
596
|
}
|
|
597
597
|
}
|
|
598
598
|
/** @internal */
|
|
599
|
-
updateAccountCache(account) {
|
|
599
|
+
updateAccountCache(account, previousGroupIds) {
|
|
600
600
|
if (this.idAccountMap) {
|
|
601
601
|
const id = account.getId();
|
|
602
602
|
if (id) {
|
|
603
603
|
this.idAccountMap.set(id, account);
|
|
604
604
|
}
|
|
605
|
+
if (previousGroupIds && previousGroupIds.length > 0) {
|
|
606
|
+
this.unlinkAccountsAndGroups(account, previousGroupIds);
|
|
607
|
+
}
|
|
605
608
|
this.linkAccountsAndGroups(account);
|
|
606
609
|
}
|
|
607
610
|
}
|
|
@@ -618,11 +621,13 @@ export class Book {
|
|
|
618
621
|
}
|
|
619
622
|
}
|
|
620
623
|
/** @internal */
|
|
621
|
-
unlinkAccountsAndGroups(account) {
|
|
622
|
-
var _a;
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
624
|
+
unlinkAccountsAndGroups(account, groupIds) {
|
|
625
|
+
var _a, _b;
|
|
626
|
+
if (!groupIds) {
|
|
627
|
+
groupIds = ((_a = account.payload.groups) === null || _a === void 0 ? void 0 : _a.map(g => g.id || "")) || [];
|
|
628
|
+
}
|
|
629
|
+
for (const groupId of groupIds) {
|
|
630
|
+
const group = (_b = this.idGroupMap) === null || _b === void 0 ? void 0 : _b.get(groupId || "");
|
|
626
631
|
if (group != null) {
|
|
627
632
|
group.removeAccount(account);
|
|
628
633
|
}
|