diff --git a/VERSION b/VERSION index a4c853e..133cad2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.4.2 +6.4.3 diff --git a/play-life-web/package.json b/play-life-web/package.json index 878bd92..66e551e 100644 --- a/play-life-web/package.json +++ b/play-life-web/package.json @@ -1,6 +1,6 @@ { "name": "play-life-web", - "version": "6.4.2", + "version": "6.4.3", "type": "module", "scripts": { "dev": "vite", diff --git a/play-life-web/src/components/ShoppingList.jsx b/play-life-web/src/components/ShoppingList.jsx index 85a4f47..d00e785 100644 --- a/play-life-web/src/components/ShoppingList.jsx +++ b/play-life-web/src/components/ShoppingList.jsx @@ -110,10 +110,21 @@ function ShoppingList({ onNavigate, refreshTrigger = 0, isActive = false, initia return null } + const hasBoardsCache = () => { + try { + const cached = localStorage.getItem(BOARDS_CACHE_KEY) + if (cached) { + const data = JSON.parse(cached) + return !!(data.boards && data.boards.length >= 0) + } + } catch (err) {} + return false + } + const [selectedBoardId, setSelectedBoardIdState] = useState(getInitialBoardId) const [items, setItems] = useState([]) const [loading, setLoading] = useState(true) - const [boardsLoading, setBoardsLoading] = useState(true) + const [boardsLoading, setBoardsLoading] = useState(!hasBoardsCache()) const [error, setError] = useState('') const [selectedItemForDetail, setSelectedItemForDetail] = useState(null) const [selectedItemForPostpone, setSelectedItemForPostpone] = useState(null) @@ -142,8 +153,8 @@ function ShoppingList({ onNavigate, refreshTrigger = 0, isActive = false, initia } // Загрузка досок - const fetchBoards = async () => { - setBoardsLoading(true) + const fetchBoards = async (showLoading = true) => { + if (showLoading) setBoardsLoading(true) try { const res = await authFetch('/api/shopping/boards') if (res.ok) { @@ -218,7 +229,8 @@ function ShoppingList({ onNavigate, refreshTrigger = 0, isActive = false, initia // Начальная загрузка useEffect(() => { - fetchBoards() + const hasCache = hasBoardsCache() + fetchBoards(!hasCache) initialFetchDoneRef.current = true }, []) @@ -235,7 +247,7 @@ function ShoppingList({ onNavigate, refreshTrigger = 0, isActive = false, initia // Рефреш при возврате на таб useEffect(() => { if (isActive && !prevIsActiveRef.current && initialFetchDoneRef.current) { - fetchBoards() + fetchBoards(false) if (selectedBoardId) fetchItems(selectedBoardId) } prevIsActiveRef.current = isActive @@ -244,7 +256,7 @@ function ShoppingList({ onNavigate, refreshTrigger = 0, isActive = false, initia // Рефреш по триггеру useEffect(() => { if (refreshTrigger > 0) { - fetchBoards() + fetchBoards(false) if (selectedBoardId) fetchItems(selectedBoardId) } }, [refreshTrigger])