From 937abf8dcac03c1f6c5134449c5552f043a779cb Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Wed, 12 Jun 2024 17:38:22 +0200 Subject: [PATCH] fix: don't show 'sub might be offline' alert in multisubs --- src/components/post-form/post-form.tsx | 6 ++++-- src/components/reply-modal/reply-modal.tsx | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/post-form/post-form.tsx b/src/components/post-form/post-form.tsx index 02d0844b..f9718be4 100644 --- a/src/components/post-form/post-form.tsx +++ b/src/components/post-form/post-form.tsx @@ -262,6 +262,8 @@ const PostForm = () => { const isInDescriptionView = isDescriptionView(location.pathname, params); const isInPostView = isPostPageView(location.pathname, params); const isInRulesView = isRulesView(location.pathname, params); + const isInAllView = isAllView(location.pathname); + const isInSubscriptionsView = isSubscriptionsView(location.pathname); const comment = useComment({ commentCid: useParams().commentCid }); const { deleted, locked, removed } = comment || {}; @@ -286,7 +288,7 @@ const PostForm = () => { return ( <>
- {offlineAlert} + {!(isInAllView || isInSubscriptionsView) && offlineAlert} {isThreadClosed ? (
{t('thread_closed')} @@ -306,7 +308,7 @@ const PostForm = () => { )}
- {offlineAlert} + {!(isInAllView || isInSubscriptionsView) && offlineAlert} {isThreadClosed ? (
{t('thread_closed')} diff --git a/src/components/reply-modal/reply-modal.tsx b/src/components/reply-modal/reply-modal.tsx index 07b98c0c..b53a38bc 100644 --- a/src/components/reply-modal/reply-modal.tsx +++ b/src/components/reply-modal/reply-modal.tsx @@ -1,11 +1,12 @@ import { useEffect, useRef, useState } from 'react'; -import { useParams } from 'react-router-dom'; +import { useLocation, useParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import Draggable from 'react-draggable'; import { setAccount, useAccount, useSubplebbit } from '@plebbit/plebbit-react-hooks'; import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js'; import { getFormattedTimeAgo } from '../../lib/utils/time-utils'; import { isValidURL } from '../../lib/utils/url-utils'; +import { isAllView, isSubscriptionsView } from '../../lib/utils/view-utils'; import useReply from '../../hooks/use-reply'; import useIsMobile from '../../hooks/use-is-mobile'; import styles from './reply-modal.module.css'; @@ -76,6 +77,9 @@ const ReplyModal = ({ closeModal, parentCid, scrollY }: ReplyModalProps) => { } }, [parentCid]); + const location = useLocation(); + const isInAllView = isAllView(location.pathname); + const isInSubscriptionsView = isSubscriptionsView(location.pathname); const subplebbit = useSubplebbit({ subplebbitAddress }); const { updatedAt } = subplebbit || {}; const isBoardOffline = subplebbit?.updatedAt && subplebbit.updatedAt < Date.now() / 1000 - 60 * 60; @@ -134,7 +138,7 @@ const ReplyModal = ({ closeModal, parentCid, scrollY }: ReplyModalProps) => { autoFocus={!isMobile} // autofocus causes auto scroll to top on mobile />
- {offlineAlert} + {!(isInAllView || isInSubscriptionsView) && offlineAlert}
{url && (