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
+55 -65
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,47 +286,24 @@ const Board = () => {
title={title} title={title}
/> />
)} )}
{feed.length !== 0 ? ( {rules && !description && rules.length > 0 && <SubplebbitRules subplebbitAddress={subplebbitAddress} createdAt={createdAt} rules={rules} />}
<> <Virtuoso
{rules && !description && rules.length > 0 && <SubplebbitRules subplebbitAddress={subplebbitAddress} createdAt={createdAt} rules={rules} />} increaseViewportBy={{ bottom: 1200, top: 1200 }}
<Virtuoso totalCount={combinedFeed.length}
increaseViewportBy={{ bottom: 1200, top: 1200 }} data={combinedFeed}
totalCount={combinedFeed.length} itemContent={(index, post) => {
data={combinedFeed} const { deleted, locked, removed } = post || {};
itemContent={(index, post) => { const isThreadClosed = deleted || locked || removed;
const { deleted, locked, removed } = post || {};
const isThreadClosed = deleted || locked || removed;
return <Post index={index} post={post} openReplyModal={isThreadClosed ? () => alert(t('thread_closed_alert')) : openReplyModal} />; return <Post index={index} post={post} openReplyModal={isThreadClosed ? () => alert(t('thread_closed_alert')) : openReplyModal} />;
}} }}
useWindowScroll={true} useWindowScroll={true}
components={{ Footer }} components={{ Footer }}
endReached={loadMore} endReached={loadMore}
ref={virtuosoRef} ref={virtuosoRef}
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>
); );
}; };