fix: sync cloud preference storage mode (#1058)

This commit is contained in:
ZacharyZcR
2026-07-16 11:52:26 +08:00
committed by GitHub
parent 7da5c24457
commit 84d4e9522a
2 changed files with 14 additions and 2 deletions
+11 -1
View File
@@ -445,7 +445,10 @@ export function UserProfilePanel({
hiddenRailTabs?: string | null;
statusColorScheme?: string | null;
};
onPrefsChange?: (prefs: { reopenTabsOnLogin: boolean }) => void;
onPrefsChange?: (prefs: {
reopenTabsOnLogin?: boolean;
storageMode?: "local" | "cloud";
}) => void;
}) {
const { t } = useTranslation();
const themeLabel: Record<ThemeId, string> = {
@@ -522,6 +525,12 @@ export function UserProfilePanel({
userPrefs?.storageMode === "cloud" ? "cloud" : "local",
);
useEffect(() => {
if (userPrefs?.storageMode) {
setStorageMode(userPrefs.storageMode === "cloud" ? "cloud" : "local");
}
}, [userPrefs?.storageMode]);
// Settings toggles — all backed by localStorage
const [commandAutocomplete, setCommandAutocomplete] = useState(
() => localStorage.getItem("commandAutocomplete") === "true",
@@ -623,6 +632,7 @@ export function UserProfilePanel({
async function handleStorageModeChange(mode: "local" | "cloud") {
setStorageMode(mode);
onPrefsChange?.({ storageMode: mode });
if (mode === "cloud") {
// Snapshot current browser localStorage values so any tab can restore them later
const SNAPSHOT_KEYS = [