mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
refactor(core): remove legacy plebbit terminology
This commit is contained in:
@@ -23,8 +23,8 @@ const testState = vi.hoisted(() => ({
|
||||
hasMore: false,
|
||||
isMobile: false,
|
||||
loadMoreMock: vi.fn(),
|
||||
resolvedSubplebbitAddress: 'music-posting.eth' as string | undefined,
|
||||
subplebbit: {
|
||||
resolvedCommunityAddress: 'music-posting.eth' as string | undefined,
|
||||
community: {
|
||||
error: undefined as Error | undefined,
|
||||
title: '/mu/ - Music',
|
||||
},
|
||||
@@ -53,7 +53,7 @@ vi.mock('@bitsocialnet/bitsocial-react-hooks', () => ({
|
||||
loadMore: testState.loadMoreMock,
|
||||
reset: vi.fn(),
|
||||
}),
|
||||
useCommunity: () => testState.subplebbit,
|
||||
useCommunity: () => testState.community,
|
||||
}));
|
||||
|
||||
vi.mock('../../../hooks/use-directories', () => ({
|
||||
@@ -62,8 +62,8 @@ vi.mock('../../../hooks/use-directories', () => ({
|
||||
directories.find((entry) => entry.address === address || entry.directoryCode === address || entry.title === address),
|
||||
}));
|
||||
|
||||
vi.mock('../../../hooks/use-resolved-subplebbit-address', () => ({
|
||||
useResolvedSubplebbitAddress: () => testState.resolvedSubplebbitAddress,
|
||||
vi.mock('../../../hooks/use-resolved-community-address', () => ({
|
||||
useResolvedCommunityAddress: () => testState.resolvedCommunityAddress,
|
||||
}));
|
||||
|
||||
vi.mock('../../../hooks/use-state-string', () => ({
|
||||
@@ -71,7 +71,7 @@ vi.mock('../../../hooks/use-state-string', () => ({
|
||||
}));
|
||||
|
||||
vi.mock('../../../hooks/use-stable-community', () => ({
|
||||
useCommunityField: (_address: string | undefined, selector: (value: typeof testState.subplebbit) => unknown) => selector(testState.subplebbit),
|
||||
useCommunityField: (_address: string | undefined, selector: (value: typeof testState.community) => unknown) => selector(testState.community),
|
||||
}));
|
||||
|
||||
vi.mock('../../../hooks/use-is-mobile', () => ({
|
||||
@@ -126,7 +126,7 @@ describe('Archive', () => {
|
||||
testState.feed = [];
|
||||
testState.hasMore = false;
|
||||
testState.isMobile = false;
|
||||
testState.subplebbit = {
|
||||
testState.community = {
|
||||
error: undefined,
|
||||
title: '/mu/ - Music',
|
||||
};
|
||||
|
||||
@@ -7,10 +7,10 @@ import { BottomButton, CatalogButton, ReturnButton, TopButton } from '../../comp
|
||||
import ErrorDisplay from '../../components/error-display/error-display';
|
||||
import { PageFooterDesktop, PageFooterMobile, ThreadFooterStyleRow } from '../../components/footer';
|
||||
import LoadingEllipsis from '../../components/loading-ellipsis';
|
||||
import { useResolvedSubplebbitAddress } from '../../hooks/use-resolved-subplebbit-address';
|
||||
import { useResolvedCommunityAddress } from '../../hooks/use-resolved-community-address';
|
||||
import { useCommunityField } from '../../hooks/use-stable-community';
|
||||
import { useFeedStateString } from '../../hooks/use-state-string';
|
||||
import { getSubplebbitAddress, getBoardPath } from '../../lib/utils/route-utils';
|
||||
import { getCommunityAddress, getBoardPath } from '../../lib/utils/route-utils';
|
||||
import { isCommentArchived } from '../../lib/utils/comment-moderation-utils';
|
||||
import { removeMarkdown } from '../../lib/utils/post-utils';
|
||||
import { useDirectories } from '../../hooks/use-directories';
|
||||
@@ -101,13 +101,13 @@ const ArchiveFooter = ({ hasMore, loadingState, onLoadMore }: { hasMore: boolean
|
||||
);
|
||||
};
|
||||
|
||||
const ArchiveDesktopTopControls = ({ subplebbitAddress }: { subplebbitAddress: string | undefined }) => (
|
||||
const ArchiveDesktopTopControls = ({ communityAddress }: { communityAddress: string | undefined }) => (
|
||||
<div className={styles.desktopNavLinks}>
|
||||
<span>
|
||||
[<ReturnButton address={subplebbitAddress} />]
|
||||
[<ReturnButton address={communityAddress} />]
|
||||
</span>
|
||||
<span>
|
||||
[<CatalogButton address={subplebbitAddress} />]
|
||||
[<CatalogButton address={communityAddress} />]
|
||||
</span>
|
||||
<span>
|
||||
[<BottomButton />]
|
||||
@@ -115,13 +115,13 @@ const ArchiveDesktopTopControls = ({ subplebbitAddress }: { subplebbitAddress: s
|
||||
</div>
|
||||
);
|
||||
|
||||
const ArchiveDesktopFooterControls = ({ subplebbitAddress }: { subplebbitAddress: string | undefined }) => (
|
||||
const ArchiveDesktopFooterControls = ({ communityAddress }: { communityAddress: string | undefined }) => (
|
||||
<div className={styles.desktopFooterButtons}>
|
||||
<span>
|
||||
[<ReturnButton address={subplebbitAddress} />]
|
||||
[<ReturnButton address={communityAddress} />]
|
||||
</span>
|
||||
<span>
|
||||
[<CatalogButton address={subplebbitAddress} />]
|
||||
[<CatalogButton address={communityAddress} />]
|
||||
</span>
|
||||
<span>
|
||||
[<TopButton />]
|
||||
@@ -129,18 +129,18 @@ const ArchiveDesktopFooterControls = ({ subplebbitAddress }: { subplebbitAddress
|
||||
</div>
|
||||
);
|
||||
|
||||
const ArchiveMobileTopControls = ({ subplebbitAddress }: { subplebbitAddress: string | undefined }) => (
|
||||
const ArchiveMobileTopControls = ({ communityAddress }: { communityAddress: string | undefined }) => (
|
||||
<div className={styles.mobileNavLinks}>
|
||||
<ReturnButton address={subplebbitAddress} />
|
||||
<CatalogButton address={subplebbitAddress} />
|
||||
<ReturnButton address={communityAddress} />
|
||||
<CatalogButton address={communityAddress} />
|
||||
<BottomButton />
|
||||
</div>
|
||||
);
|
||||
|
||||
const ArchiveMobileFooterControls = ({ subplebbitAddress }: { subplebbitAddress: string | undefined }) => (
|
||||
const ArchiveMobileFooterControls = ({ communityAddress }: { communityAddress: string | undefined }) => (
|
||||
<div className={styles.mobileFooterButtons}>
|
||||
<ReturnButton address={subplebbitAddress} />
|
||||
<CatalogButton address={subplebbitAddress} />
|
||||
<ReturnButton address={communityAddress} />
|
||||
<CatalogButton address={communityAddress} />
|
||||
<TopButton />
|
||||
</div>
|
||||
);
|
||||
@@ -151,22 +151,22 @@ const Archive = () => {
|
||||
const boardIdentifier = params.boardIdentifier;
|
||||
const directories = useDirectories();
|
||||
|
||||
const resolvedAddressFromUrl = useResolvedSubplebbitAddress();
|
||||
const subplebbitAddress = useMemo(() => {
|
||||
const resolvedAddressFromUrl = useResolvedCommunityAddress();
|
||||
const communityAddress = useMemo(() => {
|
||||
if (boardIdentifier) {
|
||||
return getSubplebbitAddress(boardIdentifier, directories);
|
||||
return getCommunityAddress(boardIdentifier, directories);
|
||||
}
|
||||
return resolvedAddressFromUrl;
|
||||
}, [boardIdentifier, directories, resolvedAddressFromUrl]);
|
||||
|
||||
const boardPath = useMemo(() => {
|
||||
if (!subplebbitAddress) {
|
||||
if (!communityAddress) {
|
||||
return boardIdentifier;
|
||||
}
|
||||
return getBoardPath(subplebbitAddress, directories);
|
||||
}, [boardIdentifier, directories, subplebbitAddress]);
|
||||
return getBoardPath(communityAddress, directories);
|
||||
}, [boardIdentifier, directories, communityAddress]);
|
||||
|
||||
const boardTitle = useCommunityField(subplebbitAddress, (community) => community?.title) || `/${boardIdentifier || subplebbitAddress || t('archive')}/`;
|
||||
const boardTitle = useCommunityField(communityAddress, (community) => community?.title) || `/${boardIdentifier || communityAddress || t('archive')}/`;
|
||||
|
||||
const archiveFilter = useMemo(
|
||||
() => ({
|
||||
@@ -176,9 +176,9 @@ const Archive = () => {
|
||||
[],
|
||||
);
|
||||
|
||||
const communityAddresses = useMemo(() => (subplebbitAddress ? [subplebbitAddress] : []), [subplebbitAddress]);
|
||||
const communityAddresses = useMemo(() => (communityAddress ? [communityAddress] : []), [communityAddress]);
|
||||
const communities = useCommunityIdentifiers(communityAddresses);
|
||||
const communityIdentifier = useCommunityIdentifier(subplebbitAddress);
|
||||
const communityIdentifier = useCommunityIdentifier(communityAddress);
|
||||
|
||||
const feedOptions = useMemo(
|
||||
() => ({
|
||||
@@ -212,14 +212,14 @@ const Archive = () => {
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div id='top' className={`${styles.page} ${shouldShowSnow() ? styles.garland : ''}`}>
|
||||
<ArchiveMobileTopControls subplebbitAddress={subplebbitAddress} />
|
||||
<ArchiveMobileTopControls communityAddress={communityAddress} />
|
||||
<hr className={styles.desktopDivider} />
|
||||
<ArchiveDesktopTopControls subplebbitAddress={subplebbitAddress} />
|
||||
<ArchiveDesktopTopControls communityAddress={communityAddress} />
|
||||
<hr className={styles.divider} />
|
||||
<h4 className={styles.archiveSummary}>{t('loading_archive')}</h4>
|
||||
<PageFooterDesktop firstRow={<ArchiveDesktopFooterControls subplebbitAddress={subplebbitAddress} />} styleRow={<ThreadFooterStyleRow />} />
|
||||
<PageFooterDesktop firstRow={<ArchiveDesktopFooterControls communityAddress={communityAddress} />} styleRow={<ThreadFooterStyleRow />} />
|
||||
<PageFooterMobile>
|
||||
<ArchiveMobileFooterControls subplebbitAddress={subplebbitAddress} />
|
||||
<ArchiveMobileFooterControls communityAddress={communityAddress} />
|
||||
</PageFooterMobile>
|
||||
</div>
|
||||
);
|
||||
@@ -227,9 +227,9 @@ const Archive = () => {
|
||||
|
||||
return (
|
||||
<div id='top' className={`${styles.page} ${shouldShowSnow() ? styles.garland : ''}`}>
|
||||
<ArchiveMobileTopControls subplebbitAddress={subplebbitAddress} />
|
||||
<ArchiveMobileTopControls communityAddress={communityAddress} />
|
||||
<hr className={styles.desktopDivider} />
|
||||
<ArchiveDesktopTopControls subplebbitAddress={subplebbitAddress} />
|
||||
<ArchiveDesktopTopControls communityAddress={communityAddress} />
|
||||
<hr className={styles.divider} />
|
||||
<h4 className={styles.archiveSummary}>{summaryText}</h4>
|
||||
|
||||
@@ -290,9 +290,9 @@ const Archive = () => {
|
||||
|
||||
<ArchiveFooter hasMore={hasMore} loadingState={loadingState} onLoadMore={loadMore} />
|
||||
|
||||
<PageFooterDesktop firstRow={<ArchiveDesktopFooterControls subplebbitAddress={subplebbitAddress} />} styleRow={<ThreadFooterStyleRow />} />
|
||||
<PageFooterDesktop firstRow={<ArchiveDesktopFooterControls communityAddress={communityAddress} />} styleRow={<ThreadFooterStyleRow />} />
|
||||
<PageFooterMobile>
|
||||
<ArchiveMobileFooterControls subplebbitAddress={subplebbitAddress} />
|
||||
<ArchiveMobileFooterControls communityAddress={communityAddress} />
|
||||
</PageFooterMobile>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -75,9 +75,7 @@ const getScopedAccountComments = (options?: { commentIndices?: number[]; communi
|
||||
const normalizedCommentIndices = options.commentIndices.filter((commentIndex) => Number.isInteger(commentIndex) && commentIndex >= 0);
|
||||
scopedComments = normalizedCommentIndices.map((commentIndex) => testState.accountComments[commentIndex]).filter(Boolean) as TestComment[];
|
||||
} else if (options?.communityAddress) {
|
||||
scopedComments = scopedComments.filter(
|
||||
(comment) => (comment.communityAddress || (comment as TestComment & { subplebbitAddress?: string }).subplebbitAddress) === options.communityAddress,
|
||||
);
|
||||
scopedComments = scopedComments.filter((comment) => comment.communityAddress === options.communityAddress);
|
||||
}
|
||||
|
||||
if (typeof options?.newerThan === 'number') {
|
||||
|
||||
@@ -19,8 +19,9 @@ import usePostNumberStore from '../../stores/use-post-number-store';
|
||||
import { useBoardFeedPageSize } from '../../hooks/use-board-feed-page-size';
|
||||
import useIsMobile from '../../hooks/use-is-mobile';
|
||||
import { getPageSlice } from '../../lib/utils/board-feed-pagination';
|
||||
import { getPageFromFeedPath, getSubplebbitAddress, isDirectoryBoard, normalizeMultiboardFeedPath, stripPageFromFeedPath } from '../../lib/utils/route-utils';
|
||||
import { getPageFromFeedPath, getCommunityAddress, isDirectoryBoard, normalizeMultiboardFeedPath, stripPageFromFeedPath } from '../../lib/utils/route-utils';
|
||||
import { isCommentArchived } from '../../lib/utils/comment-moderation-utils';
|
||||
import { getCommentCommunityAddress } from '../../lib/utils/comment-utils';
|
||||
import { getPretextItemSizeFromElement, resolveFeedVirtualizationMode } from '../../lib/utils/pretext-height-estimates';
|
||||
import ErrorDisplay from '../../components/error-display/error-display';
|
||||
import LoadingEllipsis from '../../components/loading-ellipsis';
|
||||
@@ -114,7 +115,7 @@ const Board = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp, i
|
||||
const resolvedAddressFromUrl = useResolvedCommunityAddress();
|
||||
const communityAddress = useMemo(() => {
|
||||
if (boardIdentifierProp) {
|
||||
return getSubplebbitAddress(boardIdentifierProp, directories);
|
||||
return getCommunityAddress(boardIdentifierProp, directories);
|
||||
}
|
||||
return resolvedAddressFromUrl;
|
||||
}, [boardIdentifierProp, directories, resolvedAddressFromUrl]);
|
||||
@@ -200,7 +201,7 @@ const Board = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp, i
|
||||
() =>
|
||||
recentAccountComments.filter((comment) => {
|
||||
const { cid, deleted, postCid, removed, state, timestamp } = comment || {};
|
||||
const commentCommunityAddress = comment?.communityAddress || comment?.subplebbitAddress;
|
||||
const commentCommunityAddress = getCommentCommunityAddress(comment);
|
||||
return (
|
||||
!deleted &&
|
||||
!removed &&
|
||||
|
||||
@@ -77,7 +77,7 @@ function getCatalogFiltersState() {
|
||||
filterItems: testState.filterItems,
|
||||
incrementFilterCount: testState.incrementFilterCountMock,
|
||||
searchText: testState.searchText,
|
||||
setCurrentSubplebbitAddress: testState.setCurrentCommunityAddressMock,
|
||||
setCurrentCommunityAddress: testState.setCurrentCommunityAddressMock,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -101,9 +101,7 @@ const getScopedAccountComments = (options?: { commentIndices?: number[]; communi
|
||||
const normalizedCommentIndices = options.commentIndices.filter((commentIndex) => Number.isInteger(commentIndex) && commentIndex >= 0);
|
||||
scopedComments = normalizedCommentIndices.map((commentIndex) => testState.accountComments[commentIndex]).filter(Boolean) as TestComment[];
|
||||
} else if (options?.communityAddress) {
|
||||
scopedComments = scopedComments.filter(
|
||||
(comment) => (comment.communityAddress || (comment as TestComment & { subplebbitAddress?: string }).subplebbitAddress) === options.communityAddress,
|
||||
);
|
||||
scopedComments = scopedComments.filter((comment) => comment.communityAddress === options.communityAddress);
|
||||
}
|
||||
|
||||
if (typeof options?.newerThan === 'number') {
|
||||
|
||||
@@ -15,7 +15,7 @@ import useCatalogStyleStore from '../../stores/use-catalog-style-store';
|
||||
import useFeedResetStore from '../../stores/use-feed-reset-store';
|
||||
import useSortingStore from '../../stores/use-sorting-store';
|
||||
import useCatalogFiltersStore from '../../stores/use-catalog-filters-store';
|
||||
import { getSubplebbitAddress, isDirectoryBoard, normalizeMultiboardFeedPath } from '../../lib/utils/route-utils';
|
||||
import { getCommunityAddress, isDirectoryBoard, normalizeMultiboardFeedPath } from '../../lib/utils/route-utils';
|
||||
import CatalogRow from '../../components/catalog-row';
|
||||
import { CatalogFooterFirstRow, PageFooterDesktop, PageFooterMobile } from '../../components/footer';
|
||||
import { ReturnButton, ArchiveButton, TopButton, RefreshButton } from '../../components/board-buttons/board-buttons';
|
||||
@@ -26,6 +26,7 @@ import styles from './catalog.module.css';
|
||||
import { commentMatchesPattern } from '../../lib/utils/pattern-utils';
|
||||
import { isCommentArchived } from '../../lib/utils/comment-moderation-utils';
|
||||
import { sortCatalogFeedForDisplay } from '../../lib/utils/catalog-sort';
|
||||
import { getCommentCommunityAddress } from '../../lib/utils/comment-utils';
|
||||
import {
|
||||
getCatalogRowHeightEstimates,
|
||||
getPretextItemSizeFromElement,
|
||||
@@ -212,7 +213,7 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
|
||||
const resolvedAddressFromUrl = useResolvedCommunityAddress();
|
||||
const communityAddress = useMemo(() => {
|
||||
if (boardIdentifierProp) {
|
||||
return getSubplebbitAddress(boardIdentifierProp, directories);
|
||||
return getCommunityAddress(boardIdentifierProp, directories);
|
||||
}
|
||||
return resolvedAddressFromUrl;
|
||||
}, [boardIdentifierProp, directories, resolvedAddressFromUrl]);
|
||||
@@ -267,9 +268,9 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
|
||||
|
||||
// Set the current community address
|
||||
useEffect(() => {
|
||||
useCatalogFiltersStore.getState().setCurrentSubplebbitAddress(communityAddress || null);
|
||||
useCatalogFiltersStore.getState().setCurrentCommunityAddress(communityAddress || null);
|
||||
return () => {
|
||||
useCatalogFiltersStore.getState().setCurrentSubplebbitAddress(null);
|
||||
useCatalogFiltersStore.getState().setCurrentCommunityAddress(null);
|
||||
};
|
||||
}, [communityAddress]);
|
||||
|
||||
@@ -304,7 +305,7 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
|
||||
() =>
|
||||
recentAccountComments.filter((comment) => {
|
||||
const { cid, deleted, postCid, removed, state, timestamp } = comment || {};
|
||||
const commentCommunityAddress = comment?.communityAddress || comment?.subplebbitAddress;
|
||||
const commentCommunityAddress = getCommentCommunityAddress(comment);
|
||||
|
||||
// Basic filtering conditions
|
||||
const basicConditions =
|
||||
|
||||
@@ -12,6 +12,7 @@ import LoadingEllipsis from '../../../components/loading-ellipsis';
|
||||
import BoxModal from '../box-modal';
|
||||
import { DirectoryCommunity, findDirectoryByAddress } from '../../../hooks/use-directories';
|
||||
import { useCommunityIdentifiers } from '../../../hooks/use-community-identifiers';
|
||||
import { getCommentCommunityAddress } from '../../../lib/utils/comment-utils';
|
||||
import { getBoardPath } from '../../../lib/utils/route-utils';
|
||||
import { removeMarkdown } from '../../../lib/utils/post-utils';
|
||||
|
||||
@@ -59,7 +60,6 @@ const PopularThreadCard = memo(
|
||||
const PopularThreadsBox = ({ directories, directoryAddresses }: { directories: DirectoryCommunity[]; directoryAddresses: string[] }) => {
|
||||
const { t } = useTranslation();
|
||||
const { showWorksafeContentOnly, showNsfwContentOnly } = usePopularThreadsOptionsStore();
|
||||
const getCommentCommunityAddress = (post: Comment) => post.communityAddress || post.subplebbitAddress;
|
||||
const directoryCommunities = useCommunityIdentifiers(directoryAddresses);
|
||||
const { communities } = useCommunities({ communities: directoryCommunities });
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import useModQueueStore from '../../stores/use-mod-queue-store';
|
||||
import LoadingEllipsis from '../../components/loading-ellipsis';
|
||||
import ErrorDisplay from '../../components/error-display/error-display';
|
||||
import { useFeedStateString } from '../../hooks/use-state-string';
|
||||
import { getSubplebbitAddress, getBoardPath, extractDirectoryFromTitle, areSameBoardAddress } from '../../lib/utils/route-utils';
|
||||
import { getCommunityAddress, getBoardPath, extractDirectoryFromTitle, areSameBoardAddress } from '../../lib/utils/route-utils';
|
||||
import { useDirectories, DirectoryCommunity } from '../../hooks/use-directories';
|
||||
import getShortAddress from '../../lib/get-short-address';
|
||||
import { BOARD_CODE_GROUPS } from '../../constants/board-codes';
|
||||
@@ -23,6 +23,7 @@ import { getFormattedDate, getFormattedTimeAgo } from '../../lib/utils/time-util
|
||||
import useFeedResetStore from '../../stores/use-feed-reset-store';
|
||||
import useChallengesStore from '../../stores/use-challenges-store';
|
||||
import { alertChallengeVerificationFailed } from '../../lib/utils/challenge-utils';
|
||||
import { getCommentCommunityAddress } from '../../lib/utils/comment-utils';
|
||||
import Tooltip from '../../components/tooltip';
|
||||
import { useAccountCommunityAddresses } from '../../hooks/use-account-community-addresses';
|
||||
import { useCommunityIdentifier, useCommunityIdentifiers } from '../../hooks/use-community-identifiers';
|
||||
@@ -44,8 +45,6 @@ const getBoardDisplayPath = (address: string, path: string): string => {
|
||||
return getShortAddress(address) || address;
|
||||
};
|
||||
|
||||
const getCommentCommunityAddress = (comment: Comment) => comment?.communityAddress || comment?.subplebbitAddress;
|
||||
|
||||
interface ModQueueViewProps {
|
||||
boardIdentifier?: string; // If provided, shows queue for single board
|
||||
}
|
||||
@@ -159,7 +158,7 @@ const ModQueueActions = ({ status, errorMessage, isPublishing, handleApprove, ha
|
||||
const useModQueueActions = (comment: Comment): ModQueueActionState => {
|
||||
const { t } = useTranslation();
|
||||
const { cid, approved, removed, pendingApproval } = comment || {};
|
||||
const communityAddress = comment?.communityAddress || comment?.subplebbitAddress;
|
||||
const communityAddress = getCommentCommunityAddress(comment);
|
||||
const [initiatedAction, setInitiatedAction] = useState<ModerationAction>(null);
|
||||
|
||||
const alreadyApproved = approved === true;
|
||||
@@ -256,14 +255,7 @@ const ModQueueRow = memo(({ comment, isOdd = false, showBoard = false, boardPath
|
||||
const { editedComment } = useEditedComment({ comment });
|
||||
const displayComment = editedComment || comment;
|
||||
|
||||
const { content, title, timestamp, cid, threadCid, link, thumbnailUrl, linkWidth, linkHeight, removed, approved, pendingApproval, number, parentCid } = displayComment;
|
||||
const commentCommunityAddress = getCommentCommunityAddress(displayComment);
|
||||
|
||||
// Check if already moderated (from previous session or API update)
|
||||
// Note: `approved` and `removed` are direct fields on the comment from CommentUpdate,
|
||||
// not nested under commentModeration (which is the options object for publishing moderation actions)
|
||||
const alreadyApproved = approved === true;
|
||||
const alreadyRejected = isPendingApprovalRejected({ approved, removed, pendingApproval });
|
||||
const { content, title, timestamp, cid, threadCid, link, thumbnailUrl, linkWidth, linkHeight, number, parentCid } = displayComment;
|
||||
|
||||
const timeWaiting = currentTime - timestamp;
|
||||
const alertThresholdSeconds = getAlertThresholdSeconds();
|
||||
@@ -368,11 +360,7 @@ const ModQueueCard = memo(({ comment, showBoard = false, boardPath, boardDisplay
|
||||
const { editedComment } = useEditedComment({ comment });
|
||||
const displayComment = editedComment || comment;
|
||||
|
||||
const { content, title, timestamp, cid, threadCid, link, thumbnailUrl, linkWidth, linkHeight, removed, approved, pendingApproval, number, parentCid } = displayComment;
|
||||
const commentCommunityAddress = getCommentCommunityAddress(displayComment);
|
||||
|
||||
const alreadyApproved = approved === true;
|
||||
const alreadyRejected = isPendingApprovalRejected({ approved, removed, pendingApproval });
|
||||
const { content, title, timestamp, cid, threadCid, link, thumbnailUrl, linkWidth, linkHeight, number, parentCid } = displayComment;
|
||||
|
||||
const timeWaiting = currentTime - timestamp;
|
||||
const alertThresholdSeconds = getAlertThresholdSeconds();
|
||||
@@ -725,7 +713,7 @@ export const ModQueueButton = ({ boardIdentifier, isMobile }: ModQueueButtonProp
|
||||
|
||||
const resolvedAddress = useMemo(() => {
|
||||
if (boardIdentifier) {
|
||||
return getSubplebbitAddress(boardIdentifier, directories);
|
||||
return getCommunityAddress(boardIdentifier, directories);
|
||||
}
|
||||
return undefined;
|
||||
}, [boardIdentifier, directories]);
|
||||
@@ -796,7 +784,7 @@ const ModQueueView = ({ boardIdentifier: propBoardIdentifier }: ModQueueViewProp
|
||||
|
||||
const resolvedAddress = useMemo(() => {
|
||||
if (boardIdentifier) {
|
||||
return getSubplebbitAddress(boardIdentifier, directories);
|
||||
return getCommunityAddress(boardIdentifier, directories);
|
||||
}
|
||||
return undefined;
|
||||
}, [boardIdentifier, directories]);
|
||||
|
||||
@@ -39,7 +39,7 @@ vi.mock('../../../hooks/use-directories', () => ({
|
||||
}));
|
||||
|
||||
vi.mock('../../../lib/utils/route-utils', () => ({
|
||||
getSubplebbitAddress: () => testState.communityAddress,
|
||||
getCommunityAddress: () => testState.communityAddress,
|
||||
}));
|
||||
|
||||
vi.mock('../../home', () => ({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import { useCommunityField } from '../../hooks/use-stable-community';
|
||||
import { useDirectories } from '../../hooks/use-directories';
|
||||
import { getSubplebbitAddress } from '../../lib/utils/route-utils';
|
||||
import { getCommunityAddress } from '../../lib/utils/route-utils';
|
||||
import { HomeLogo } from '../home';
|
||||
import NotFoundImage from '../../components/not-found-image';
|
||||
import styles from './not-found.module.css';
|
||||
@@ -12,7 +12,7 @@ const NotFound = () => {
|
||||
const pathParts = location.pathname.split('/').filter(Boolean);
|
||||
const boardIdentifier = pathParts[0] && pathParts[0] !== 'not-found' && pathParts[0] !== 'faq' ? pathParts[0] : '';
|
||||
const directories = useDirectories();
|
||||
const communityAddress = boardIdentifier ? getSubplebbitAddress(boardIdentifier, directories) : '';
|
||||
const communityAddress = boardIdentifier ? getCommunityAddress(boardIdentifier, directories) : '';
|
||||
// Only subscribe to address and shortAddress to avoid rerenders from updatingState changes
|
||||
const address = useCommunityField(communityAddress, (community) => community?.address);
|
||||
const shortAddress = useCommunityField(communityAddress, (community) => community?.shortAddress);
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useAccountComments } from '@bitsocialnet/bitsocial-react-hooks';
|
||||
import { useDirectories } from '../../hooks/use-directories';
|
||||
import useSafeAccountComment from '../../hooks/use-safe-account-comment';
|
||||
import { getCommentCommunityAddress } from '../../lib/utils/comment-utils';
|
||||
import { getBoardPath } from '../../lib/utils/route-utils';
|
||||
import { Post } from '../post';
|
||||
|
||||
@@ -31,7 +32,7 @@ const PendingPost = () => {
|
||||
}, [isValidAccountCommentIndex, navigate]);
|
||||
|
||||
useEffect(() => {
|
||||
const postCommunityAddress = post?.communityAddress || post?.subplebbitAddress;
|
||||
const postCommunityAddress = getCommentCommunityAddress(post);
|
||||
if (post?.cid && postCommunityAddress) {
|
||||
const boardPath = getBoardPath(postCommunityAddress, directories);
|
||||
navigate(`/${boardPath}/thread/${post.cid}`, { replace: true });
|
||||
|
||||
@@ -25,7 +25,6 @@ type TestComment = {
|
||||
replies?: unknown[];
|
||||
state?: string;
|
||||
communityAddress?: string;
|
||||
subplebbitAddress?: string;
|
||||
timestamp?: number;
|
||||
title?: string;
|
||||
};
|
||||
@@ -322,7 +321,7 @@ describe('Post', () => {
|
||||
},
|
||||
number: 777,
|
||||
replyCount: 0,
|
||||
subplebbitAddress: 'music-posting.eth',
|
||||
communityAddress: 'music-posting.eth',
|
||||
title: 'Archived thread',
|
||||
},
|
||||
};
|
||||
@@ -380,7 +379,7 @@ describe('Post', () => {
|
||||
'legacy-cid': {
|
||||
cid: 'legacy-cid',
|
||||
state: 'updating',
|
||||
subplebbitAddress: 'music-posting.eth',
|
||||
communityAddress: 'music-posting.eth',
|
||||
},
|
||||
};
|
||||
testState.cachedComments = {
|
||||
@@ -389,7 +388,7 @@ describe('Post', () => {
|
||||
content: 'cached body',
|
||||
number: 7,
|
||||
replyCount: 0,
|
||||
subplebbitAddress: 'music-posting.eth',
|
||||
communityAddress: 'music-posting.eth',
|
||||
title: 'Legacy thread',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -95,7 +95,7 @@ export const Post = memo(
|
||||
replyVirtualizationModeOverride,
|
||||
}: PostProps) => {
|
||||
// Only subscribe to roles field to avoid rerenders from updatingState changes
|
||||
const communityAddress = post?.communityAddress || post?.subplebbitAddress;
|
||||
const communityAddress = getCommentCommunityAddress(post);
|
||||
const roles = useCommunityField(communityAddress, (community) => community?.roles);
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useCommunity } from '@bitsocialnet/bitsocial-react-hooks';
|
||||
import { Footer, HomeLogo } from '../home';
|
||||
import { useDirectories, DirectoryCommunity, findDirectoryByAddress } from '../../hooks/use-directories';
|
||||
import { useCommunityIdentifier } from '../../hooks/use-community-identifiers';
|
||||
import { getSubplebbitAddress, getBoardPath } from '../../lib/utils/route-utils';
|
||||
import { getCommunityAddress, getBoardPath } from '../../lib/utils/route-utils';
|
||||
import Markdown from '../../components/markdown';
|
||||
import styles from './rules.module.css';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@@ -171,7 +171,7 @@ const Rules = () => {
|
||||
const navigate = useNavigate();
|
||||
const directories = useDirectories();
|
||||
|
||||
const selectedAddress = boardIdentifier ? getSubplebbitAddress(boardIdentifier, directories) : '';
|
||||
const selectedAddress = boardIdentifier ? getCommunityAddress(boardIdentifier, directories) : '';
|
||||
|
||||
const handleBoardSelect = (address: string) => {
|
||||
const path = getBoardPath(address, directories);
|
||||
|
||||
Reference in New Issue
Block a user