mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-07-16 05:13:36 +00:00
fix: sync cloud preference storage mode (#1058)
This commit is contained in:
+3
-1
@@ -1683,7 +1683,9 @@ export function AppShell({
|
||||
onLogout={onLogout}
|
||||
onChangeServer={onChangeServer}
|
||||
userPrefs={userPrefs}
|
||||
onPrefsChange={setUserPrefs}
|
||||
onPrefsChange={(updates) =>
|
||||
setUserPrefs((current) => ({ ...current, ...updates }))
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user