(accountId, options = {})
| 1395 | } |
| 1396 | |
| 1397 | async function setCurrentHotmailAccount(accountId, options = {}) { |
| 1398 | const { markUsed = false, syncEmail = true } = options; |
| 1399 | const state = await getState(); |
| 1400 | const accounts = normalizeHotmailAccounts(state.hotmailAccounts); |
| 1401 | const account = findHotmailAccount(accounts, accountId); |
| 1402 | if (!account) { |
| 1403 | throw new Error('未找到对应的 Hotmail 账号。'); |
| 1404 | } |
| 1405 | |
| 1406 | if (markUsed) { |
| 1407 | account.lastUsedAt = Date.now(); |
| 1408 | await syncHotmailAccounts(accounts.map((item) => (item.id === account.id ? account : item))); |
| 1409 | } |
| 1410 | |
| 1411 | await setState({ currentHotmailAccountId: account.id }); |
| 1412 | broadcastDataUpdate({ currentHotmailAccountId: account.id }); |
| 1413 | if (syncEmail) { |
| 1414 | await setEmailState(account.email || null); |
| 1415 | } |
| 1416 | return account; |
| 1417 | } |
| 1418 | |
| 1419 | async function ensureHotmailAccountForFlow(options = {}) { |
| 1420 | const { allowAllocate = true, markUsed = false, preferredAccountId = null } = options; |
no test coverage detected