(mode = 'all')
| 1343 | } |
| 1344 | |
| 1345 | async function deleteHotmailAccounts(mode = 'all') { |
| 1346 | const state = await getState(); |
| 1347 | const accounts = normalizeHotmailAccounts(state.hotmailAccounts); |
| 1348 | const targets = filterHotmailAccountsByUsage(accounts, mode); |
| 1349 | const targetIds = new Set(targets.map((account) => account.id)); |
| 1350 | const nextAccounts = mode === 'used' |
| 1351 | ? accounts.filter((account) => !targetIds.has(account.id)) |
| 1352 | : []; |
| 1353 | |
| 1354 | await syncHotmailAccounts(nextAccounts); |
| 1355 | |
| 1356 | if (state.currentHotmailAccountId && targetIds.has(state.currentHotmailAccountId)) { |
| 1357 | await setState({ currentHotmailAccountId: null }); |
| 1358 | if (isHotmailProvider(state)) { |
| 1359 | await setEmailState(null); |
| 1360 | } |
| 1361 | broadcastDataUpdate({ currentHotmailAccountId: null }); |
| 1362 | } |
| 1363 | |
| 1364 | return { |
| 1365 | deletedCount: targets.length, |
| 1366 | remainingCount: nextAccounts.length, |
| 1367 | }; |
| 1368 | } |
| 1369 | |
| 1370 | async function patchHotmailAccount(accountId, updates = {}) { |
| 1371 | const state = await getState(); |
no test coverage detected