Explorar o código

fix: Refine sider visibility and inner padding logic in StyleProvider component

- Consolidated the logic for managing sider visibility and inner padding based on the current pathname, improving responsiveness to navigation changes.
- Ensured that the sider is hidden on specific paths and adjusted inner padding accordingly, enhancing the user interface experience on both mobile and desktop views.
CalciumIon hai 1 ano
pai
achega
16599a900b
Modificáronse 1 ficheiros con 10 adicións e 11 borrados
  1. 10 11
      web/src/context/Style/index.js

+ 10 - 11
web/src/context/Style/index.js

@@ -45,19 +45,18 @@ export const StyleProvider = ({ children }) => {
     updateIsMobile();
     updateIsMobile();
 
 
     const updateShowSider = () => {
     const updateShowSider = () => {
-      if (isMobile()) {
+      // check pathname
+      const pathname = window.location.pathname;
+      if (pathname === '' || pathname === '/' || pathname.includes('/home') || pathname.includes('/chat')) {
         dispatch({ type: 'SET_SIDER', payload: false });
         dispatch({ type: 'SET_SIDER', payload: false });
+        dispatch({ type: 'SET_INNER_PADDING', payload: false });
       } else {
       } else {
-        // check pathname
-        const pathname = window.location.pathname;
-        console.log(pathname)
-        if (pathname === '' || pathname === '/' || pathname.includes('/home') || pathname.includes('/chat')) {
-          dispatch({ type: 'SET_SIDER', payload: false });
-          dispatch({ type: 'SET_INNER_PADDING', payload: false });
-        } else {
-          dispatch({ type: 'SET_SIDER', payload: true });
-          dispatch({ type: 'SET_INNER_PADDING', payload: true });
-        }
+        dispatch({ type: 'SET_SIDER', payload: true });
+        dispatch({ type: 'SET_INNER_PADDING', payload: true });
+      }
+
+      if (isMobile()) {
+        dispatch({ type: 'SET_SIDER', payload: false });
       }
       }
     };
     };