diff --git a/src/app/components/News.tsx b/src/app/components/News.tsx
index 710a794..135fa76 100644
--- a/src/app/components/News.tsx
+++ b/src/app/components/News.tsx
@@ -23,10 +23,18 @@ export default function News() {
-
- eeXiv 2.1 has been released! Documents are now statically generated
- for instant loading speeds.{' '}
+ eeXiv 2.2 has been released! You can now select document version and
+ export as BibTex.{' '}
+
+ -
+ We are working on becoming a{' '}
+
+ ISO 26324 DOI registry!
+
- - Mobile support is currently in beta.
-
eeXiv is currently under active development! There may be major
updates, breaking changes, or weird bugs. Report bugs, suggest new
diff --git a/src/app/db/loaders.ts b/src/app/db/loaders.ts
index 4e40eec..86f0be7 100644
--- a/src/app/db/loaders.ts
+++ b/src/app/db/loaders.ts
@@ -1,5 +1,11 @@
import { Document, Author, Affiliation, Topic, Nationality } from './data'
+/**
+ * Loads a document with the given ID using a web worker if available, and returns a promise that resolves with the document.
+ *
+ * @param {string} id - The ID of the document to load
+ * @return {Promise} A promise that resolves with the loaded document, or rejects with an error
+ */
export const loadDocument = (id: string): Promise => {
return new Promise((resolve, reject) => {
if (typeof Worker !== 'undefined') {
@@ -8,13 +14,12 @@ export const loadDocument = (id: string): Promise => {
{ type: 'module' }
)
- worker.onmessage = (e: MessageEvent<{ [key: string]: Document }>) => {
+ worker.onmessage = (e: MessageEvent) => {
const data = e.data
- const doc: Document | undefined = data[id]
- if (!doc) {
+ if (!data) {
return reject(new Error('404'))
} else {
- resolve(doc)
+ resolve(data)
}
worker.terminate()
}
@@ -24,7 +29,7 @@ export const loadDocument = (id: string): Promise => {
worker.terminate()
}
- worker.postMessage('LOAD')
+ worker.postMessage(id)
} else {
reject(
new Error(
@@ -34,6 +39,9 @@ export const loadDocument = (id: string): Promise => {
}
})
}
+/**
+ * @deprecated This function doesn't improve efficiency and shouldn't be used
+ */
export const loadAllDocuments = (): Promise<{ [key: string]: Document }> => {
return new Promise((resolve, reject) => {
if (typeof Worker !== 'undefined') {
diff --git a/src/app/db/workers/documentLoader.worker.ts b/src/app/db/workers/documentLoader.worker.ts
index b263e79..1ea6e60 100644
--- a/src/app/db/workers/documentLoader.worker.ts
+++ b/src/app/db/workers/documentLoader.worker.ts
@@ -1,7 +1,5 @@
import { documents } from '../data'
onmessage = (e) => {
- if (e.data === 'LOAD') {
- self.postMessage(documents)
- }
+ typeof e.data === 'string' && postMessage(documents[e.data])
}