Skip to content

Commit

Permalink
Change displayed time based on approval
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Jul 12, 2024
1 parent 2f92b7e commit 04765a8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/@types/subsocial.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ declare module '@subsocial/api/types' {
dataType?: 'persistent' | 'optimistic' | 'offChain'
parentPostId?: string | null
approvedInRootPost?: boolean
approvedInRootPostAtTime: string
approvedInRootPostAtTime: number
},
PostContent
> & { requestedId?: string }
Expand Down
15 changes: 12 additions & 3 deletions src/components/extensions/common/CommonChatItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ export default function CommonChatItem({
const firstReasonId = reasons?.[0].id

const { struct, content } = message
const { ownerId, createdAtTime, dataType, isUpdated } = struct
const {
ownerId,
createdAtTime,
approvedInRootPostAtTime,
dataType,
isUpdated,
} = struct
const { body } = content || {}
const repliedMessageId = getRepliedMessageId(message)
const { data: superLikeCount } = getSuperLikeCountQuery.useQuery(message.id)
Expand Down Expand Up @@ -118,10 +124,13 @@ export default function CommonChatItem({
? children({ isMyMessage, relativeTime, isSent })
: children

const displayedTime = showApproveButton
? createdAtTime
: approvedInRootPostAtTime
const otherMessageCheckMarkElement = (className?: string) => (
<ChatRelativeTime
isUpdated={isUpdated}
createdAtTime={createdAtTime}
createdAtTime={displayedTime}
className={cx(
'text-xs text-text-muted',
isMyMessage && 'text-text-muted-on-primary-light',
Expand All @@ -139,7 +148,7 @@ export default function CommonChatItem({
<div className={cx('flex items-center gap-1 self-end', className)}>
<ChatRelativeTime
isUpdated={isUpdated}
createdAtTime={createdAtTime}
createdAtTime={displayedTime}
className={cx(
'text-xs text-text-muted-on-primary-light',
isMyMessage && 'text-text-muted-on-primary-light',
Expand Down
2 changes: 2 additions & 0 deletions src/components/modals/LikeIntroModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const DUMMY_MESSAGES: { message: PostData; superLikeCount: number }[] = [
message: {
id: '0x123',
struct: {
approvedInRootPostAtTime: dayjs().subtract(1, 'day').toDate().getTime(),
id: '0x123',
createdAtBlock: 0,
createdAtTime: dayjs().subtract(1, 'day').toDate().getTime(),
Expand Down Expand Up @@ -59,6 +60,7 @@ const DUMMY_MESSAGES: { message: PostData; superLikeCount: number }[] = [
message: {
id: '0x123',
struct: {
approvedInRootPostAtTime: dayjs().subtract(1, 'day').toDate().getTime(),
id: '0x123',
createdAtBlock: 0,
createdAtTime: dayjs().subtract(1, 'day').toDate().getTime(),
Expand Down
2 changes: 1 addition & 1 deletion src/services/datahub/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const mapDatahubPostFragment = (
sharesCount: 0,
spaceId: '',
approvedInRootPost: post.approvedInRootPost ?? false,
approvedInRootPostAtTime: post.approvedInRootPostAtTime ?? '',
approvedInRootPostAtTime: new Date(post.approvedInRootPostAtTime).getTime(),
isUpdated: false,
rootPostId: post.rootPost?.persistentId ?? '',
parentPostId: null,
Expand Down

0 comments on commit 04765a8

Please sign in to comment.