in the middle of fixing

This commit is contained in:
Team 1280 Programming Laptop 2024-02-14 18:42:48 -08:00
parent 5bfcf96987
commit 7e5649c648
3 changed files with 22 additions and 9 deletions

View file

@ -88,7 +88,7 @@ export const loadAllAuthors = (): Promise<{ [key: string]: Author }> => {
})
}
export const loadAuthor = (id: string): Promise<Author> => {
export const loadAuthors = (authorIds: string[]): Promise<Author> => {
return new Promise((resolve, reject) => {
if (typeof Worker !== 'undefined') {
const worker = new Worker(

View file

@ -1,7 +1,18 @@
import { authors } from '../data'
import { authors, Author } from '../data'
const checkIsStringArray = (data: unknown): data is string[] => {
if (Array.isArray(data)) {
return data.every((d) => typeof d === 'string')
}
return false
}
onmessage = (e) => {
if (e.data === 'LOAD') {
self.postMessage(authors)
}
let authorIds: string[] = []
let authors = []
checkIsStringArray(e.data) && (authorIds = e.data as string[])
authorIds.forEach(id => {
})
}

View file

@ -1,5 +1,5 @@
'use client'
import { useState } from 'react'
import { useState, useEffect } from 'react'
import { Document } from '@/app/db/data'
import Link from 'next/link'
import { loadAllAuthors } from '@/app/db/loaders'
@ -18,8 +18,10 @@ const VersionChooser = ({
},
})
if (error) throw error
let authorList = data
useEffect(() => {
console.log(data)
}, [data])
const { file } = doc
const { authors, latest } = doc.manifest
@ -52,7 +54,7 @@ const VersionChooser = ({
const bibtex = `@article{
author={${authors
.map((a: string, i) => {
const author = authorList[a].name.first + ' ' + authorList[a].name.last
const author = data[a].name.first + ' ' + data[a].name.last
if (i === 0) return author
else if (i === authors.length - 1) return ` and ${author}`
else return `, ${author}`