diff --git a/package.json b/package.json index 4e40253..02b57a7 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "budgetzen-desktop", "productName": "Budget Zen", - "version": "1.2.1", - "buildHash": "rfydHa5p", + "version": "1.3.0", + "buildHash": "Hx7BNMQB", "description": "Desktop app for Budget Zen", "main": ".webpack/main", "scripts": { @@ -38,7 +38,7 @@ "appBundleId": "com.emotionloop.BudgetsCalm-macOS", "appCategoryType": "public.app-category.finance", "appCopyright": "Bruno Bernardino", - "buildVersion": 12 + "buildVersion": 13 }, "makers": [ { diff --git a/src/components/SegmentedControl.tsx b/src/components/SegmentedControl.tsx index 85ed087..175cb6f 100644 --- a/src/components/SegmentedControl.tsx +++ b/src/components/SegmentedControl.tsx @@ -33,7 +33,7 @@ const Segment = styled.button` selected ? colors().primaryButtonBackground : 'transparent'}; padding: 10px; border-radius: 5px; - min-width: 50%; + min-width: 33%; color: ${({ selected }) => selected ? colors().primaryButtonText : 'inherit'}; font-size: ${fontSizes.button}px; diff --git a/src/hocs/withLayout.tsx b/src/hocs/withLayout.tsx index 3efb49a..0d4e836 100644 --- a/src/hocs/withLayout.tsx +++ b/src/hocs/withLayout.tsx @@ -21,7 +21,7 @@ interface LayoutState { } const notificationTimeoutInMS = 10 * 1000; -const reloadTimeoutInMS = 60 * 1000; +const reloadTimeoutInMS = 15 * 60 * 1000; const withLayout: any = (WrappedComponent: any, sharedOptions: any) => { class LayoutComponent extends Component { diff --git a/src/lib/db.ts b/src/lib/db.ts index 482bf88..6e39095 100644 --- a/src/lib/db.ts +++ b/src/lib/db.ts @@ -14,6 +14,10 @@ import { sortByDate, sortByName, splitArrayInChunks } from './utils'; import * as T from './types'; interface DB { + _hasFinishedFirstSync: { + budgets: boolean; + expenses: boolean; + }; updateSyncDate: (alive: boolean) => Promise; connect: () => Promise; fetchBudgets: (db: RxDatabase, month: string) => Promise; @@ -103,6 +107,10 @@ const localDbName = 'localdb_budgetscalm_v0'; const store = new Store(); const DB: DB = { + _hasFinishedFirstSync: { + budgets: false, + expenses: false, + }, updateSyncDate: async (alive = true) => { const lastSyncDate = moment().format('YYYY-MM-DD HH:mm:ss'); if (alive) { @@ -150,6 +158,15 @@ const DB: DB = { expensesSync.change$.subscribe((change) => DB.updateSyncDate(change.ok), ); + budgetsSync.complete$.subscribe(() => { + DB._hasFinishedFirstSync.budgets = true; + }); + expensesSync.complete$.subscribe(() => { + DB._hasFinishedFirstSync.expenses = true; + }); + } else { + DB._hasFinishedFirstSync.budgets = true; + DB._hasFinishedFirstSync.expenses = true; } return db; @@ -383,6 +400,14 @@ const DB: DB = { await existingExpense.remove(); }, copyBudgets: async (db, originalMonth, destinationMonth) => { + // Don't copy anything until we're done with the first sync + if ( + !DB._hasFinishedFirstSync.expenses || + !DB._hasFinishedFirstSync.budgets + ) { + return; + } + const originalBudgets = await DB.fetchBudgets(db, originalMonth); const destinationBudgets = originalBudgets.map((budget) => { const newBudget: T.Budget = { ...budget }; diff --git a/src/lib/utils.test.ts b/src/lib/utils.test.ts index 3f77a9c..624a54b 100644 --- a/src/lib/utils.test.ts +++ b/src/lib/utils.test.ts @@ -9,6 +9,9 @@ describe('lib/utils', () => { { currency: 'EUR', number: 900.999, expected: '€901' }, { currency: 'EUR', number: 900.991, expected: '€900.99' }, { currency: 'USD', number: 50.11, expected: '$50.11' }, + { currency: 'GBP', number: 900.999, expected: '£901' }, + { currency: 'GBP', number: 900.991, expected: '£900.99' }, + { currency: 'GBP', number: 50.11, expected: '£50.11' }, ]; for (const test of tests) { diff --git a/src/windows/main/settings.tsx b/src/windows/main/settings.tsx index 462264b..31a4cd0 100644 --- a/src/windows/main/settings.tsx +++ b/src/windows/main/settings.tsx @@ -115,8 +115,8 @@ const Code = styled.code` line-height: 1em; `; -const currencyLabels = ['$', '€']; -const currencyValues = ['USD', 'EUR']; +const currencyLabels = ['$', '€', '£']; +const currencyValues = ['USD', 'EUR', 'GBP']; class Settings extends Component { constructor(props: SettingsProps) { @@ -197,6 +197,10 @@ class Settings extends Component { currency, } = this.state; + const selectedCurrencyIndex = currencyValues.findIndex( + (_currency) => currency === _currency, + ); + return ( <> { { this.setState( {