Skip to content

Commit

Permalink
Show missed/accepted video calls in the chat log.
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoVink committed Jan 7, 2025
1 parent 34f1d4b commit 33c5ce2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions web/app/(main)/chats/components-client.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ const cleanChatEntries = (userId, rawEntries) => {
curEntries.push(pick(entry, [...commonProps, 'linkText', 'linkUri']))
} else if (entry.type === 'im-media-visual' && entry.mediaType === 'photo') {
curEntries.push(pick(entry, [...commonProps, 'mediaType', 'mediaName', 'mediaUri', 'mediaAspectWidth', 'mediaAspectHeight', 'mediaPlaceholder']))
} else if (entry.type === 'im-call') {
curEntries.push(pick(entry, [...commonProps, 'missed', 'duration']))
}
}
pushGroup();
Expand Down
21 changes: 19 additions & 2 deletions web/app/(main)/chats/components-server.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ const ThreadLinkEntry = ({ entryId, userIsAuthor, linkText, linkUri }) => (

const ThreadVisualMediaEntry = ({ entryId, userIsAuthor, mediaUri, mediaAspectWidth, mediaAspectHeight, mediaPlaceholder }) => (
<div
id={`entry-${entryId}`}
id={`entry-${entryId}}`}
className={cn(
'w-full flex',
userIsAuthor ? 'justify-end' : 'justify-start'
Expand Down Expand Up @@ -239,18 +239,35 @@ const ThreadVisualMediaEntry = ({ entryId, userIsAuthor, mediaUri, mediaAspectWi
</div>
)

const ThreadCallEntry = ({ entryId, missed, duration }) => (
<div id={`entry-${entryId}`} className="w-full flex justify-center tracking-wide text-muted-foreground text-xs py-1">
{missed
? <span>Missed call</span>
: !!duration
? <span>Video call for {duration} seconds</span>
: <span>Video call ended</span>}
</div>
);

const ThreadEntry = ({ entry }) => {
if (entry.type === 'im-text') {
return <ThreadTextEntry {...entry} />
} else if (entry.type === 'im-link') {
return <ThreadLinkEntry {...entry} />
} else if (entry.type === 'im-media-visual') {
return <ThreadVisualMediaEntry {...entry} />
} else if (entry.type === 'im-call') {
return <ThreadCallEntry {...entry} />
}

return <div />;
}

const getKey = (entry) =>
entry.type === 'im-media-visual'
? `entry-${entry.entryId}-${entry.mediaUri}`
: `entry-${entry.entryId}`;


export const ThreadEntryGroup = ({ entryGroup }) => (
<div>
Expand All @@ -261,7 +278,7 @@ export const ThreadEntryGroup = ({ entryGroup }) => (
)}
<div className="space-y-1">
{entryGroup.entries.map(e => (
<ThreadEntry key={e.entryId} entry={({ ...e, userIsAuthor: entryGroup.userIsAuthor })} />
<ThreadEntry key={getKey(e)} entry={({ ...e, userIsAuthor: entryGroup.userIsAuthor })} />
))}
</div>
</div>
Expand Down

0 comments on commit 33c5ce2

Please sign in to comment.