refac: citation

This commit is contained in:
Timothy Jaeryang Baek committed 2025-12-26 02:05:03 +04:00
1 parent 2e9e46a9f1
commit c0ec04935b
4 files changed
+69 -30

No files matched your search

@@ -23,12 +23,26 @@
let selectedCitation: any = null;
export const showSourceModal = (sourceIdx) => {
if (citations[sourceIdx]) {
console.log('Showing citation modal for:', citations[sourceIdx]);
export const showSourceModal = (sourceId) => {
let index;
let suffix = null;
if (citations[sourceIdx]?.source?.embed_url) {
const embedUrl = citations[sourceIdx].source.embed_url;
if (typeof sourceId === 'string') {
const output = sourceId.split('#');
index = parseInt(output[0]) - 1;
if (output.length > 1) {
suffix = output[1];
}
} else {
index = sourceId - 1;
}
if (citations[index]) {
console.log('Showing citation modal for:', citations[index]);
if (citations[index]?.source?.embed_url) {
const embedUrl = citations[index].source.embed_url;
if (embedUrl) {
if (readOnly) {
// Open in new tab if readOnly
@@ -39,18 +53,19 @@
showEmbeds.set(true);
embed.set({
url: embedUrl,
title: citations[sourceIdx]?.source?.name || 'Embedded Content',
source: citations[sourceIdx],
title: citations[index]?.source?.name || 'Embedded Content',
source: citations[index],
chatId: chatId,
messageId: id
messageId: id,
sourceId: sourceId
});
}
} else {
selectedCitation = citations[sourceIdx];
selectedCitation = citations[index];
showCitationModal = true;
}
} else {
selectedCitation = citations[sourceIdx];
selectedCitation = citations[index];
showCitationModal = true;
}
}