fix(p/all): empty 24h feed would not show 'show more posts since last week'

This commit is contained in:
Tom (plebeius.eth)
2024-11-05 11:25:08 +01:00
parent a927f3aa00
commit 82217a726c
+38 -48
View File
@@ -121,27 +121,7 @@ const Board = () => {
const { blocked, unblock } = useBlock({ address: subplebbitAddress }); const { blocked, unblock } = useBlock({ address: subplebbitAddress });
const loadingStateString = useFeedStateString(subplebbitAddresses) || t('loading'); const loadingStateString = useFeedStateString(subplebbitAddresses) || t('loading');
const loadingString = ( const loadingString = <div className={styles.stateString}></div>;
<div className={styles.stateString}>
{state === 'failed' ? (
<span className='red'>{state}</span>
) : isInSubscriptionsView && subscriptions?.length === 0 ? (
t('not_subscribed_to_any_board')
) : blocked ? (
'you have blocked this board'
) : !hasMore && feed.length === 0 ? (
t('no_posts')
) : (
hasMore && <LoadingEllipsis string={loadingStateString} />
)}
{error && (
<div className='red'>
<br />
{error.message}
</div>
)}
</div>
);
const handleNewerPostsButtonClick = () => { const handleNewerPostsButtonClick = () => {
window.scrollTo({ top: 0, left: 0 }); window.scrollTo({ top: 0, left: 0 });
@@ -219,13 +199,46 @@ const Board = () => {
</div> </div>
)) ))
)} )}
<div className={styles.stateString}>
<LoadingEllipsis string={loadingStateString} />
</div>
</> </>
); );
} }
return <div className={styles.footer}>{footerContent}</div>; return (
<div className={styles.footer}>
{footerContent}
<div>
{state === 'failed' ? (
<span className='red'>{state}</span>
) : isInSubscriptionsView && subscriptions?.length === 0 ? (
t('not_subscribed_to_any_board')
) : blocked ? (
'you have blocked this board'
) : (
hasMore && <LoadingEllipsis string={loadingStateString} />
)}
{error && (
<div className='red'>
<br />
{error.message}
</div>
)}
{blocked && (
<>
&nbsp;&nbsp;[
<span
className={styles.button}
onClick={() => {
unblock();
reset();
}}
>
Unblock
</span>
]
</>
)}
</div>
</div>
);
}; };
// save the last Virtuoso state to restore it when navigating back // save the last Virtuoso state to restore it when navigating back
@@ -273,8 +286,6 @@ const Board = () => {
title={title} title={title}
/> />
)} )}
{feed.length !== 0 ? (
<>
{rules && !description && rules.length > 0 && <SubplebbitRules subplebbitAddress={subplebbitAddress} createdAt={createdAt} rules={rules} />} {rules && !description && rules.length > 0 && <SubplebbitRules subplebbitAddress={subplebbitAddress} createdAt={createdAt} rules={rules} />}
<Virtuoso <Virtuoso
increaseViewportBy={{ bottom: 1200, top: 1200 }} increaseViewportBy={{ bottom: 1200, top: 1200 }}
@@ -293,27 +304,6 @@ const Board = () => {
restoreStateFrom={lastVirtuosoState} restoreStateFrom={lastVirtuosoState}
initialScrollTop={lastVirtuosoState?.scrollTop} initialScrollTop={lastVirtuosoState?.scrollTop}
/> />
</>
) : (
<div className={styles.footer}>
{loadingString}
{blocked && (
<>
&nbsp;&nbsp;[
<span
className={styles.button}
onClick={() => {
unblock();
reset();
}}
>
Unblock
</span>
]
</>
)}
</div>
)}
</div> </div>
); );
}; };