@pisell/pisellos 0.0.164 → 0.0.165
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.
|
@@ -303,7 +303,7 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
303
303
|
key: "removeAccount",
|
|
304
304
|
value: function () {
|
|
305
305
|
var _removeAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(id) {
|
|
306
|
-
var index;
|
|
306
|
+
var _this$getActiveAccoun, index;
|
|
307
307
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
308
308
|
while (1) switch (_context6.prev = _context6.next) {
|
|
309
309
|
case 0:
|
|
@@ -324,26 +324,31 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
324
324
|
this.store.accountList = this.store.accountList.filter(function (account) {
|
|
325
325
|
return account.id !== id;
|
|
326
326
|
});
|
|
327
|
-
|
|
327
|
+
|
|
328
|
+
// 检测 如果被删除的是活跃账号,则默认把第一个账号设置为 activeAccount
|
|
329
|
+
if (((_this$getActiveAccoun = this.getActiveAccount()) === null || _this$getActiveAccoun === void 0 ? void 0 : _this$getActiveAccoun.getId()) === id) {
|
|
330
|
+
this.setActiveAccount(this.store.accounts[0].getId());
|
|
331
|
+
}
|
|
332
|
+
_context6.next = 12;
|
|
328
333
|
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
329
|
-
case
|
|
330
|
-
_context6.next =
|
|
334
|
+
case 12:
|
|
335
|
+
_context6.next = 19;
|
|
331
336
|
break;
|
|
332
|
-
case
|
|
333
|
-
_context6.prev =
|
|
337
|
+
case 14:
|
|
338
|
+
_context6.prev = 14;
|
|
334
339
|
_context6.t0 = _context6["catch"](0);
|
|
335
340
|
this.store.error = _context6.t0 instanceof Error ? _context6.t0.message : 'Failed to remove account';
|
|
336
|
-
_context6.next =
|
|
341
|
+
_context6.next = 19;
|
|
337
342
|
return this.core.effects.emit(AccountListHooks.OnAccountListError, this.store.error);
|
|
338
|
-
case
|
|
339
|
-
_context6.prev =
|
|
343
|
+
case 19:
|
|
344
|
+
_context6.prev = 19;
|
|
340
345
|
this.store.isLoading = false;
|
|
341
|
-
return _context6.finish(
|
|
342
|
-
case
|
|
346
|
+
return _context6.finish(19);
|
|
347
|
+
case 22:
|
|
343
348
|
case "end":
|
|
344
349
|
return _context6.stop();
|
|
345
350
|
}
|
|
346
|
-
}, _callee6, this, [[0,
|
|
351
|
+
}, _callee6, this, [[0, 14, 19, 22]]);
|
|
347
352
|
}));
|
|
348
353
|
function removeAccount(_x9) {
|
|
349
354
|
return _removeAccount.apply(this, arguments);
|
|
@@ -179,6 +179,7 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
async removeAccount(id) {
|
|
182
|
+
var _a;
|
|
182
183
|
try {
|
|
183
184
|
this.store.isLoading = true;
|
|
184
185
|
this.store.error = null;
|
|
@@ -194,6 +195,9 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
194
195
|
this.store.accountList = this.store.accountList.filter(
|
|
195
196
|
(account) => account.id !== id
|
|
196
197
|
);
|
|
198
|
+
if (((_a = this.getActiveAccount()) == null ? void 0 : _a.getId()) === id) {
|
|
199
|
+
this.setActiveAccount(this.store.accounts[0].getId());
|
|
200
|
+
}
|
|
197
201
|
await this.core.effects.emit(
|
|
198
202
|
import_types.AccountListHooks.OnAccountListUpdate,
|
|
199
203
|
this.store
|