-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ (synced-prefs) refactor ImportedTransactions usage of prefs (#3408)
- Loading branch information
1 parent
8498d7f
commit 7231959
Showing
3 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useCallback } from 'react'; | ||
import { useDispatch } from 'react-redux'; | ||
|
||
import { savePrefs } from 'loot-core/client/actions'; | ||
import { type SyncedPrefs } from 'loot-core/src/types/prefs'; | ||
|
||
import { useLocalPrefs } from './useLocalPrefs'; | ||
|
||
type SetSyncedPrefsAction = (value: Partial<SyncedPrefs>) => void; | ||
|
||
export function useSyncedPrefs(): [SyncedPrefs, SetSyncedPrefsAction] { | ||
// TODO: implement real logic (follow-up PR) | ||
const dispatch = useDispatch(); | ||
const setPrefs = useCallback<SetSyncedPrefsAction>( | ||
newPrefs => { | ||
dispatch(savePrefs(newPrefs)); | ||
}, | ||
[dispatch], | ||
); | ||
|
||
return [useLocalPrefs(), setPrefs]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
category: Maintenance | ||
authors: [MatissJanis] | ||
--- | ||
|
||
SyncedPrefs: refactor `ImportTransactions` usage of prefs to use a common hook. |