2024-04-09 15:03:26 +02:00
|
|
|
import Post from '../post';
|
2024-04-28 22:05:06 +02:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2024-05-17 14:55:41 +02:00
|
|
|
import { isAllView } from '../../lib/utils/view-utils';
|
|
|
|
|
import { useMultisubMetadata } from '../../hooks/use-default-subplebbits';
|
|
|
|
|
import { useLocation } from 'react-router-dom';
|
2024-04-12 14:28:06 +02:00
|
|
|
|
2024-04-09 15:03:26 +02:00
|
|
|
interface DescriptionPostProps {
|
2024-04-29 14:53:46 +02:00
|
|
|
avatarUrl?: string;
|
2024-04-09 15:03:26 +02:00
|
|
|
createdAt: number;
|
|
|
|
|
description: string;
|
2024-04-29 14:53:46 +02:00
|
|
|
shortAddress: string;
|
|
|
|
|
subplebbitAddress: string | undefined;
|
2024-04-09 15:03:26 +02:00
|
|
|
title: string;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-29 14:53:46 +02:00
|
|
|
const SubplebbitDescription = ({ avatarUrl, createdAt, description, shortAddress, subplebbitAddress, title }: DescriptionPostProps) => {
|
2024-04-28 22:05:06 +02:00
|
|
|
const { t } = useTranslation();
|
2024-05-17 14:55:41 +02:00
|
|
|
const location = useLocation();
|
|
|
|
|
const isInAllView = isAllView(location.pathname);
|
|
|
|
|
const multisubMetadata = useMultisubMetadata();
|
|
|
|
|
|
2024-04-09 15:03:26 +02:00
|
|
|
const post = {
|
|
|
|
|
isDescription: true,
|
|
|
|
|
subplebbitAddress,
|
2024-05-17 14:55:41 +02:00
|
|
|
timestamp: isInAllView ? multisubMetadata?.createdAt : createdAt,
|
2024-05-31 17:29:19 +02:00
|
|
|
author: { displayName: `'## ${t('board_mods')}` },
|
2024-05-17 14:55:41 +02:00
|
|
|
content: isInAllView ? multisubMetadata?.description : description,
|
2024-04-09 15:03:26 +02:00
|
|
|
link: avatarUrl,
|
2024-05-17 14:55:41 +02:00
|
|
|
title: t('welcome_to_board', {
|
|
|
|
|
board: isInAllView ? multisubMetadata?.title : title || `p/${shortAddress}`,
|
|
|
|
|
interpolation: { escapeValue: false },
|
|
|
|
|
}),
|
2024-04-09 15:03:26 +02:00
|
|
|
pinned: true,
|
|
|
|
|
locked: true,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return <Post post={post} />;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default SubplebbitDescription;
|