mirror of
https://github.com/narrrl/holy-flavor-rater.git
synced 2026-11-03 16:41:27 +01:00
removed old drawer stuff
This commit is contained in:
1 parent
e714e1ea51
commit
5ff5da2aac
8 files changed
+2
-102
No files matched your search
@@ -7,7 +7,6 @@ export interface AuthUser {
|
||||
is_superuser: boolean;
|
||||
theme?: string;
|
||||
language?: string;
|
||||
drawer_anchor?: 'left' | 'right';
|
||||
}
|
||||
|
||||
export interface FollowingEntry {
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import api from '../lib/api';
|
||||
import { useAuth } from './useAuth';
|
||||
|
||||
export type DrawerAnchor = 'left' | 'right';
|
||||
|
||||
const STORAGE_KEY = 'drawer-anchor';
|
||||
|
||||
const readLocal = (): DrawerAnchor => {
|
||||
const raw = localStorage.getItem(STORAGE_KEY);
|
||||
return raw === 'left' ? 'left' : 'right';
|
||||
};
|
||||
|
||||
export interface UseDrawerAnchorResult {
|
||||
anchor: DrawerAnchor;
|
||||
setAnchor: (anchor: DrawerAnchor) => Promise<void>;
|
||||
}
|
||||
|
||||
export const useDrawerAnchor = (): UseDrawerAnchorResult => {
|
||||
const { user, refetchUser } = useAuth();
|
||||
const [anchor, setAnchorState] = useState<DrawerAnchor>(
|
||||
(user?.drawer_anchor as DrawerAnchor) ?? readLocal(),
|
||||
);
|
||||
|
||||
// Adopt the server-side preference when it loads/changes. Derived during
|
||||
// render (tracking the previously-applied value) so it doesn't cost an extra
|
||||
// effect pass; the localStorage mirror is written in the effect below.
|
||||
const [appliedAnchor, setAppliedAnchor] = useState(user?.drawer_anchor);
|
||||
if (user?.drawer_anchor && user.drawer_anchor !== appliedAnchor) {
|
||||
setAppliedAnchor(user.drawer_anchor);
|
||||
setAnchorState(user.drawer_anchor);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (user?.drawer_anchor) localStorage.setItem(STORAGE_KEY, user.drawer_anchor);
|
||||
}, [user?.drawer_anchor]);
|
||||
|
||||
const setAnchor = useCallback(
|
||||
async (next: DrawerAnchor) => {
|
||||
setAnchorState(next);
|
||||
localStorage.setItem(STORAGE_KEY, next);
|
||||
if (user) {
|
||||
try {
|
||||
await api.patch('users/update_preferences/', { drawer_anchor: next });
|
||||
await refetchUser();
|
||||
} catch {
|
||||
/* fall back to local-only persistence */
|
||||
}
|
||||
}
|
||||
},
|
||||
[user, refetchUser],
|
||||
);
|
||||
|
||||
return { anchor, setAnchor };
|
||||
};
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
IconButton,
|
||||
Skeleton,
|
||||
useMediaQuery,
|
||||
useTheme,
|
||||
} from '@mui/material';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@@ -94,8 +93,6 @@ const MainPage: React.FC = () => {
|
||||
const [autoPlay, setAutoPlay] = useState(true);
|
||||
const [hovered, setHovered] = useState(false);
|
||||
const prefersReducedMotion = useMediaQuery('(prefers-reduced-motion: reduce)');
|
||||
const muiTheme = useTheme();
|
||||
const isDesktop = useMediaQuery(muiTheme.breakpoints.up('md'));
|
||||
const touchStartX = useRef<number | null>(null);
|
||||
|
||||
const query = new URLSearchParams(location.search).get('q') || '';
|
||||
@@ -533,8 +530,8 @@ const MainPage: React.FC = () => {
|
||||
)}
|
||||
</Box>
|
||||
|
||||
{/* Desktop-only category browser */}
|
||||
{isDesktop && <CategoryBrowseGrid categories={categories} />}
|
||||
{/* Category browser */}
|
||||
<CategoryBrowseGrid categories={categories} />
|
||||
|
||||
{/* Algorithmic discovery: personalized (members) or popular picks (visitors) */}
|
||||
<MainPageRecommendations isLoggedIn={isLoggedIn} />
|
||||
|
||||
@@ -24,8 +24,6 @@ import {
|
||||
ListSubheader,
|
||||
Divider,
|
||||
Grid,
|
||||
FormControlLabel,
|
||||
Switch,
|
||||
} from '@mui/material';
|
||||
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
@@ -36,7 +34,6 @@ import { useTitle } from '../hooks/useTitle';
|
||||
import type { CatppuccinTheme } from '../theme';
|
||||
import { PageShell, GlassCard, FormCard } from '../components/ui';
|
||||
import { useConfirm } from '../hooks/useConfirm';
|
||||
import { useDrawerAnchor } from '../hooks/useDrawerAnchor';
|
||||
|
||||
interface SettingsProps {
|
||||
themeName: CatppuccinTheme;
|
||||
@@ -54,7 +51,6 @@ const Settings: React.FC<SettingsProps> = ({ themeName, onThemeChange }) => {
|
||||
const { refetchUser } = useAuth();
|
||||
useTitle(t('nav.settings'));
|
||||
const { confirm } = useConfirm();
|
||||
const { anchor: drawerAnchor, setAnchor: setDrawerAnchor } = useDrawerAnchor();
|
||||
const { data: me } = useMe();
|
||||
const { data: banners = [] } = useBannersList();
|
||||
const updateAvatarMutation = useUpdateAvatar();
|
||||
@@ -324,31 +320,6 @@ const Settings: React.FC<SettingsProps> = ({ themeName, onThemeChange }) => {
|
||||
<MenuItem value="de">Deutsch</MenuItem>
|
||||
</Select>
|
||||
</FormControl>
|
||||
|
||||
<Divider sx={{ my: 2 }} />
|
||||
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Switch
|
||||
checked={drawerAnchor === 'left'}
|
||||
onChange={(e) => setDrawerAnchor(e.target.checked ? 'left' : 'right')}
|
||||
/>
|
||||
}
|
||||
label={
|
||||
<Box>
|
||||
<Typography variant="body1">
|
||||
{t('settings.leftHandMode', { defaultValue: 'Left-hand mode' })}
|
||||
</Typography>
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
{t('settings.leftHandModeHint', {
|
||||
defaultValue:
|
||||
'Mobile drawer slides in from the left (better for left-handed thumb reach).',
|
||||
})}
|
||||
</Typography>
|
||||
</Box>
|
||||
}
|
||||
sx={{ alignItems: 'flex-start', mt: 1 }}
|
||||
/>
|
||||
</GlassCard>
|
||||
|
||||
{/* Avatar: NOT a FormCard — file input lives outside any form */}
|
||||
|
||||
Reference in new issue
Block a user