Remove isGlobal preference functionality (#6049)

This commit is contained in:
Matiss Janis Aboltins
2025-11-01 14:18:08 +00:00
committed by GitHub
parent 7983ee45e1
commit 0cac66b203
7 changed files with 11 additions and 19 deletions

View File

@@ -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' }}>

View File

@@ -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]);

View File

@@ -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,
}),
),
);

View File

@@ -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

View File

@@ -212,7 +212,6 @@ export type DbTransactionFilter = {
export type DbPreference = {
id: string;
value: string;
isGlobal?: 1 | 0;
};
export type DbCustomReport = {

View File

@@ -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 }),
});
}

View File

@@ -0,0 +1,7 @@
---
category: Maintenance
authors: [MatissJanis]
---
Remove `isGlobal` preference functionality from the preferences and synced preferences system.