feat: link media to conversations
This commit is contained in:
1 parent
e8f56b42e6
commit
acc610c2bf
4 files changed
+39
-5
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import type { MediaItem } from '../../../../../packages/api-contracts/src/index.js';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { RedditUsernameLink } from '../../components/reddit-username-link.js';
|
||||
import { createOwnedConversationId } from '../conversations/conversation-identity.js';
|
||||
import { mediaConversation, mediaType } from './filters.js';
|
||||
import { AccountOwnerBadge } from '../../components/account-owner-badge.js';
|
||||
|
||||
@@ -15,6 +17,11 @@ function formatMediaDate(timestamp: number): string {
|
||||
}
|
||||
|
||||
export function MediaCard({ item, isRevealed, onToggleReveal, onOpenPreview }: MediaCardProps) {
|
||||
const conversationId = item.chatRoomId ?? item.chatUsername;
|
||||
const conversationPath = conversationId
|
||||
? `/conversations/${encodeURIComponent(createOwnedConversationId(item.owner?.accountId, conversationId))}`
|
||||
: null;
|
||||
|
||||
return (
|
||||
<article className="media-card">
|
||||
<div className="media-preview">
|
||||
@@ -41,6 +48,11 @@ export function MediaCard({ item, isRevealed, onToggleReveal, onOpenPreview }: M
|
||||
<div><dt>Type</dt><dd>{mediaType(item) === 'gif' ? 'GIF' : 'Image'}</dd></div>
|
||||
<div><dt>Received</dt><dd>{formatMediaDate(item.timestamp)}</dd></div>
|
||||
</dl>
|
||||
{conversationPath ? (
|
||||
<Link className="button secondary media-conversation-link" to={conversationPath}>
|
||||
Open conversation
|
||||
</Link>
|
||||
) : null}
|
||||
<button
|
||||
className="button secondary media-reveal"
|
||||
onClick={onToggleReveal}
|
||||
|
||||
Reference in new issue
Block a user