diff --git a/.gitignore b/.gitignore index 150d81008..57cb15ccf 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ storage build/* config/local.* config/docker.* +config/dev.* todo.md startDB.bat diff --git a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.less b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.less index aa7625301..4b3751ca3 100644 --- a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.less +++ b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.less @@ -335,7 +335,7 @@ } //these media queries are just for the list layout and could be moved inside it, not sure it is a good idea -@media screen and (max-width : 1400px) { +@container (max-width : 1400px) { .brewCollection .brewGroup.list { .brewItem:not(.detailsOpen) { .info { @@ -361,7 +361,7 @@ } } } -@media screen and (max-width : 1200px) { +@container (max-width : 1200px) { .brewCollection .brewGroup.list { .brewItem:not(.detailsOpen) { grid-template-columns : 35% 3fr 150px; @@ -388,7 +388,7 @@ } } } -@media screen and (max-width : 800px) { +@container (max-width : 800px) { .brewCollection .brewGroup.list { .brewItem:not(.detailsOpen) { .info { @@ -443,7 +443,7 @@ } } } -@media screen and (max-width : 650px) { +@container (max-width : 650px) { .brewCollection .brewGroup.list { .brewItem:not(.detailsOpen) { grid-template-columns : 3fr 2fr; diff --git a/client/homebrew/pages/basePages/listPage/listPage.less b/client/homebrew/pages/basePages/listPage/listPage.less index 389c83abf..7a9286914 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.less +++ b/client/homebrew/pages/basePages/listPage/listPage.less @@ -21,15 +21,16 @@ .sitePage.listPage { --bg-clr : white; + container-type: inline-size; .content { - padding : clamp(20px, 5vh, 200px) clamp(20px, 20vw, 200px); + padding : clamp(20px, 5vh, 200px) clamp(20px, 20cqi, 200px); overflow-y : scroll; scrollbar-gutter : stable; - @media screen and (max-width : 1200px) { - padding : clamp(20px, 5vh, 200px) clamp(20px, 10vw, 200px); + @container (max-width : 1200px) { + padding : clamp(20px, 5vh, 200px) clamp(20px, 10cqi, 200px); } - @media screen and (max-width : 800px) { - padding : clamp(20px, 5vh, 200px) clamp(20px, 5vw, 200px); + @container (max-width : 800px) { + padding : clamp(20px, 5vh, 200px) clamp(20px, 5cqi, 200px); } &::-webkit-scrollbar { @@ -53,6 +54,7 @@ color : white; } .brewCollection { + h1 { width : fit-content; margin-bottom : 20px; @@ -97,9 +99,9 @@ gap : 20px; justify-items : center; - @media screen and (max-width : 1700px) {--columns : 3;} - @media screen and (max-width : 1400px) {--columns : 2;} - @media screen and (max-width : 900px) {--columns : 1;} + @container (max-width : 1700px) {--columns : 3;} + @container (max-width : 1400px) {--columns : 2;} + @container (max-width : 900px) {--columns : 1;} h1 { position : absolute; } &:not(:has(.brewItem:last-child:nth-child(3n))) { diff --git a/client/homebrew/pages/sharePage/sharePage.jsx b/client/homebrew/pages/sharePage/sharePage.jsx index 7f5b1c235..9edc05938 100644 --- a/client/homebrew/pages/sharePage/sharePage.jsx +++ b/client/homebrew/pages/sharePage/sharePage.jsx @@ -46,21 +46,25 @@ const SharePage = (props)=>{ document.addEventListener('keydown', handleControlKeys); fetchThemeBundle(undefined, setThemeBundle, currentBrew.renderer, currentBrew.theme); - // listen for changes in the brew version - const eventSource = new EventSource('/stream'); - eventSource.addEventListener('message', (evt)=>{ - const messageData = JSON.parse(evt.data); + let eventSource; + // Start a stream if the brew has been updated in the last month + if(Date.parse(props.brew?.updatedAt) > (new Date).setDate((new Date).getDate() - 30)){ + // listen for changes in the brew version + eventSource = new EventSource(`/api/stream/${props.brew.shareId}`); - if(messageData.eventType == 'brewUpdated'){ - if(messageData.shareId == currentBrew.shareId && messageData.version != currentBrew.version) { + eventSource.addEventListener('brewUpdated', (evt)=>{ + const messageData = JSON.parse(evt.data); + + if(messageData.version != currentBrew.version) { console.log('should fetch brew'); fetchUpdatedBrew(); } - } - }); + }); + } return ()=>{ document.removeEventListener('keydown', handleControlKeys); + eventSource?.close(); }; }, []); console.log('brew: ', currentBrew); diff --git a/client/homebrew/pages/vaultPage/vaultPage.jsx b/client/homebrew/pages/vaultPage/vaultPage.jsx index e15443db0..0b1ec1f5d 100644 --- a/client/homebrew/pages/vaultPage/vaultPage.jsx +++ b/client/homebrew/pages/vaultPage/vaultPage.jsx @@ -10,6 +10,13 @@ import ErrorIndex from '../errorPage/errors/errorIndex.js'; import request from '../../utils/request-middleware.js'; import Navbar from '../../navbar/navbar.jsx'; +const DEFAULT_SORT_TYPE = 'alpha'; +const DEFAULT_SORT_DIR = 'asc'; +const DEFAULT_LAYOUT_MODE = 'grid'; +const DEFAULT_THEME_MODE = 'light'; +const USERPAGE_LAYOUT_MODE = 'HB_listPage_layout_mode'; +const USERPAGE_THEME_MODE = 'HB_listPage_theme_mode'; + const VaultPage = (props)=>{ const [pageState, setPageState] = useState(parseInt(props.query.page) || 1); @@ -21,6 +28,8 @@ const VaultPage = (props)=>{ const [totalBrews, setTotalBrews] = useState(null); const [searching, setSearching] = useState(false); const [error, setError] = useState(null); + const [layoutMode, setLayoutMode] = useState(DEFAULT_LAYOUT_MODE); + const [themeMode, setThemeMode] = useState(DEFAULT_THEME_MODE); const titleRef = useRef(null); const authorRef = useRef(null); @@ -31,6 +40,13 @@ const VaultPage = (props)=>{ useEffect(()=>{ disableSubmitIfFormInvalid(); + + const newLayoutMode = localStorage.getItem(USERPAGE_LAYOUT_MODE) || DEFAULT_LAYOUT_MODE; + const newThemeMode = localStorage.getItem(USERPAGE_THEME_MODE) || DEFAULT_THEME_MODE; + + setLayoutMode(newLayoutMode); + setThemeMode(newThemeMode); + loadPage(pageState, true, props.query.sort, props.query.dir); }, []); @@ -68,7 +84,7 @@ const VaultPage = (props)=>{ updateStateWithBrews([], 1); }); - if(response.ok) + if(response?.ok) updateStateWithBrews(response.body.brews, page); }; @@ -77,7 +93,8 @@ const VaultPage = (props)=>{ const response = await request.get(`/api/vault/total?title=${title}&author=${author}&v3=${v3}&legacy=${legacy}`) .catch((error)=>{ - console.log('error at loadTotal: ', error); + console.log('error at loadTotal: '); + console.error(error); setError(error); updateStateWithBrews([], 1); }); @@ -239,7 +256,7 @@ const VaultPage = (props)=>{ const oppositeDir = dirState === 'asc' ? 'desc' : 'asc'; return ( -