(accountId, updates = {})
| 1368 | } |
| 1369 | |
| 1370 | async function patchHotmailAccount(accountId, updates = {}) { |
| 1371 | const state = await getState(); |
| 1372 | const accounts = normalizeHotmailAccounts(state.hotmailAccounts); |
| 1373 | const account = findHotmailAccount(accounts, accountId); |
| 1374 | if (!account) { |
| 1375 | throw new Error('未找到对应的 Hotmail 账号。'); |
| 1376 | } |
| 1377 | |
| 1378 | const nextAccount = normalizeHotmailAccount({ |
| 1379 | ...account, |
| 1380 | ...updates, |
| 1381 | id: account.id, |
| 1382 | }); |
| 1383 | |
| 1384 | await syncHotmailAccounts(accounts.map((item) => (item.id === account.id ? nextAccount : item))); |
| 1385 | |
| 1386 | if (state.currentHotmailAccountId === account.id && shouldClearHotmailCurrentSelection(nextAccount)) { |
| 1387 | await setState({ currentHotmailAccountId: null }); |
| 1388 | broadcastDataUpdate({ currentHotmailAccountId: null }); |
| 1389 | if (isHotmailProvider(state)) { |
| 1390 | await setEmailState(null); |
| 1391 | } |
| 1392 | } |
| 1393 | |
| 1394 | return nextAccount; |
| 1395 | } |
| 1396 | |
| 1397 | async function setCurrentHotmailAccount(accountId, options = {}) { |
| 1398 | const { markUsed = false, syncEmail = true } = options; |
no test coverage detected