Skip to content

Commit

Permalink
🐛 (goCardless) patch incomplete migration (actualbudget#2308)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatissJanis authored Feb 1, 2024
1 parent 6b570da commit 9e9c3f9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
15 changes: 11 additions & 4 deletions packages/desktop-client/src/components/accounts/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,14 @@ export function AccountHeader({
const [menuOpen, setMenuOpen] = useState(false);
const searchInput = useRef(null);
const splitsExpanded = useSplitsExpanded();
const syncServerStatus = useSyncServerStatus();
const isUsingServer = syncServerStatus !== 'no-server';
const isServerOffline = syncServerStatus === 'offline';

let canSync = account && account.account_id;
let canSync = account && account.account_id && isUsingServer;
if (!account) {
// All accounts - check for any syncable account
canSync = !!accounts.find(account => !!account.account_id);
canSync = !!accounts.find(account => !!account.account_id) && isUsingServer;
}

function onToggleSplits() {
Expand Down Expand Up @@ -210,7 +213,11 @@ export function AccountHeader({
style={{ marginTop: 12 }}
>
{((account && !account.closed) || canSync) && (
<Button type="bare" onClick={canSync ? onSync : onImport}>
<Button
type="bare"
onClick={canSync ? onSync : onImport}
disabled={canSync && isServerOffline}
>
{canSync ? (
<>
<AnimatedRefresh
Expand All @@ -222,7 +229,7 @@ export function AccountHeader({
}
style={{ marginRight: 4 }}
/>{' '}
Sync
{isServerOffline ? 'Sync offline' : 'Sync'}
</>
) : (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,4 @@ BEGIN TRANSACTION;

ALTER TABLE accounts ADD COLUMN account_sync_source TEXT;

UPDATE accounts SET
account_sync_source = CASE
WHEN account_id THEN 'goCardless'
ELSE NULL
END;

COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
BEGIN TRANSACTION;

UPDATE accounts
SET
account_sync_source = 'goCardless'
WHERE account_id IS NOT NULL
AND account_sync_source IS NULL;

COMMIT;
6 changes: 6 additions & 0 deletions upcoming-release-notes/2308.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [MatissJanis]
---

Fix GoCardless bank sync breaking after a flaky SimpleFin db migration.

0 comments on commit 9e9c3f9

Please sign in to comment.