Skip to content

Commit

Permalink
Fixed bug in reserved config not saving
Browse files Browse the repository at this point in the history
  • Loading branch information
coltoneshaw committed Oct 8, 2021
1 parent 1183b58 commit 6d6eef7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/app/Pages/Settings/Components/ApiSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ const ApiSettings = ({tempProfile, updateTempProfile}: {tempProfile: typeof defa
let secret = tempProfile.secret
let mode = tempProfile.mode
try {
await updateReservedFundsArray(key, secret, mode, handleUpdatingReservedFunds, tempProfile.reservedFunds)
const reservedFunds = await updateReservedFundsArray(key, secret, mode, tempProfile.reservedFunds)
handleUpdatingReservedFunds(reservedFunds ?? [])
} catch (error) {
alert('there was an error testing the API keys. Check the console for more information.')
}
Expand Down
8 changes: 4 additions & 4 deletions src/app/redux/configActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const updateNestedCurrentProfile = (data: string | {} | [], path: string) => {
store.dispatch(updateCurrentProfileByPath({ data, path }))
}

const updateReservedFundsArray = async (key: string, secret: string, mode: string, handleUpdatingReservedFunds: CallableFunction, reservedFunds: Type_ReservedFunds[]) => {
const updateReservedFundsArray = async (key: string, secret: string, mode: string, reservedFunds: Type_ReservedFunds[]) => {

// @ts-ignore
const accountSummary = await electron.api.getAccountData(undefined, key, secret, mode)
Expand All @@ -59,7 +59,7 @@ const updateReservedFundsArray = async (key: string, secret: string, mode: strin
// checking to see if any reserved funds exist
if (reservedFunds.length === 0 || reservedFunds === []) {
console.log('setting since there are no account IDs!')
return filteredAccountData.map(account => {
return filteredAccountData.map(account => {
const { id, name } = account
return {
id,
Expand All @@ -68,13 +68,14 @@ const updateReservedFundsArray = async (key: string, secret: string, mode: strin
is_enabled: false
}
})

}

// getting account IDs from the reserved funds
// const configuredAccountIds = removeDuplicatesInArray(reservedFunds.map(account => account.id), 'id')

// finding any accounts that did not exist since the last sync.
const reservedFundsArray = filteredAccountData
return filteredAccountData
// .filter( account => !configuredAccountIds.includes(account.id) )
.map(account => {
let { id, name } = account
Expand All @@ -96,7 +97,6 @@ const updateReservedFundsArray = async (key: string, secret: string, mode: strin

// updateReservedFunds(reservedFundsArray)

handleUpdatingReservedFunds(reservedFundsArray)

}

Expand Down

0 comments on commit 6d6eef7

Please sign in to comment.