mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 20:44:32 -05:00
♻️ (synced-prefs) remove no longer necessary migration (#3718)
* ♻️ (synced-prefs) remove no longer necessary migration Closes #3551 * Release notes
This commit is contained in:
committed by
GitHub
parent
1b883aa0ab
commit
34f3ccacf6
@@ -1,5 +1,3 @@
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import { useLocalStorage } from 'usehooks-ts';
|
||||
|
||||
import { type LocalPrefs } from 'loot-core/src/types/prefs';
|
||||
@@ -18,25 +16,8 @@ export function useLocalPref<K extends keyof LocalPrefs>(
|
||||
): [LocalPrefs[K], SetLocalPrefAction<K>] {
|
||||
const [budgetId] = useMetadataPref('id');
|
||||
|
||||
const [value, setValue] = useLocalStorage<LocalPrefs[K]>(
|
||||
`${budgetId}-${prefName}`,
|
||||
undefined,
|
||||
{
|
||||
deserializer: JSON.parse,
|
||||
serializer: JSON.stringify,
|
||||
},
|
||||
);
|
||||
|
||||
// Migrate from old pref storage location (metadata.json) to local storage
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const [metadataPref] = useMetadataPref(prefName as any);
|
||||
useEffect(() => {
|
||||
if (value !== undefined || metadataPref === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
setValue(metadataPref);
|
||||
}, [value, metadataPref, setValue]);
|
||||
|
||||
return [value, setValue];
|
||||
return useLocalStorage<LocalPrefs[K]>(`${budgetId}-${prefName}`, undefined, {
|
||||
deserializer: JSON.parse,
|
||||
serializer: JSON.stringify,
|
||||
});
|
||||
}
|
||||
|
||||
6
upcoming-release-notes/3718.md
Normal file
6
upcoming-release-notes/3718.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Maintenance
|
||||
authors: [MatissJanis]
|
||||
---
|
||||
|
||||
SyncedPrefs: remove no longer necessary migration.
|
||||
Reference in New Issue
Block a user