mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(settings): decode subplebbit address with emoji to fix pathname
This commit is contained in:
@@ -44,6 +44,16 @@ export const isRulesView = (pathname: string, params: ParamsType): boolean => {
|
||||
return params.subplebbitAddress ? decodedPathname.startsWith(`/p/${params.subplebbitAddress}/rules`) : false;
|
||||
};
|
||||
|
||||
export const isSettingsView = (pathname: string, params: ParamsType): boolean => {
|
||||
const { subplebbitAddress, commentCid } = params;
|
||||
const decodedPathname = decodeURIComponent(pathname);
|
||||
return (
|
||||
decodedPathname === `/p/${subplebbitAddress}/c/${commentCid}/settings` ||
|
||||
decodedPathname === `/p/${subplebbitAddress}/description/settings` ||
|
||||
decodedPathname === `/p/${subplebbitAddress}/rules/settings`
|
||||
);
|
||||
};
|
||||
|
||||
export const isSubscriptionsView = (pathname: string): boolean => {
|
||||
return pathname.startsWith('/p/subscriptions');
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { useComment, useSubplebbit } from '@plebbit/plebbit-react-hooks';
|
||||
import { useLocation, useParams } from 'react-router-dom';
|
||||
import styles from './post-page.module.css';
|
||||
import { isDescriptionView, isRulesView } from '../../lib/utils/view-utils';
|
||||
import { isDescriptionView, isRulesView, isSettingsView } from '../../lib/utils/view-utils';
|
||||
import useReplyModal from '../../hooks/use-reply-modal';
|
||||
import Post from '../../components/post';
|
||||
import ReplyModal from '../../components/reply-modal';
|
||||
@@ -16,10 +16,7 @@ const PostPage = () => {
|
||||
const params = useParams();
|
||||
const location = useLocation();
|
||||
const { commentCid, subplebbitAddress } = params;
|
||||
const showSettings =
|
||||
location.pathname === `/p/${subplebbitAddress}/c/${commentCid}/settings` ||
|
||||
location.pathname === `/p/${subplebbitAddress}/description/settings` ||
|
||||
location.pathname === `/p/${subplebbitAddress}/rules/settings`;
|
||||
const isInSettigsView = isSettingsView(location.pathname, params);
|
||||
const isInDescriptionView = isDescriptionView(location.pathname, params);
|
||||
const isInRulesView = isRulesView(location.pathname, params);
|
||||
|
||||
@@ -38,7 +35,7 @@ const PostPage = () => {
|
||||
|
||||
return (
|
||||
<div className={styles.content}>
|
||||
{showSettings && <SettingsModal />}
|
||||
{isInSettigsView && <SettingsModal />}
|
||||
{showReplyModal && activeCid && <ReplyModal closeModal={closeModal} parentCid={activeCid} scrollY={scrollY} />}
|
||||
{isInDescriptionView ? (
|
||||
<SubplebbitDescription
|
||||
|
||||
Reference in New Issue
Block a user