Clean up editor code and reorganize contents (#478)
This commit is contained in:
parent
b3aa3cb18a
commit
5190b109c9
19 changed files with 475 additions and 444 deletions
12
lib/utils.ts
12
lib/utils.ts
|
|
@ -9,7 +9,7 @@ import {
|
|||
import { clsx, type ClassValue } from 'clsx';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
|
||||
import { Chat } from '@/db/schema';
|
||||
import { Chat, Document } from '@/db/schema';
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
|
|
@ -221,3 +221,13 @@ export function sanitizeUIMessages(messages: Array<Message>): Array<Message> {
|
|||
(message.toolInvocations && message.toolInvocations.length > 0)
|
||||
);
|
||||
}
|
||||
|
||||
export function getDocumentTimestampByIndex(
|
||||
documents: Array<Document>,
|
||||
index: number
|
||||
) {
|
||||
if (!documents) return new Date();
|
||||
if (index > documents.length) return new Date();
|
||||
|
||||
return documents[index].createdAt;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue