diff --git a/components/ReviewTipForm.tsx b/components/ReviewTipForm.tsx index b66e8e8..8bea3d2 100644 --- a/components/ReviewTipForm.tsx +++ b/components/ReviewTipForm.tsx @@ -40,7 +40,14 @@ export function ReviewTipForm({ review, article, onSuccess, onCancel }: ReviewTi const split = calculateReviewSplit() // Build zap request tags - const category = article.category === 'author-presentation' ? undefined : (article.category === 'science-fiction' || article.category === 'scientific-research' ? article.category : undefined) + let category: 'science-fiction' | 'scientific-research' | undefined + if (article.category === 'author-presentation') { + category = undefined + } else if (article.category === 'science-fiction' || article.category === 'scientific-research') { + category = article.category + } else { + category = undefined + } const zapRequestTags = buildReviewTipZapRequestTags({ articleId: article.id, reviewId: review.id, diff --git a/lib/articleMutations.ts b/lib/articleMutations.ts index 75f6655..5d426d8 100644 --- a/lib/articleMutations.ts +++ b/lib/articleMutations.ts @@ -44,7 +44,14 @@ async function buildParsedArticleFromDraft( invoice: AlbyInvoice, authorPubkey: string ): Promise<{ article: Article; hash: string; version: number; index: number }> { - const category = draft.category === 'science-fiction' ? 'sciencefiction' : draft.category === 'scientific-research' ? 'research' : 'sciencefiction' + let category: string + if (draft.category === 'science-fiction') { + category = 'sciencefiction' + } else if (draft.category === 'scientific-research') { + category = 'research' + } else { + category = 'sciencefiction' + } const hashId = await generatePublicationHashId({ pubkey: authorPubkey, @@ -103,16 +110,12 @@ async function publishPreviewWithInvoice( let index: number if (customArticle) { + ;({ hash, version } = customArticle) article = customArticle - hash = customArticle.hash - version = customArticle.version index = customArticle.index ?? 0 } else { const built = await buildParsedArticleFromDraft(draft, invoice, authorPubkey) - article = built.article - hash = built.hash - version = built.version - index = built.index + ;({ article, hash, version, index } = built) } // Build event template diff --git a/lib/articlePublisherHelpersPresentation.ts b/lib/articlePublisherHelpersPresentation.ts index 2ff0eb0..b5d3a2b 100644 --- a/lib/articlePublisherHelpersPresentation.ts +++ b/lib/articlePublisherHelpersPresentation.ts @@ -166,7 +166,14 @@ export async function parsePresentationEvent(event: Event): Promise { + if (typeof profileData?.pictureUrl === 'string') { + return profileData.pictureUrl + } + if (typeof tags.pictureUrl === 'string') { + return tags.pictureUrl + } + return '' + })(), // Required field createdAt: event.created_at, zapAmount: 0, paid: true, diff --git a/lib/articlePublisherPublish.ts b/lib/articlePublisherPublish.ts index ecaa737..683e7c3 100644 --- a/lib/articlePublisherPublish.ts +++ b/lib/articlePublisherPublish.ts @@ -26,7 +26,14 @@ async function buildParsedArticleFromDraft( invoice: AlbyInvoice, authorPubkey: string ): Promise<{ article: Article; hash: string; version: number; index: number }> { - const category = draft.category === 'science-fiction' ? 'sciencefiction' : draft.category === 'scientific-research' ? 'research' : 'sciencefiction' + let category: string + if (draft.category === 'science-fiction') { + category = 'sciencefiction' + } else if (draft.category === 'scientific-research') { + category = 'research' + } else { + category = 'sciencefiction' + } const hashId = await generatePublicationHashId({ pubkey: authorPubkey, diff --git a/lib/nostrEventParsing.ts b/lib/nostrEventParsing.ts index 75abbe7..7c3dc44 100644 --- a/lib/nostrEventParsing.ts +++ b/lib/nostrEventParsing.ts @@ -174,7 +174,14 @@ function getPreviewContent(content: string, previewTag?: string): { previewConte async function buildArticle(event: Event, tags: ReturnType, preview: string): Promise
{ // Map category from new system to old system - const category = tags.category === 'sciencefiction' ? 'science-fiction' : tags.category === 'research' ? 'scientific-research' : undefined + let category: 'science-fiction' | 'scientific-research' | undefined + if (tags.category === 'sciencefiction') { + category = 'science-fiction' + } else if (tags.category === 'research') { + category = 'scientific-research' + } else { + category = undefined + } const isPresentation = tags.type === 'author' // Extract hash, version, index from id tag or parse it @@ -185,7 +192,7 @@ async function buildArticle(event: Event, tags: ReturnType { + if (typeof tags.bannerUrl === 'string') { + return tags.bannerUrl + } + if (typeof tags.pictureUrl === 'string') { + return tags.pictureUrl + } + return '' + })(), // Required field with default ...(tags.invoice ? { invoice: tags.invoice } : {}), ...(tags.paymentHash ? { paymentHash: tags.paymentHash } : {}), ...(category ? { category } : {}), diff --git a/lib/publishWorker.ts b/lib/publishWorker.ts index b939586..04bce0a 100644 --- a/lib/publishWorker.ts +++ b/lib/publishWorker.ts @@ -83,7 +83,7 @@ class PublishWorkerService { if (isReady) { await swClient.stopPublishWorker() } - } catch (error) { + } catch (_error) { // Ignore errors } }