diff --git a/packages/desktop-client/src/components/modals/CreateAccountModal.tsx b/packages/desktop-client/src/components/modals/CreateAccountModal.tsx index a753458409c..a655e2b8e6a 100644 --- a/packages/desktop-client/src/components/modals/CreateAccountModal.tsx +++ b/packages/desktop-client/src/components/modals/CreateAccountModal.tsx @@ -51,11 +51,7 @@ export function CreateAccountModal({ upgradingAccountId }: CreateAccountProps) { return; } - if (upgradingAccountId == null) { - authorizeBank(dispatch); - } else { - authorizeBank(dispatch); - } + authorizeBank(dispatch); }; const onConnectSimpleFin = async () => { diff --git a/packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.jsx b/packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.jsx index 545c47caefb..6df1b3e7eb8 100644 --- a/packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.jsx +++ b/packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.jsx @@ -78,16 +78,18 @@ export function SelectLinkedAccountsModal({ return; } + const upgradingId = + chosenLocalAccountId !== addOnBudgetAccountOption.id && + chosenLocalAccountId !== addOffBudgetAccountOption.id + ? chosenLocalAccountId + : undefined; + // Finally link the matched account if (syncSource === 'simpleFin') { dispatch( linkAccountSimpleFin({ externalAccount, - upgradingId: - chosenLocalAccountId !== addOnBudgetAccountOption.id && - chosenLocalAccountId !== addOffBudgetAccountOption.id - ? chosenLocalAccountId - : undefined, + upgradingId, offBudget, }), ); @@ -96,11 +98,7 @@ export function SelectLinkedAccountsModal({ linkAccount({ requisitionId, account: externalAccount, - upgradingId: - chosenLocalAccountId !== addOnBudgetAccountOption.id && - chosenLocalAccountId !== addOffBudgetAccountOption.id - ? chosenLocalAccountId - : undefined, + upgradingId, offBudget, }), ); diff --git a/packages/loot-core/bin/build-api b/packages/loot-core/bin/build-api index 577e6342332..1d2a25a5062 100755 --- a/packages/loot-core/bin/build-api +++ b/packages/loot-core/bin/build-api @@ -9,7 +9,7 @@ yarn tsc -p tsconfig.api.json --outDir ../api/@types/loot-core/ # Copy existing handwritten .d.ts files, as tsc doesn't move them for us dest="../../api/@types/loot-core" cd src -find . -type f -name "*.d.ts" | while read -r f +/usr/bin/find . -type f -name "*.d.ts" | while read -r f do d=$(dirname "${f}") d="${dest}/${d}" diff --git a/packages/loot-core/bin/build-browser b/packages/loot-core/bin/build-browser index 56caa4d9a77..6314a289aba 100755 --- a/packages/loot-core/bin/build-browser +++ b/packages/loot-core/bin/build-browser @@ -10,7 +10,7 @@ mkdir -p "$DATA_DIR" "$ROOT"/copy-migrations "$DATA_DIR" cd "$DATA_DIR" -find * -type f | sort > ../data-file-index.txt +/usr/bin/find * -type f | sort > ../data-file-index.txt cd "$ROOT" OUTPUT_HASH="[contenthash]" diff --git a/packages/loot-core/src/server/accounts/app.ts b/packages/loot-core/src/server/accounts/app.ts index c9a8ca3c377..ee451fcc532 100644 --- a/packages/loot-core/src/server/accounts/app.ts +++ b/packages/loot-core/src/server/accounts/app.ts @@ -423,7 +423,9 @@ async function checkSecret(name: string) { try { return await get(serverConfig.BASE_SERVER + '/secret/' + name, { - 'X-ACTUAL-TOKEN': userToken, + headers: { + 'X-ACTUAL-TOKEN': userToken, + }, }); } catch (error) { console.error(error); diff --git a/packages/loot-core/src/server/post.ts b/packages/loot-core/src/server/post.ts index 90533596be7..02c75338175 100644 --- a/packages/loot-core/src/server/post.ts +++ b/packages/loot-core/src/server/post.ts @@ -5,31 +5,35 @@ import { PostError } from './errors'; import * as Platform from './platform'; function throwIfNot200(res: Response, text: string) { - if (res.status !== 200) { - if (res.status === 500) { - throw new PostError(res.status === 500 ? 'internal' : text); - } - - const contentType = res.headers.get('Content-Type'); - if (contentType.toLowerCase().indexOf('application/json') !== -1) { - const json = JSON.parse(text); - throw new PostError(json.reason); - } - - // Actual Sync Server may be exposed via a tunnel (e.g. ngrok). Tunnel errors should be treated as network errors. - const tunnelErrorHeaders = ['ngrok-error-code']; - const tunnelError = tunnelErrorHeaders.some(header => - res.headers.has(header), - ); + //there are a few places where we return 204 (success, but no content) + //these should probably also not throw (along with other 2xx codes) + if (Math.floor(res.status / 100) === 2) { + return; + } + + if (res.status === 500) { + throw new PostError('internal'); + } - if (tunnelError) { - // Tunnel errors are present when the tunnel is active and the server is not reachable e.g. server is offline - // When we experience a tunnel error we treat it as a network failure - throw new PostError('network-failure'); - } + const contentType = res.headers.get('Content-Type') ?? ''; + if (contentType.toLowerCase().indexOf('application/json') !== -1) { + const json = JSON.parse(text); + throw new PostError(json.reason); + } + + // Actual Sync Server may be exposed via a tunnel (e.g. ngrok). Tunnel errors should be treated as network errors. + const tunnelErrorHeaders = ['ngrok-error-code']; + const tunnelError = tunnelErrorHeaders.some(header => + res.headers.has(header), + ); - throw new PostError(text); + if (tunnelError) { + // Tunnel errors are present when the tunnel is active and the server is not reachable e.g. server is offline + // When we experience a tunnel error we treat it as a network failure + throw new PostError('network-failure'); } + + throw new PostError(text); } export async function post( diff --git a/upcoming-release-notes/4455.md b/upcoming-release-notes/4455.md new file mode 100644 index 00000000000..b168c180532 --- /dev/null +++ b/upcoming-release-notes/4455.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [rugulous] +--- + +Allow building on Windows, checking for secrets, and tidy up a few duplications along the way!