feat: use red offline icon for subplebbits that are most likely offline (ipns record fails to update)

This commit is contained in:
Tom (plebeius.eth)
2024-07-07 20:02:58 +02:00
parent a2347769e2
commit 9f7544936e
9 changed files with 46 additions and 30 deletions
+4 -9
View File
@@ -12,7 +12,7 @@ import useReply from '../../hooks/use-reply';
import useChallengesStore from '../../stores/use-challenges-store';
import styles from './post-form.module.css';
import _ from 'lodash';
import { getFormattedTimeAgo } from '../../lib/utils/time-utils';
import useIsSubplebbitOffline from '../../hooks/use-is-subplebbit-offline';
type SubmitState = {
subplebbitAddress: string | undefined;
@@ -272,17 +272,12 @@ const PostForm = () => {
const [showForm, setShowForm] = useState(false);
const subplebbit = useSubplebbit({ subplebbitAddress: params?.subplebbitAddress });
const { updatedAt } = subplebbit || {};
const isBoardOffline = updatedAt && updatedAt < Date.now() / 1000 - 60 * 60;
const offlineMessage = updatedAt
? isBoardOffline && t('posts_last_synced_info', { time: getFormattedTimeAgo(updatedAt), interpolation: { escapeValue: false } })
: t('subplebbit_offline_info');
const { isOffline, offlineTitle } = useIsSubplebbitOffline(subplebbit);
return (
<>
<div className={styles.postFormDesktop}>
{!(isInAllView || isInSubscriptionsView) && showForm && isBoardOffline && <div className={styles.offlineBoard}>{offlineMessage}</div>}
{!(isInAllView || isInSubscriptionsView) && showForm && isOffline && <div className={styles.offlineBoard}>{offlineTitle}</div>}
{isThreadClosed ? (
<div className={styles.closed}>
{t('thread_closed')}
@@ -302,7 +297,7 @@ const PostForm = () => {
)}
</div>
<div className={styles.postFormMobile}>
{!(isInAllView || isInSubscriptionsView) && showForm && isBoardOffline && <div className={styles.offlineBoard}>{offlineMessage}</div>}
{!(isInAllView || isInSubscriptionsView) && showForm && isOffline && <div className={styles.offlineBoard}>{offlineTitle}</div>}
{isThreadClosed ? (
<div className={styles.closed}>
{t('thread_closed')}