mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
sort mod queue by timestamp, remove redundant "view" button
This commit is contained in:
@@ -501,7 +501,7 @@ export const DesktopBoardButtons = () => {
|
|||||||
{!(isInAllView || isInSubscriptionsView || isInModView) && (
|
{!(isInAllView || isInSubscriptionsView || isInModView) && (
|
||||||
<>
|
<>
|
||||||
{' '}
|
{' '}
|
||||||
[<ModQueueButton boardIdentifier={boardIdentifier} isMobile={false} />]
|
<ModQueueButton boardIdentifier={boardIdentifier} isMobile={false} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{isInCatalogView && searchText ? (
|
{isInCatalogView && searchText ? (
|
||||||
|
|||||||
@@ -170,25 +170,8 @@ const ModQueueRow = ({ comment, showBoardColumn = false }: ModQueueRowProps) =>
|
|||||||
<button className={styles.button} onClick={handleReject} disabled={isPublishing}>
|
<button className={styles.button} onClick={handleReject} disabled={isPublishing}>
|
||||||
{t('reject')}
|
{t('reject')}
|
||||||
</button>
|
</button>
|
||||||
]{' '}
|
|
||||||
{postUrl ? (
|
|
||||||
<>
|
|
||||||
[
|
|
||||||
<Link to={postUrl} className={styles.button}>
|
|
||||||
{t('view')}
|
|
||||||
</Link>
|
|
||||||
]
|
]
|
||||||
</>
|
</>
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
[
|
|
||||||
<button className={styles.button} disabled>
|
|
||||||
{t('view')}
|
|
||||||
</button>
|
|
||||||
]
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -282,7 +265,6 @@ export const ModQueueButton = ({ boardIdentifier, isMobile }: ModQueueButtonProp
|
|||||||
const { feed } = useFeed({
|
const { feed } = useFeed({
|
||||||
subplebbitAddresses: shouldFetch ? subplebbitAddresses : [],
|
subplebbitAddresses: shouldFetch ? subplebbitAddresses : [],
|
||||||
modQueue: ['pendingApproval'],
|
modQueue: ['pendingApproval'],
|
||||||
sortType: 'new',
|
|
||||||
postsPerPage: 100, // Fetch enough to check timestamps
|
postsPerPage: 100, // Fetch enough to check timestamps
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -290,6 +272,11 @@ export const ModQueueButton = ({ boardIdentifier, isMobile }: ModQueueButtonProp
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort feed by timestamp (oldest first) to match ModQueueView sorting
|
||||||
|
const sortedFeed = useMemo(() => {
|
||||||
|
return [...feed].sort((a, b) => a.timestamp - b.timestamp);
|
||||||
|
}, [feed]);
|
||||||
|
|
||||||
// Separate comments into normal and urgent based on threshold
|
// Separate comments into normal and urgent based on threshold
|
||||||
// Match ModQueueRow logic: use > (strictly greater) to be consistent
|
// Match ModQueueRow logic: use > (strictly greater) to be consistent
|
||||||
const { normalCount, urgentCount } = useMemo(() => {
|
const { normalCount, urgentCount } = useMemo(() => {
|
||||||
@@ -299,7 +286,7 @@ export const ModQueueButton = ({ boardIdentifier, isMobile }: ModQueueButtonProp
|
|||||||
let normal = 0;
|
let normal = 0;
|
||||||
let urgent = 0;
|
let urgent = 0;
|
||||||
|
|
||||||
for (const item of feed) {
|
for (const item of sortedFeed) {
|
||||||
const timeWaiting = now - item.timestamp;
|
const timeWaiting = now - item.timestamp;
|
||||||
if (timeWaiting > thresholdSeconds) {
|
if (timeWaiting > thresholdSeconds) {
|
||||||
urgent++;
|
urgent++;
|
||||||
@@ -309,7 +296,7 @@ export const ModQueueButton = ({ boardIdentifier, isMobile }: ModQueueButtonProp
|
|||||||
}
|
}
|
||||||
|
|
||||||
return { normalCount: normal, urgentCount: urgent };
|
return { normalCount: normal, urgentCount: urgent };
|
||||||
}, [feed, alertThresholdHours]);
|
}, [sortedFeed, alertThresholdHours]);
|
||||||
|
|
||||||
const totalCount = normalCount + urgentCount;
|
const totalCount = normalCount + urgentCount;
|
||||||
|
|
||||||
@@ -383,6 +370,11 @@ export const ModQueueView = ({ boardIdentifier: propBoardIdentifier }: ModQueueV
|
|||||||
postsPerPage: 50,
|
postsPerPage: 50,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Sort feed by timestamp (oldest first) to show items waiting longest at the top
|
||||||
|
const sortedFeed = useMemo(() => {
|
||||||
|
return [...feed].sort((a, b) => a.timestamp - b.timestamp);
|
||||||
|
}, [feed]);
|
||||||
|
|
||||||
// Register reset function with feed reset store so refresh button works
|
// Register reset function with feed reset store so refresh button works
|
||||||
const setResetFunction = useFeedResetStore((state) => state.setResetFunction);
|
const setResetFunction = useFeedResetStore((state) => state.setResetFunction);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -421,7 +413,7 @@ export const ModQueueView = ({ boardIdentifier: propBoardIdentifier }: ModQueueV
|
|||||||
|
|
||||||
{!resolvedAddress && <ModQueueBoardFilter subplebbits={subplebbitsWithMetadata} />}
|
{!resolvedAddress && <ModQueueBoardFilter subplebbits={subplebbitsWithMetadata} />}
|
||||||
|
|
||||||
{feed.length === 0 && !hasMore ? (
|
{sortedFeed.length === 0 && !hasMore ? (
|
||||||
<div className={styles.empty}>{t('queue_is_empty')}</div>
|
<div className={styles.empty}>{t('queue_is_empty')}</div>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
@@ -434,8 +426,8 @@ export const ModQueueView = ({ boardIdentifier: propBoardIdentifier }: ModQueueV
|
|||||||
|
|
||||||
<Virtuoso
|
<Virtuoso
|
||||||
useWindowScroll
|
useWindowScroll
|
||||||
data={feed}
|
data={sortedFeed}
|
||||||
totalCount={feed.length}
|
totalCount={sortedFeed.length}
|
||||||
endReached={loadMore}
|
endReached={loadMore}
|
||||||
itemContent={(index, comment) => <ModQueueRow key={comment.cid} comment={comment} showBoardColumn={showBoardColumn} />}
|
itemContent={(index, comment) => <ModQueueRow key={comment.cid} comment={comment} showBoardColumn={showBoardColumn} />}
|
||||||
components={footerComponents}
|
components={footerComponents}
|
||||||
|
|||||||
Reference in New Issue
Block a user