diff --git a/VERSION b/VERSION index e411592..b22e754 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.6.3 +6.6.4 diff --git a/play-life-web/package.json b/play-life-web/package.json index 33217ad..64353fc 100644 --- a/play-life-web/package.json +++ b/play-life-web/package.json @@ -1,6 +1,6 @@ { "name": "play-life-web", - "version": "6.6.3", + "version": "6.6.4", "type": "module", "scripts": { "dev": "vite", diff --git a/play-life-web/src/components/WishlistDetail.jsx b/play-life-web/src/components/WishlistDetail.jsx index f86d186..324c1c3 100644 --- a/play-life-web/src/components/WishlistDetail.jsx +++ b/play-life-web/src/components/WishlistDetail.jsx @@ -75,10 +75,7 @@ function WishlistDetail({ wishlistId, onNavigate, onRefresh, boardId, onClose, p if (onRefresh) { onRefresh() } - if (onNavigate) { - onNavigate('wishlist') - } - onClose?.() + closeWithHistoryCleanup() } catch (err) { console.error('Error completing wishlist:', err) setToastMessage({ text: err.message || 'Ошибка при завершении', type: 'error' }) @@ -103,10 +100,7 @@ function WishlistDetail({ wishlistId, onNavigate, onRefresh, boardId, onClose, p if (onRefresh) { onRefresh() } - if (onNavigate) { - onNavigate('wishlist') - } - onClose?.() + closeWithHistoryCleanup() } catch (err) { console.error('Error rejecting wishlist:', err) setToastMessage({ text: err.message || 'Ошибка при отклонении', type: 'error' }) @@ -131,8 +125,7 @@ function WishlistDetail({ wishlistId, onNavigate, onRefresh, boardId, onClose, p if (onRefresh) { onRefresh() } - fetchWishlistDetail() - onClose?.() + closeWithHistoryCleanup() } catch (err) { console.error('Error uncompleting wishlist:', err) setToastMessage({ text: err.message || 'Ошибка при возобновлении желания', type: 'error' }) @@ -161,9 +154,7 @@ function WishlistDetail({ wishlistId, onNavigate, onRefresh, boardId, onClose, p if (onRefresh) { onRefresh() } - if (onNavigate) { - onNavigate('wishlist') - } + closeWithHistoryCleanup() } catch (err) { console.error('Error deleting wishlist:', err) setToastMessage({ text: err.message || 'Ошибка при удалении', type: 'error' }) @@ -341,6 +332,28 @@ function WishlistDetail({ wishlistId, onNavigate, onRefresh, boardId, onClose, p } }, [wishlistId, selectedTaskForDetail, onClose, onNavigate, previousTab, boardId]) + // Закрытие модального окна с очисткой записей из истории + // Используется при программном закрытии (завершение, отклонение, возобновление) + const closeWithHistoryCleanup = () => { + // Считаем сколько записей нужно убрать из истории + let stepsBack = 0 + if (historyPushedForTaskRef.current) stepsBack++ + if (historyPushedForWishlistRef.current) stepsBack++ + + // Сбрасываем refs чтобы popstate handler не реагировал + historyPushedForTaskRef.current = false + historyPushedForWishlistRef.current = false + selectedTaskForDetailRef.current = null + wishlistIdRef.current = null + setSelectedTaskForDetail(null) + + // Убираем записи из истории + if (stepsBack > 0) { + window.history.go(-stepsBack) + } + onClose?.() + } + const handleClose = () => { // Если была добавлена запись в историю, удаляем её через history.back() // Обработчик popstate закроет модальное окно @@ -371,10 +384,7 @@ function WishlistDetail({ wishlistId, onNavigate, onRefresh, boardId, onClose, p if (onRefresh) { onRefresh() } - if (onNavigate) { - onNavigate('wishlist') - } - onClose?.() + closeWithHistoryCleanup() } const handleDeleteTask = async (e) => {