Skip to content

Commit

Permalink
save csv inOutMode settings (#3543)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-fidd authored Oct 10, 2024
1 parent 0b31556 commit 9f27948
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ export function ImportTransactionsModal({ options }) {
const [filetype, setFileType] = useState(null);
const [fieldMappings, setFieldMappings] = useState(null);
const [splitMode, setSplitMode] = useState(false);
const [inOutMode, setInOutMode] = useState(false);
const [outValue, setOutValue] = useState('');
const [flipAmount, setFlipAmount] = useState(false);
const [multiplierEnabled, setMultiplierEnabled] = useState(false);
const [reconcile, setReconcile] = useState(true);
Expand All @@ -170,6 +168,12 @@ export function ImportTransactionsModal({ options }) {
const [skipLines, setSkipLines] = useState(
parseInt(prefs[`csv-skip-lines-${accountId}`], 10) || 0,
);
const [inOutMode, setInOutMode] = useState(
String(prefs[`csv-in-out-mode-${accountId}`]) === 'true',
);
const [outValue, setOutValue] = useState(
prefs[`csv-out-value-${accountId}`] ?? '',
);
const [hasHeaderRow, setHasHeaderRow] = useState(
String(prefs[`csv-has-header-${accountId}`]) !== 'false',
);
Expand Down Expand Up @@ -638,6 +642,8 @@ export function ImportTransactionsModal({ options }) {
savePrefs({ [`csv-delimiter-${accountId}`]: delimiter });
savePrefs({ [`csv-has-header-${accountId}`]: String(hasHeaderRow) });
savePrefs({ [`csv-skip-lines-${accountId}`]: String(skipLines) });
savePrefs({ [`csv-in-out-mode-${accountId}`]: String(inOutMode) });
savePrefs({ [`csv-out-value-${accountId}`]: String(outValue) });
}

if (filetype === 'csv' || filetype === 'qif') {
Expand Down
2 changes: 2 additions & 0 deletions packages/loot-core/src/types/prefs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export type SyncedPrefs = Partial<
| `csv-mappings-${string}`
| `csv-delimiter-${string}`
| `csv-skip-lines-${string}`
| `csv-in-out-mode-${string}`
| `csv-out-value-${string}`
| `csv-has-header-${string}`
| `ofx-fallback-missing-payee-${string}`
| `flip-amount-${string}-${'csv' | 'qif'}`
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3543.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [matt-fidd]
---

Save in/out mode settings between CSV imports

0 comments on commit 9f27948

Please sign in to comment.