fix error cuando solo hay un párrafo devuelve como objeto
This commit is contained in:
parent
7430e17a52
commit
2ac1077a1b
|
|
@ -473,7 +473,8 @@ async function fetchDocumentWithParagraphs(docId: string) {
|
||||||
const hit = (res?.results?.[0] as { hits?: Array<{ document: Record<string, unknown> }> })?.hits?.[0]
|
const hit = (res?.results?.[0] as { hits?: Array<{ document: Record<string, unknown> }> })?.hits?.[0]
|
||||||
if (hit) {
|
if (hit) {
|
||||||
const docRaw = { ...hit.document }
|
const docRaw = { ...hit.document }
|
||||||
const rawParagraphs = (docRaw[props.paragraphsCollection] as ParagraphDoc[] | undefined) ?? []
|
const raw = docRaw[props.paragraphsCollection]
|
||||||
|
const rawParagraphs = Array.isArray(raw) ? raw : (raw ? [raw] : []) as ParagraphDoc[]
|
||||||
delete docRaw[props.paragraphsCollection]
|
delete docRaw[props.paragraphsCollection]
|
||||||
selectedDocument.value = docRaw as unknown as DocumentDoc
|
selectedDocument.value = docRaw as unknown as DocumentDoc
|
||||||
selectedParagraphs.value = [...rawParagraphs]
|
selectedParagraphs.value = [...rawParagraphs]
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,8 @@ export function usePublicationFetch() {
|
||||||
const docHit = (res?.results?.[0] as { hits?: Array<{ document: Record<string, unknown> }> })?.hits?.[0]
|
const docHit = (res?.results?.[0] as { hits?: Array<{ document: Record<string, unknown> }> })?.hits?.[0]
|
||||||
if (docHit) {
|
if (docHit) {
|
||||||
const docRaw = { ...docHit.document }
|
const docRaw = { ...docHit.document }
|
||||||
const rawParagraphs = (docRaw[config.paragraphs] as ParagraphDoc[] | undefined) ?? []
|
const raw = docRaw[config.paragraphs]
|
||||||
|
const rawParagraphs = Array.isArray(raw) ? raw : (raw ? [raw] : []) as ParagraphDoc[]
|
||||||
delete docRaw[config.paragraphs]
|
delete docRaw[config.paragraphs]
|
||||||
detailDocument.value = docRaw as unknown as DocumentDoc
|
detailDocument.value = docRaw as unknown as DocumentDoc
|
||||||
detailParagraphs.value = [...rawParagraphs]
|
detailParagraphs.value = [...rawParagraphs]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue