mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(account settings): add hash-based routing for settings categories
Each settings category now has a dedicated URL hash that expands only that category when accessed directly. The URL updates dynamically based on which category is expanded.
This commit is contained in:
@@ -5,6 +5,7 @@ import stringify from 'json-stringify-pretty-compact';
|
||||
import styles from './account-settings.module.css';
|
||||
import useAnonModeStore from '../../../stores/use-anon-mode-store';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
|
||||
const isAndroid = Capacitor.getPlatform() === 'android';
|
||||
|
||||
@@ -25,6 +26,7 @@ const AnonMode = () => {
|
||||
|
||||
const AccountSettings = () => {
|
||||
const { t } = useTranslation();
|
||||
const location = useLocation();
|
||||
const account = useAccount();
|
||||
const [text, setText] = useState('');
|
||||
|
||||
@@ -39,6 +41,7 @@ const AccountSettings = () => {
|
||||
|
||||
const { accounts } = useAccounts();
|
||||
const switchToNewAccountRef = useRef(false);
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
if (switchToNewAccountRef.current && accounts.length > 0) {
|
||||
@@ -160,6 +163,11 @@ const AccountSettings = () => {
|
||||
}
|
||||
|
||||
alert(`Imported ${newAccount.account?.name}`);
|
||||
|
||||
const currentPath = location.pathname;
|
||||
if (!currentPath.includes('/settings#account-settings')) {
|
||||
navigate(`${currentPath}#account-settings`, { replace: true });
|
||||
}
|
||||
window.location.reload();
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
|
||||
Reference in New Issue
Block a user