diff --git a/packages/desktop-client/src/components/accounts/Header.jsx b/packages/desktop-client/src/components/accounts/Header.jsx index da5608da11a42848a30e408f46d0f2062abac89a..3c4f79a78a64bffd83bf6d5609309e216d623ad1 100644 --- a/packages/desktop-client/src/components/accounts/Header.jsx +++ b/packages/desktop-client/src/components/accounts/Header.jsx @@ -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() { @@ -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 @@ -222,7 +229,7 @@ export function AccountHeader({ } style={{ marginRight: 4 }} />{' '} - Sync + {isServerOffline ? 'Sync offline' : 'Sync'} </> ) : ( <> diff --git a/packages/loot-core/migrations/1704572023730_add_account_sync_source.sql b/packages/loot-core/migrations/1704572023730_add_account_sync_source.sql index 3aae8da909ef0f62ce3f63cdd5a4f1487001b8b4..7af2400895af6710212cb3ce0423431270b35fb0 100644 --- a/packages/loot-core/migrations/1704572023730_add_account_sync_source.sql +++ b/packages/loot-core/migrations/1704572023730_add_account_sync_source.sql @@ -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; diff --git a/packages/loot-core/migrations/1704572023731_add_missing_goCardless_sync_source.sql b/packages/loot-core/migrations/1704572023731_add_missing_goCardless_sync_source.sql new file mode 100644 index 0000000000000000000000000000000000000000..49aa4cb85ca77c76e70a9590ad704384942e1d81 --- /dev/null +++ b/packages/loot-core/migrations/1704572023731_add_missing_goCardless_sync_source.sql @@ -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; diff --git a/upcoming-release-notes/2308.md b/upcoming-release-notes/2308.md new file mode 100644 index 0000000000000000000000000000000000000000..bba8f394711f991100fd4f84b8b9c3aa80597000 --- /dev/null +++ b/upcoming-release-notes/2308.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [MatissJanis] +--- + +Fix GoCardless bank sync breaking after a flaky SimpleFin db migration.