Skip to content

PostgreSQL backup tool with Point-In-Time-Recovery and restore verification

FIX (mobile): Do not preselect card on mobile for DBs, notifiers and storanges

Rostislav Dugin8db83d40d551
diff --git a/frontend/src/features/databases/ui/DatabasesComponent.tsx b/frontend/src/features/databases/ui/DatabasesComponent.tsx
index 123b549e..20886152 100644
--- a/frontend/src/features/databases/ui/DatabasesComponent.tsx
+++ b/frontend/src/features/databases/ui/DatabasesComponent.tsx
@@ -47,7 +47,7 @@ export const DatabasesComponent = ({ contentHeight, workspace, isCanManageDBs }:
if (selectDatabaseId) {
updateSelectedDatabaseId(selectDatabaseId);
} else if (!selectedDatabaseId && !isSilent && !isMobile) {
- // On desktop, auto-select a database; on mobile, keep it unselected
+ // On desktop, auto-select a database; on mobile, keep it unselected to show the list first
const savedDatabaseId = localStorage.getItem(
`${SELECTED_DATABASE_STORAGE_KEY}_${workspace.id}`,
);
diff --git a/frontend/src/features/notifiers/ui/NotifiersComponent.tsx b/frontend/src/features/notifiers/ui/NotifiersComponent.tsx
index d6d6583a..0fcebeb2 100644
--- a/frontend/src/features/notifiers/ui/NotifiersComponent.tsx
+++ b/frontend/src/features/notifiers/ui/NotifiersComponent.tsx
@@ -47,7 +47,7 @@ export const NotifiersComponent = ({ contentHeight, workspace, isCanManageNotifi
if (selectNotifierId) {
updateSelectedNotifierId(selectNotifierId);
} else if (!selectedNotifierId && !isSilent && !isMobile) {
- // On desktop, auto-select a notifier; on mobile, keep it unselected
+ // On desktop, auto-select a notifier; on mobile, keep it unselected to show the list first
const savedNotifierId = localStorage.getItem(
`${SELECTED_NOTIFIER_STORAGE_KEY}_${workspace.id}`,
);
diff --git a/frontend/src/features/storages/ui/StoragesComponent.tsx b/frontend/src/features/storages/ui/StoragesComponent.tsx
index 4ddc810d..03c0451f 100644
--- a/frontend/src/features/storages/ui/StoragesComponent.tsx
+++ b/frontend/src/features/storages/ui/StoragesComponent.tsx
@@ -34,15 +34,19 @@ export const StoragesComponent = ({ contentHeight, workspace, isCanManageStorage
}
};
- const loadStorages = () => {
- setIsLoading(true);
+ const loadStorages = (isSilent = false, selectStorageId?: string) => {
+ if (!isSilent) {
+ setIsLoading(true);
+ }
storageApi
.getStorages(workspace.id)
.then((storages: Storage[]) => {
setStorages(storages);
- if (!selectedStorageId && !isMobile) {
- // On desktop, auto-select a storage; on mobile, keep it unselected
+ if (selectStorageId) {
+ updateSelectedStorageId(selectStorageId);
+ } else if (!selectedStorageId && !isSilent && !isMobile) {
+ // On desktop, auto-select a storage; on mobile, keep it unselected to show the list first
const savedStorageId = localStorage.getItem(
`${SELECTED_STORAGE_STORAGE_KEY}_${workspace.id}`,
);
@@ -154,8 +158,8 @@ export const StoragesComponent = ({ contentHeight, workspace, isCanManageStorage
isShowName
isShowClose={false}
onClose={() => setIsShowAddStorage(false)}
- onChanged={() => {
- loadStorages();
+ onChanged={(storage) => {
+ loadStorages(false, storage.id);
setIsShowAddStorage(false);
}}
/>
diff --git a/frontend/src/shared/hooks/useIsMobile.tsx b/frontend/src/shared/hooks/useIsMobile.tsx
index f78ac769..5aff76b6 100644
--- a/frontend/src/shared/hooks/useIsMobile.tsx
+++ b/frontend/src/shared/hooks/useIsMobile.tsx
@@ -7,14 +7,14 @@ import { useEffect, useState } from 'react';
* @returns isMobile boolean
*/
export function useIsMobile(): boolean {
- const [isMobile, setIsMobile] = useState<boolean>(false);
+ // Initialize with actual value to avoid race conditions
+ const [isMobile, setIsMobile] = useState<boolean>(() => window.innerWidth <= 768);
useEffect(() => {
const updateIsMobile = () => {
setIsMobile(window.innerWidth <= 768);
};
- updateIsMobile(); // Set initial value
window.addEventListener('resize', updateIsMobile);
return () => {