| 99 | } |
| 100 | |
| 101 | function upsertHotmailAccountInList(accounts, nextAccount) { |
| 102 | const list = Array.isArray(accounts) ? accounts.slice() : []; |
| 103 | if (!nextAccount?.id) return list; |
| 104 | |
| 105 | const existingIndex = list.findIndex((account) => account?.id === nextAccount.id); |
| 106 | if (existingIndex === -1) { |
| 107 | list.push(nextAccount); |
| 108 | return list; |
| 109 | } |
| 110 | |
| 111 | list[existingIndex] = nextAccount; |
| 112 | return list; |
| 113 | } |
| 114 | |
| 115 | function pickHotmailAccountForRun(accounts, options = {}) { |
| 116 | const candidates = Array.isArray(accounts) ? accounts.filter(isAuthorizedHotmailAccount) : []; |