mirror of
https://github.com/actualbudget/actual.git
synced 2026-04-28 18:40:34 -05:00
Remove isGlobal preference functionality (#6049)
This commit is contained in:
committed by
GitHub
parent
7983ee45e1
commit
0cac66b203
@@ -83,7 +83,7 @@ function GlobalFeatureToggle({
|
||||
error,
|
||||
children,
|
||||
}: GlobalFeatureToggleProps) {
|
||||
const [enabled, setEnabled] = useSyncedPref(prefName, { isGlobal: true });
|
||||
const [enabled, setEnabled] = useSyncedPref(prefName);
|
||||
|
||||
return (
|
||||
<label style={{ display: 'flex' }}>
|
||||
|
||||
@@ -11,7 +11,6 @@ type SetSyncedPrefAction<K extends keyof SyncedPrefs> = (
|
||||
|
||||
export function useSyncedPref<K extends keyof SyncedPrefs>(
|
||||
prefName: K,
|
||||
options?: { isGlobal?: boolean },
|
||||
): [SyncedPrefs[K], SetSyncedPrefAction<K>] {
|
||||
const dispatch = useDispatch();
|
||||
const setPref = useCallback<SetSyncedPrefAction<K>>(
|
||||
@@ -19,11 +18,10 @@ export function useSyncedPref<K extends keyof SyncedPrefs>(
|
||||
dispatch(
|
||||
saveSyncedPrefs({
|
||||
prefs: { [prefName]: value },
|
||||
isGlobal: options?.isGlobal,
|
||||
}),
|
||||
);
|
||||
},
|
||||
[prefName, dispatch, options?.isGlobal],
|
||||
[prefName, dispatch],
|
||||
);
|
||||
const pref = useSelector(state => state.prefs.synced[prefName]);
|
||||
|
||||
|
||||
@@ -108,18 +108,16 @@ export const saveGlobalPrefs = createAppAsyncThunk(
|
||||
|
||||
type SaveSyncedPrefsPayload = {
|
||||
prefs: SyncedPrefs;
|
||||
isGlobal?: boolean;
|
||||
};
|
||||
|
||||
export const saveSyncedPrefs = createAppAsyncThunk(
|
||||
`${sliceName}/saveSyncedPrefs`,
|
||||
async ({ prefs, isGlobal }: SaveSyncedPrefsPayload, { dispatch }) => {
|
||||
async ({ prefs }: SaveSyncedPrefsPayload, { dispatch }) => {
|
||||
await Promise.all(
|
||||
Object.entries(prefs).map(([prefName, value]) =>
|
||||
send('preferences/save', {
|
||||
id: prefName as keyof SyncedPrefs,
|
||||
value,
|
||||
isGlobal,
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,8 +1 @@
|
||||
-- Migration: Add isGlobal column to preferences table
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
ALTER TABLE preferences ADD COLUMN isGlobal INTEGER DEFAULT 0;
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
-- Migration removed because it was not needed
|
||||
|
||||
@@ -212,7 +212,6 @@ export type DbTransactionFilter = {
|
||||
export type DbPreference = {
|
||||
id: string;
|
||||
value: string;
|
||||
isGlobal?: 1 | 0;
|
||||
};
|
||||
|
||||
export type DbCustomReport = {
|
||||
|
||||
@@ -39,11 +39,9 @@ app.method('load-prefs', loadMetadataPrefs);
|
||||
async function saveSyncedPrefs({
|
||||
id,
|
||||
value,
|
||||
isGlobal,
|
||||
}: {
|
||||
id: keyof SyncedPrefs;
|
||||
value: string | undefined;
|
||||
isGlobal?: boolean;
|
||||
}) {
|
||||
if (!id) {
|
||||
return;
|
||||
@@ -52,7 +50,6 @@ async function saveSyncedPrefs({
|
||||
await db.update('preferences', {
|
||||
id,
|
||||
value,
|
||||
...(isGlobal !== undefined && { isGlobal: isGlobal ? 1 : 0 }),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
7
upcoming-release-notes/6049.md
Normal file
7
upcoming-release-notes/6049.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
category: Maintenance
|
||||
authors: [MatissJanis]
|
||||
---
|
||||
|
||||
Remove `isGlobal` preference functionality from the preferences and synced preferences system.
|
||||
|
||||
Reference in New Issue
Block a user