mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat: add offline icon to board title, show alert before posting if sub appears offline
This commit is contained in:
@@ -28,6 +28,16 @@
|
|||||||
width: 90%;
|
width: 90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.offlineIcon {
|
||||||
|
background-image: url('/public/assets/icons/offline.png');
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 10px;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: contain;
|
||||||
|
image-rendering: pixelated;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 640px) {
|
@media (max-width: 640px) {
|
||||||
.bannerCnt {
|
.bannerCnt {
|
||||||
|
|||||||
@@ -34,12 +34,17 @@ const BoardHeader = () => {
|
|||||||
const title = isInAllView ? multisubMetadata?.title : isInSubscriptionsView ? 'Subscriptions' : subplebbit?.title;
|
const title = isInAllView ? multisubMetadata?.title : isInSubscriptionsView ? 'Subscriptions' : subplebbit?.title;
|
||||||
const subtitle = isInAllView ? 'p/all' : isInSubscriptionsView ? 'p/subscriptions' : `p/${address}`;
|
const subtitle = isInAllView ? 'p/all' : isInSubscriptionsView ? 'p/subscriptions' : `p/${address}`;
|
||||||
|
|
||||||
|
const isBoardOffline = subplebbit?.updatedAt && subplebbit.updatedAt < Date.now() / 1000 - 60 * 60;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
<div className={styles.bannerCnt}>
|
<div className={styles.bannerCnt}>
|
||||||
<ImageBanner key={isInAllView ? 'all' : isInSubscriptionsView ? 'subscriptions' : address} />
|
<ImageBanner key={isInAllView ? 'all' : isInSubscriptionsView ? 'subscriptions' : address} />
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.boardTitle}>{title || `p/${shortAddress || subplebbitAddress}`}</div>
|
<div className={styles.boardTitle}>
|
||||||
|
{title || `p/${shortAddress || subplebbitAddress}`}
|
||||||
|
{isBoardOffline && <span className={styles.offlineIcon} />}
|
||||||
|
</div>
|
||||||
<div className={styles.boardSubtitle}>{subtitle}</div>
|
<div className={styles.boardSubtitle}>{subtitle}</div>
|
||||||
<hr />
|
<hr />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -23,8 +23,15 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
color: red;
|
color: red;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
padding-top: 100px;
|
padding-top: 100px 0;
|
||||||
padding-bottom: 100px;
|
}
|
||||||
|
|
||||||
|
.offlineBoard {
|
||||||
|
font-size: 16px;
|
||||||
|
text-align: center;
|
||||||
|
color: red;
|
||||||
|
padding: 30px 0;
|
||||||
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
.postFormTable td:first-child {
|
.postFormTable td:first-child {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
||||||
import { PublishCommentOptions, setAccount, useAccount, useAccountComment, useComment, usePublishComment } from '@plebbit/plebbit-react-hooks';
|
import { PublishCommentOptions, setAccount, useAccount, useAccountComment, useComment, usePublishComment, useSubplebbit } from '@plebbit/plebbit-react-hooks';
|
||||||
import { create } from 'zustand';
|
import { create } from 'zustand';
|
||||||
import { alertChallengeVerificationFailed } from '../../lib/utils/challenge-utils';
|
import { alertChallengeVerificationFailed } from '../../lib/utils/challenge-utils';
|
||||||
import { getLinkMediaInfo } from '../../lib/utils/media-utils';
|
import { getLinkMediaInfo } from '../../lib/utils/media-utils';
|
||||||
@@ -12,6 +12,7 @@ import useReply from '../../hooks/use-reply';
|
|||||||
import useChallengesStore from '../../stores/use-challenges-store';
|
import useChallengesStore from '../../stores/use-challenges-store';
|
||||||
import styles from './post-form.module.css';
|
import styles from './post-form.module.css';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { getFormattedTimeAgo } from '../../lib/utils/time-utils';
|
||||||
|
|
||||||
type SubmitState = {
|
type SubmitState = {
|
||||||
subplebbitAddress: string | undefined;
|
subplebbitAddress: string | undefined;
|
||||||
@@ -271,9 +272,22 @@ const PostForm = () => {
|
|||||||
|
|
||||||
const [showForm, setShowForm] = useState(false);
|
const [showForm, setShowForm] = useState(false);
|
||||||
|
|
||||||
|
const subplebbit = useSubplebbit({ subplebbitAddress: params?.subplebbitAddress });
|
||||||
|
const { updatedAt } = subplebbit || {};
|
||||||
|
const isBoardOffline = subplebbit?.updatedAt && subplebbit.updatedAt < Date.now() / 1000 - 60 * 60;
|
||||||
|
|
||||||
|
const offlineAlert =
|
||||||
|
showForm &&
|
||||||
|
(updatedAt
|
||||||
|
? isBoardOffline && (
|
||||||
|
<div className={styles.offlineBoard}>{`Posts last synced ${getFormattedTimeAgo(updatedAt)}, the subplebbit might be offline and publishing might fail.`}</div>
|
||||||
|
)
|
||||||
|
: `The subplebbit might be offline and publishing might fail.`);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles.postFormDesktop}>
|
<div className={styles.postFormDesktop}>
|
||||||
|
{offlineAlert}
|
||||||
{isThreadClosed ? (
|
{isThreadClosed ? (
|
||||||
<div className={styles.closed}>
|
<div className={styles.closed}>
|
||||||
{t('thread_closed')}
|
{t('thread_closed')}
|
||||||
@@ -293,6 +307,7 @@ const PostForm = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.postFormMobile}>
|
<div className={styles.postFormMobile}>
|
||||||
|
{offlineAlert}
|
||||||
{isThreadClosed ? (
|
{isThreadClosed ? (
|
||||||
<div className={styles.closed}>
|
<div className={styles.closed}>
|
||||||
{t('thread_closed')}
|
{t('thread_closed')}
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ const BoardsBox = ({ multisub, subplebbits }: { multisub: Subplebbit[]; subplebb
|
|||||||
const isOffline = subplebbit?.updatedAt && subplebbit.updatedAt < Date.now() / 1000 - 60 * 60;
|
const isOffline = subplebbit?.updatedAt && subplebbit.updatedAt < Date.now() / 1000 - 60 * 60;
|
||||||
return isOffline;
|
return isOffline;
|
||||||
};
|
};
|
||||||
|
|
||||||
const multisubMetadata = useMultisubMetadata();
|
const multisubMetadata = useMultisubMetadata();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user