mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
refactor(routing): migrate to directory-based board routing
This commit is contained in:
@@ -6,7 +6,8 @@ export const DISCLAIMER_ACCEPTED_KEY = '5chan-disclaimer-accepted';
|
||||
interface DisclaimerModalState {
|
||||
showModal: boolean;
|
||||
targetAddress: string | null;
|
||||
showDisclaimerModal: (address: string, navigate: NavigateFunction) => void;
|
||||
targetBoardPath: string | null;
|
||||
showDisclaimerModal: (address: string, navigate: NavigateFunction, boardPath?: string) => void;
|
||||
closeDisclaimerModal: () => void;
|
||||
acceptDisclaimer: (navigate: NavigateFunction) => void;
|
||||
}
|
||||
@@ -30,12 +31,14 @@ const setDisclaimerAccepted = (): void => {
|
||||
const useDisclaimerModalStore = create<DisclaimerModalState>((set) => ({
|
||||
showModal: false,
|
||||
targetAddress: null,
|
||||
targetBoardPath: null,
|
||||
|
||||
showDisclaimerModal: (address: string, navigate: NavigateFunction) => {
|
||||
showDisclaimerModal: (address: string, navigate: NavigateFunction, boardPath?: string) => {
|
||||
// Check if user has already accepted the disclaimer
|
||||
if (hasAcceptedDisclaimer()) {
|
||||
// Navigate directly without showing modal
|
||||
navigate(`/p/${address}`);
|
||||
const path = boardPath || address;
|
||||
navigate(`/${path}`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,6 +46,7 @@ const useDisclaimerModalStore = create<DisclaimerModalState>((set) => ({
|
||||
set({
|
||||
showModal: true,
|
||||
targetAddress: address,
|
||||
targetBoardPath: boardPath || null,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -50,6 +54,7 @@ const useDisclaimerModalStore = create<DisclaimerModalState>((set) => ({
|
||||
set({
|
||||
showModal: false,
|
||||
targetAddress: null,
|
||||
targetBoardPath: null,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -59,15 +64,17 @@ const useDisclaimerModalStore = create<DisclaimerModalState>((set) => ({
|
||||
// Save acceptance to localStorage
|
||||
setDisclaimerAccepted();
|
||||
|
||||
// Navigate to the target address
|
||||
if (state.targetAddress) {
|
||||
navigate(`/p/${state.targetAddress}`);
|
||||
// Navigate to the target board path (or address if no path)
|
||||
const path = state.targetBoardPath || state.targetAddress;
|
||||
if (path) {
|
||||
navigate(`/${path}`);
|
||||
}
|
||||
|
||||
// Close the modal
|
||||
set({
|
||||
showModal: false,
|
||||
targetAddress: null,
|
||||
targetBoardPath: null,
|
||||
});
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user