Skip to content

Commit

Permalink
refactor useSearchParams
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Jan 27, 2025
1 parent 756514d commit cc54964
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/app/(main)/settings/_layout/Mobile/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,31 @@

import { MobileNavBar, MobileNavBarTitle } from '@lobehub/ui';
import { Tag } from 'antd';
import { useRouter, useSearchParams } from 'next/navigation';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';

import { useActiveSettingsKey } from '@/hooks/useActiveTabKey';
import { useQueryRoute } from '@/hooks/useQueryRoute';
import { useShowMobileWorkspace } from '@/hooks/useShowMobileWorkspace';
import { SettingsTabs } from '@/store/global/initialState';
import { useSessionStore } from '@/store/session';
import { useUserStore } from '@/store/user';
import { authSelectors } from '@/store/user/selectors';
import { mobileHeaderSticky } from '@/styles/mobileHeader';

const Header = memo(() => {
const { t } = useTranslation('setting');

const router = useRouter();
const searchParams = useSearchParams();
const router = useQueryRoute();
const showMobileWorkspace = useShowMobileWorkspace();
const activeSettingsKey = useActiveSettingsKey();

const isSessionActive = useSessionStore((s) => !!s.activeId);
const enableAuth = useUserStore(authSelectors.enabledAuth);

const handleBackClick = () => {
if (searchParams.has('session') && searchParams.has('showMobileWorkspace')) {
router.push(`/chat?${searchParams.toString()}`);
if (isSessionActive && showMobileWorkspace) {
router.push('/chat');
} else {
router.push(enableAuth ? '/me/settings' : '/me');
}
Expand Down

0 comments on commit cc54964

Please sign in to comment.