Skip to content
Snippets Groups Projects
Commit 7618e648 authored by Léopold Chappuis's avatar Léopold Chappuis Committed by Léopold Chappuis
Browse files

cleanup: move timestamp to number

Change-Id: I65e822746155c9a2367d49606322ea8c61cbc723
parent c86854b1
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,7 @@ import MediaViewer from './MediaViewer' ...@@ -32,7 +32,7 @@ import MediaViewer from './MediaViewer'
interface ConversationSettingsFileItemProps { interface ConversationSettingsFileItemProps {
displayName: string displayName: string
timeStamp: string timeStamp: number
totalSize: number totalSize: number
fileId: string fileId: string
author: string author: string
......
...@@ -61,12 +61,7 @@ export const ConversationSummaryList = ({ conversationsSummaries }: Conversation ...@@ -61,12 +61,7 @@ export const ConversationSummaryList = ({ conversationsSummaries }: Conversation
if (conversationsSummaries.some((conversationSummary) => conversationSummary === null)) { if (conversationsSummaries.some((conversationSummary) => conversationSummary === null)) {
return conversationsSummaries return conversationsSummaries
} }
return [...conversationsSummaries].sort((a, b) => b.lastMessage.timestamp - a.lastMessage.timestamp)
return [...conversationsSummaries].sort((a, b) => {
const aTimestamp = a?.lastMessage?.timestamp ? Number(a.lastMessage.timestamp) : 0
const bTimestamp = b?.lastMessage?.timestamp ? Number(b.lastMessage.timestamp) : 0
return bTimestamp - aTimestamp
})
}, [conversationsSummaries]) }, [conversationsSummaries])
return ( return (
......
...@@ -39,7 +39,7 @@ interface MediaViewerProps { ...@@ -39,7 +39,7 @@ interface MediaViewerProps {
member?: ConversationMember member?: ConversationMember
handleDownload?: () => void handleDownload?: () => void
type?: string type?: string
timeStamp?: string timeStamp?: number
} }
export default function MediaViewer({ export default function MediaViewer({
...@@ -111,7 +111,7 @@ export default function MediaViewer({ ...@@ -111,7 +111,7 @@ export default function MediaViewer({
} }
} }
const displayTime = dayjs.unix(Number(timeStamp)) const displayTime = dayjs.unix(timeStamp || 0)
const formattedTime = displayTime.format('YYYY-MM-DD HH:mm') const formattedTime = displayTime.format('YYYY-MM-DD HH:mm')
return ( return (
......
...@@ -778,8 +778,8 @@ const UserMessageRow = memo( ...@@ -778,8 +778,8 @@ const UserMessageRow = memo(
const { t } = useTranslation() const { t } = useTranslation()
const previousIsUserMessageType = checkIsUserMessageType(previousMessage?.type) const previousIsUserMessageType = checkIsUserMessageType(previousMessage?.type)
const nextIsUserMessageType = checkIsUserMessageType(nextMessage?.type) const nextIsUserMessageType = checkIsUserMessageType(nextMessage?.type)
const nextTime = dayjs.unix(Number(nextMessage?.timestamp)) const nextTime = dayjs.unix(nextMessage?.timestamp || 0)
const sentTime = dayjs.unix(Number(message.timestamp)) const sentTime = dayjs.unix(message.timestamp)
const nextShowsTime = checkShowsTime(nextTime, sentTime) const nextShowsTime = checkShowsTime(nextTime, sentTime)
const isFirstOfGroup = showsTime || !previousIsUserMessageType || previousMessage?.author !== message.author const isFirstOfGroup = showsTime || !previousIsUserMessageType || previousMessage?.author !== message.author
const isLastOfGroup = nextShowsTime || !nextIsUserMessageType || message.author !== nextMessage?.author const isLastOfGroup = nextShowsTime || !nextIsUserMessageType || message.author !== nextMessage?.author
...@@ -1388,8 +1388,8 @@ interface MessageProps { ...@@ -1388,8 +1388,8 @@ interface MessageProps {
} }
export const MessageRow = memo(({ message, isAccountMessage, author, previousMessage, nextMessage }: MessageProps) => { export const MessageRow = memo(({ message, isAccountMessage, author, previousMessage, nextMessage }: MessageProps) => {
const time = dayjs.unix(Number(message.timestamp)) const time = dayjs.unix(message.timestamp)
const previousTime = dayjs.unix(Number(previousMessage?.timestamp)) const previousTime = dayjs.unix(previousMessage?.timestamp || 0)
const showDate = const showDate =
message?.type === 'initial' || previousTime.year() !== time.year() || previousTime.dayOfYear() !== time.dayOfYear() message?.type === 'initial' || previousTime.year() !== time.year() || previousTime.dayOfYear() !== time.dayOfYear()
const showTime = checkShowsTime(time, previousTime) const showTime = checkShowsTime(time, previousTime)
......
...@@ -51,7 +51,7 @@ export const SelectConversationList = ({ ...@@ -51,7 +51,7 @@ export const SelectConversationList = ({
if (conversationsSummaries.some((conversationSummary) => conversationSummary === null)) { if (conversationsSummaries.some((conversationSummary) => conversationSummary === null)) {
return conversationsSummaries return conversationsSummaries
} }
return [...conversationsSummaries].sort((a, b) => Number(b.lastMessage.timestamp) - Number(a.lastMessage.timestamp)) return [...conversationsSummaries].sort((a, b) => b.lastMessage.timestamp - a.lastMessage.timestamp)
}, [conversationsSummaries]) }, [conversationsSummaries])
return ( return (
......
...@@ -37,7 +37,7 @@ export interface Reaction { ...@@ -37,7 +37,7 @@ export interface Reaction {
export interface Message { export interface Message {
id: string id: string
author: string author: string
timestamp: string timestamp: number
type: type:
| 'application/call-history+json' | 'application/call-history+json'
| 'application/data-transfer+json' | 'application/data-transfer+json'
......
...@@ -96,7 +96,7 @@ export class Jamid { ...@@ -96,7 +96,7 @@ export class Jamid {
author: message.body.author, author: message.body.author,
linearizedParent: message.linearizedParent, linearizedParent: message.linearizedParent,
parents: message.body.parents, parents: message.body.parents,
timestamp: message.body.timestamp, timestamp: message.body.timestamp ? Number(message.body.timestamp) : 0,
duration: message.body.duration, duration: message.body.duration,
displayName: message.body.displayName, displayName: message.body.displayName,
sha3sum: message.body.sha3sum, sha3sum: message.body.sha3sum,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment