From 0369eb6e0e3473013cf1aae6def365c9dc69bb3d Mon Sep 17 00:00:00 2001 From: sabaimran Date: Wed, 10 Jul 2024 14:53:31 +0530 Subject: [PATCH] Fix timestamp bug for pending message and expand CSP for thumbnails --- src/interface/web/app/chat/layout.tsx | 2 +- .../web/app/components/chatHistory/chatHistory.tsx | 2 +- .../web/app/components/chatMessage/chatMessage.tsx | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/interface/web/app/chat/layout.tsx b/src/interface/web/app/chat/layout.tsx index 5f4ed222..1da0e7a7 100644 --- a/src/interface/web/app/chat/layout.tsx +++ b/src/interface/web/app/chat/layout.tsx @@ -21,7 +21,7 @@ export default function RootLayout({ script-src 'self' https://assets.khoj.dev 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https://ipapi.co/json ws://localhost:42110; style-src 'self' https://assets.khoj.dev 'unsafe-inline' https://fonts.googleapis.com; - img-src 'self' data: https://*.khoj.dev https://*.googleusercontent.com; + img-src 'self' data: https://*.khoj.dev https://*.googleusercontent.com https://*.google.com/ https://*.gstatic.com; font-src 'self' https://assets.khoj.dev https://fonts.gstatic.com; child-src 'none'; object-src 'none';"> diff --git a/src/interface/web/app/components/chatHistory/chatHistory.tsx b/src/interface/web/app/components/chatHistory/chatHistory.tsx index 0dc39173..1c67a812 100644 --- a/src/interface/web/app/components/chatHistory/chatHistory.tsx +++ b/src/interface/web/app/components/chatHistory/chatHistory.tsx @@ -299,7 +299,7 @@ export default function ChatHistory(props: ChatHistoryProps) { message: props.pendingMessage, context: [], onlineContext: {}, - created: new Date().toISOString(), + created: (new Date().getTime()).toString(), by: "you", automationId: '', } diff --git a/src/interface/web/app/components/chatMessage/chatMessage.tsx b/src/interface/web/app/components/chatMessage/chatMessage.tsx index c3696323..3561b315 100644 --- a/src/interface/web/app/components/chatMessage/chatMessage.tsx +++ b/src/interface/web/app/components/chatMessage/chatMessage.tsx @@ -267,7 +267,12 @@ export default function ChatMessage(props: ChatMessageProps) { } function renderTimeStamp(timestamp: string) { - const messageDateTime = new Date(timestamp + 'Z'); + + console.log("INCOMING TIMESTAMP", timestamp); + if (!timestamp.endsWith('Z')) { + timestamp = timestamp + 'Z'; + } + const messageDateTime = new Date(timestamp); const currentDataTime = new Date(); const timeDiff = currentDataTime.getTime() - messageDateTime.getTime();