mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(p/all): empty 24h feed would not show 'show more posts since last week'
This commit is contained in:
+55
-65
@@ -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 && (
|
||||||
|
<>
|
||||||
|
[
|
||||||
|
<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 && (
|
|
||||||
<>
|
|
||||||
[
|
|
||||||
<span
|
|
||||||
className={styles.button}
|
|
||||||
onClick={() => {
|
|
||||||
unblock();
|
|
||||||
reset();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Unblock
|
|
||||||
</span>
|
|
||||||
]
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user