mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
chore(knip): trim dead exports and tool noise
This commit is contained in:
@@ -1 +1 @@
|
||||
export { MobileBoardButtons, DesktopBoardButtons, PostPageStats, ReturnButton, CatalogButton, UpdateButton, AutoButton, TopButton, RefreshButton } from './board-buttons';
|
||||
export { MobileBoardButtons, DesktopBoardButtons } from './board-buttons';
|
||||
|
||||
@@ -5,7 +5,7 @@ import StyleSelector from '../style-selector/style-selector';
|
||||
import footerStyles from '../footer/footer.module.css';
|
||||
import styles from './board-pagination.module.css';
|
||||
|
||||
export interface BoardPaginationProps {
|
||||
interface BoardPaginationProps {
|
||||
basePath: string;
|
||||
currentPage: number;
|
||||
totalPages: number;
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
export { default } from './board-pagination';
|
||||
export type { BoardPaginationProps } from './board-pagination';
|
||||
|
||||
@@ -18,7 +18,7 @@ import styles from './footer.module.css';
|
||||
* Main page footer wrapper: hr, first row slot, BoardsBar, SiteLegalMeta.
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
export interface PageFooterDesktopProps {
|
||||
interface PageFooterDesktopProps {
|
||||
/** Mode-specific first row content (e.g. board pagination or thread controls) */
|
||||
firstRow: React.ReactNode;
|
||||
/** Optional row between first row and BoardsBar (e.g. style selector on thread page) */
|
||||
@@ -61,7 +61,7 @@ export const StyleOnlyFooterFirstRow = () => {
|
||||
* Catalog footer first row: Return, Archive, Top, Refresh on left; Style selector on right.
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
export interface CatalogFooterFirstRowProps {
|
||||
interface CatalogFooterFirstRowProps {
|
||||
subplebbitAddress?: string;
|
||||
isInAllView?: boolean;
|
||||
isInSubscriptionsView?: boolean;
|
||||
@@ -114,7 +114,7 @@ export const ThreadFooterStyleRow = () => {
|
||||
* Thread page footer first row: Return, Catalog, Top, Update, Auto, Post a Reply, stats.
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
export interface ThreadFooterFirstRowProps {
|
||||
interface ThreadFooterFirstRowProps {
|
||||
postCid: string;
|
||||
threadNumber: number | undefined;
|
||||
subplebbitAddress: string;
|
||||
@@ -193,7 +193,7 @@ export const PageFooterMobile = ({ children }: { children: React.ReactNode }) =>
|
||||
* Mobile thread page footer: Post a Reply, Return/Catalog/Top, Update/Auto, stats.
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
export interface ThreadFooterMobileProps {
|
||||
interface ThreadFooterMobileProps {
|
||||
postCid: string;
|
||||
threadNumber: number | undefined;
|
||||
subplebbitAddress: string;
|
||||
|
||||
@@ -7,4 +7,3 @@ export {
|
||||
ThreadFooterStyleRow,
|
||||
ThreadFooterMobile,
|
||||
} from './footer';
|
||||
export type { PageFooterDesktopProps, CatalogFooterFirstRowProps, ThreadFooterFirstRowProps, ThreadFooterMobileProps } from './footer';
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { LinkTypePreviewer, default } from './post-form';
|
||||
export { default } from './post-form';
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
export { default } from './site-legal-meta';
|
||||
export type { SiteLegalMetaOrder, SiteLegalMetaProps } from './site-legal-meta';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import Version from '../version';
|
||||
|
||||
export type SiteLegalMetaOrder = 'version-first' | 'license-first';
|
||||
type SiteLegalMetaOrder = 'version-first' | 'license-first';
|
||||
|
||||
export type SiteLegalMetaProps = {
|
||||
type SiteLegalMetaProps = {
|
||||
/** Order of blocks: version-first (homepage) or license-first (board/post footer) */
|
||||
order?: SiteLegalMetaOrder;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
|
||||
import type { DirectoryCommunity } from './use-directories';
|
||||
import { computeGuiPostsPerPage, getBoardFeedPageSizeConstants, type CommunityWithPostsPerPage } from '../lib/utils/board-feed-pagination';
|
||||
|
||||
export type BoardFeedPageSize = ReturnType<typeof getBoardFeedPageSizeConstants>;
|
||||
type BoardFeedPageSize = ReturnType<typeof getBoardFeedPageSizeConstants>;
|
||||
|
||||
/**
|
||||
* Compute board feed page-size values from directory community.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import directoriesData from '../data/5chan-directories.json';
|
||||
|
||||
export interface DirectoriesMetadata {
|
||||
interface DirectoriesMetadata {
|
||||
title: string;
|
||||
description: string;
|
||||
createdAt: number;
|
||||
@@ -36,7 +36,7 @@ export interface DirectoriesData {
|
||||
communities: DirectoryCommunity[];
|
||||
}
|
||||
|
||||
export interface DirectoriesState {
|
||||
interface DirectoriesState {
|
||||
communities: DirectoryCommunity[];
|
||||
loading: boolean;
|
||||
error: Error | null;
|
||||
|
||||
@@ -19,7 +19,7 @@ const setCachedGifFrame = async (url: string, frameUrl: string): Promise<void> =
|
||||
await gifFrameDb.setItem(url, frameUrl);
|
||||
};
|
||||
|
||||
export const fetchImage = (url: string): Promise<ArrayBuffer> => {
|
||||
const fetchImage = (url: string): Promise<ArrayBuffer> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = new XMLHttpRequest();
|
||||
request.open('GET', url, true);
|
||||
@@ -35,7 +35,7 @@ export const fetchImage = (url: string): Promise<ArrayBuffer> => {
|
||||
});
|
||||
};
|
||||
|
||||
export const readImage = (file: File): Promise<ArrayBuffer> => {
|
||||
const readImage = (file: File): Promise<ArrayBuffer> => {
|
||||
return new Promise((resolve) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
|
||||
@@ -92,7 +92,7 @@ function getRuntime(): 'web' | 'electron' | 'android' {
|
||||
return 'web';
|
||||
}
|
||||
|
||||
export interface UseFileUploadOptions {
|
||||
interface UseFileUploadOptions {
|
||||
onUploadComplete: (url: string, fileName: string) => void;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useDirectoryByAddress } from './use-directories';
|
||||
import { useBoardFeedPageSize } from './use-board-feed-page-size';
|
||||
import { findPostPageInFeed, findPostPageInLoadedBoardFeeds, type FeedsOptionsLike, type LoadedFeedsLike } from '../lib/utils/post-page-resolution';
|
||||
|
||||
export interface UsePostPageNumberOptions {
|
||||
interface UsePostPageNumberOptions {
|
||||
subplebbitAddress: string | undefined;
|
||||
postCid: string | undefined;
|
||||
/** When false, page segment is excluded (e.g. pending-post view). When true, resolve and show page. */
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useEffect } from 'react';
|
||||
import { useSubplebbitStats } from '@bitsocialhq/bitsocial-react-hooks';
|
||||
import { create } from 'zustand';
|
||||
|
||||
export type SubplebbitsStatsState = {
|
||||
type SubplebbitsStatsState = {
|
||||
subplebbitsStats: { [subplebbitAddress: string]: any };
|
||||
setSubplebbitStats: (subplebbitAddress: string, stats: any) => void;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { ProviderAttempt } from './types';
|
||||
|
||||
export type { ProviderAttempt } from './types';
|
||||
|
||||
export type TranslateFn = (key: string) => string;
|
||||
type TranslateFn = (key: string) => string;
|
||||
|
||||
function formatSingleAttempt(a: ProviderAttempt): string {
|
||||
const base = `${a.provider}: ${a.error ?? 'unknown'}`;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { MediaHostingRuntime, ProviderId } from './types';
|
||||
|
||||
export interface ProviderDefinition {
|
||||
interface ProviderDefinition {
|
||||
id: ProviderId;
|
||||
label: string;
|
||||
homepageUrl: string;
|
||||
@@ -23,6 +23,3 @@ export const MEDIA_HOSTING_PROVIDERS: readonly ProviderDefinition[] = [
|
||||
supportedRuntimes: ['electron', 'android'],
|
||||
},
|
||||
] as const;
|
||||
|
||||
/** Provider IDs for ordering */
|
||||
export const PROVIDER_IDS: readonly ProviderId[] = MEDIA_HOSTING_PROVIDERS.map((p) => p.id);
|
||||
|
||||
@@ -13,7 +13,7 @@ export interface CatalogPost {
|
||||
}
|
||||
|
||||
/** Sort types supported by the catalog feed */
|
||||
export type CatalogSortType = 'active' | 'new' | 'replyCount';
|
||||
type CatalogSortType = 'active' | 'new' | 'replyCount';
|
||||
|
||||
/**
|
||||
* Sort catalog feed for display.
|
||||
|
||||
@@ -276,11 +276,11 @@ export const getMediaDimensions = memoize(
|
||||
|
||||
const thumbnailUrlsDb = localForageLru.createInstance({ name: '5chanThumbnailUrls', size: 500 });
|
||||
|
||||
export const getCachedThumbnail = async (url: string): Promise<string | null> => {
|
||||
const getCachedThumbnail = async (url: string): Promise<string | null> => {
|
||||
return await thumbnailUrlsDb.getItem(url);
|
||||
};
|
||||
|
||||
export const setCachedThumbnail = async (url: string, thumbnail: string): Promise<void> => {
|
||||
const setCachedThumbnail = async (url: string, thumbnail: string): Promise<void> => {
|
||||
await thumbnailUrlsDb.setItem(url, thumbnail);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BOARD_REPLIES_PREVIEW_VISIBLE_COUNT } from '../constants';
|
||||
|
||||
export interface CommentLike {
|
||||
interface CommentLike {
|
||||
cid?: string | null;
|
||||
index?: number;
|
||||
pendingApproval?: boolean;
|
||||
@@ -35,7 +35,7 @@ export function getPreviewDisplayReplies<T extends CommentLike>(replies: T[], vi
|
||||
.map((t) => t.reply);
|
||||
}
|
||||
|
||||
export interface ComputeOmittedParams {
|
||||
interface ComputeOmittedParams {
|
||||
totalReplyCount: number;
|
||||
visibleCount: number;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ export function computeOmittedCount({ totalReplyCount, visibleCount }: ComputeOm
|
||||
return Math.max(0, totalReplyCount - visibleCount);
|
||||
}
|
||||
|
||||
export interface GetTotalReplyCountParams {
|
||||
interface GetTotalReplyCountParams {
|
||||
replyCount: number | undefined;
|
||||
fullLoadedCount: number;
|
||||
previewLoadedCount: number;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { isBoardModRoute, isModQueueRoute } from './route-utils';
|
||||
|
||||
export type ParamsType = {
|
||||
type ParamsType = {
|
||||
accountCommentIndex?: string;
|
||||
boardIdentifier?: string;
|
||||
commentCid?: string;
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { registerPlugin } from '@capacitor/core';
|
||||
import type { ProviderAttempt, ProviderId } from '../lib/media-hosting/types';
|
||||
|
||||
export interface PickAndUploadMediaOptions {
|
||||
interface PickAndUploadMediaOptions {
|
||||
providerOrder: ProviderId[];
|
||||
}
|
||||
|
||||
export interface PickAndUploadMediaResult {
|
||||
interface PickAndUploadMediaResult {
|
||||
url: string;
|
||||
fileName: string;
|
||||
provider: ProviderId;
|
||||
attempts?: ProviderAttempt[];
|
||||
}
|
||||
|
||||
export interface FileUploaderPlugin {
|
||||
interface FileUploaderPlugin {
|
||||
pickAndUploadMedia(options?: PickAndUploadMediaOptions): Promise<PickAndUploadMediaResult>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { create } from 'zustand';
|
||||
|
||||
export type AllFeedFilter = 'all' | 'nsfw' | 'sfw';
|
||||
type AllFeedFilter = 'all' | 'nsfw' | 'sfw';
|
||||
|
||||
interface AllFeedFilterStore {
|
||||
filter: AllFeedFilter;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { create } from 'zustand';
|
||||
|
||||
export type BoardFilter = 'all' | 'nsfw' | 'worksafe';
|
||||
type BoardFilter = 'all' | 'nsfw' | 'worksafe';
|
||||
|
||||
interface BoardsFilterStore {
|
||||
useCatalogLinks: boolean;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { create } from 'zustand';
|
||||
import { persist } from 'zustand/middleware';
|
||||
|
||||
export type AlertThresholdUnit = 'hours' | 'minutes';
|
||||
export type ModQueueViewMode = 'compact' | 'feed';
|
||||
type AlertThresholdUnit = 'hours' | 'minutes';
|
||||
type ModQueueViewMode = 'compact' | 'feed';
|
||||
|
||||
interface ModQueueState {
|
||||
alertThresholdValue: number;
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { default, ContentPreview } from './popular-threads-box';
|
||||
export { default } from './popular-threads-box';
|
||||
|
||||
@@ -54,28 +54,38 @@ const PopularThreadCard = memo(
|
||||
(prevProps, nextProps) => prevProps.post?.cid === nextProps.post?.cid && prevProps.boardTitle === nextProps.boardTitle && prevProps.boardPath === nextProps.boardPath,
|
||||
);
|
||||
|
||||
const PopularThreadsBox = ({ directories, subplebbits }: { directories: DirectoryCommunity[]; subplebbits: any }) => {
|
||||
const PopularThreadsBox = ({
|
||||
directories,
|
||||
directoryAddresses,
|
||||
subplebbits,
|
||||
}: {
|
||||
directories: DirectoryCommunity[];
|
||||
directoryAddresses: string[];
|
||||
subplebbits: Array<Subplebbit | undefined>;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { showWorksafeContentOnly, showNsfwContentOnly } = usePopularThreadsOptionsStore();
|
||||
|
||||
const filteredSubplebbits = useMemo(() => {
|
||||
if (showWorksafeContentOnly) {
|
||||
return subplebbits.filter((sub: Subplebbit) => {
|
||||
const directoryEntry = findDirectoryByAddress(directories, sub?.address);
|
||||
return directoryEntry ? !directoryEntry.nsfw : true;
|
||||
});
|
||||
}
|
||||
if (showNsfwContentOnly) {
|
||||
return subplebbits.filter((sub: Subplebbit) => {
|
||||
const directoryEntry = findDirectoryByAddress(directories, sub?.address);
|
||||
return directoryEntry ? directoryEntry.nsfw : false;
|
||||
});
|
||||
}
|
||||
return subplebbits;
|
||||
}, [subplebbits, showWorksafeContentOnly, showNsfwContentOnly, directories]);
|
||||
const { filteredBoardAddresses, filteredSubplebbits } = useMemo(() => {
|
||||
const filteredEntries = directoryAddresses.flatMap((address, index) => {
|
||||
const directoryEntry = findDirectoryByAddress(directories, address);
|
||||
if (showWorksafeContentOnly && directoryEntry?.nsfw) {
|
||||
return [];
|
||||
}
|
||||
if (showNsfwContentOnly && !directoryEntry?.nsfw) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const { popularPosts } = usePopularPosts(filteredSubplebbits);
|
||||
const isLoading = popularPosts.length === 0;
|
||||
return [{ address, subplebbit: subplebbits[index] }];
|
||||
});
|
||||
|
||||
return {
|
||||
filteredBoardAddresses: filteredEntries.map((entry) => entry.address),
|
||||
filteredSubplebbits: filteredEntries.map((entry) => entry.subplebbit),
|
||||
};
|
||||
}, [directories, directoryAddresses, showNsfwContentOnly, showWorksafeContentOnly, subplebbits]);
|
||||
|
||||
const { popularPosts, isLoading } = usePopularPosts(filteredSubplebbits, filteredBoardAddresses);
|
||||
|
||||
return (
|
||||
<div className={styles.box}>
|
||||
|
||||
Reference in New Issue
Block a user