lint fix wip

This commit is contained in:
Nicolas Cantu 2026-01-07 11:36:24 +01:00
parent b69dfc96e9
commit ddda722141
6 changed files with 64 additions and 17 deletions

View File

@ -40,7 +40,14 @@ export function ReviewTipForm({ review, article, onSuccess, onCancel }: ReviewTi
const split = calculateReviewSplit() const split = calculateReviewSplit()
// Build zap request tags // 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({ const zapRequestTags = buildReviewTipZapRequestTags({
articleId: article.id, articleId: article.id,
reviewId: review.id, reviewId: review.id,

View File

@ -44,7 +44,14 @@ async function buildParsedArticleFromDraft(
invoice: AlbyInvoice, invoice: AlbyInvoice,
authorPubkey: string authorPubkey: string
): Promise<{ article: Article; hash: string; version: number; index: number }> { ): 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({ const hashId = await generatePublicationHashId({
pubkey: authorPubkey, pubkey: authorPubkey,
@ -103,16 +110,12 @@ async function publishPreviewWithInvoice(
let index: number let index: number
if (customArticle) { if (customArticle) {
;({ hash, version } = customArticle)
article = customArticle article = customArticle
hash = customArticle.hash
version = customArticle.version
index = customArticle.index ?? 0 index = customArticle.index ?? 0
} else { } else {
const built = await buildParsedArticleFromDraft(draft, invoice, authorPubkey) const built = await buildParsedArticleFromDraft(draft, invoice, authorPubkey)
article = built.article ;({ article, hash, version, index } = built)
hash = built.hash
version = built.version
index = built.index
} }
// Build event template // Build event template

View File

@ -166,7 +166,14 @@ export async function parsePresentationEvent(event: Event): Promise<import('@/ty
} }
// Map tag category to article category // Map tag category to article category
const articleCategory = tags.category === 'sciencefiction' ? 'science-fiction' : tags.category === 'research' ? 'scientific-research' : undefined let articleCategory: 'science-fiction' | 'scientific-research' | undefined
if (tags.category === 'sciencefiction') {
articleCategory = 'science-fiction'
} else if (tags.category === 'research') {
articleCategory = 'scientific-research'
} else {
articleCategory = undefined
}
// Extract hash, version, index from id tag or parse it // Extract hash, version, index from id tag or parse it
let hash: string let hash: string
@ -176,7 +183,7 @@ export async function parsePresentationEvent(event: Event): Promise<import('@/ty
if (tags.id) { if (tags.id) {
const parsed = parseObjectId(tags.id) const parsed = parseObjectId(tags.id)
if (parsed.hash) { if (parsed.hash) {
hash = parsed.hash ;({ hash } = parsed)
version = parsed.version ?? version version = parsed.version ?? version
index = parsed.index ?? index index = parsed.index ?? index
} else { } else {
@ -219,7 +226,15 @@ export async function parsePresentationEvent(event: Event): Promise<import('@/ty
.join('\n') .join('\n')
.trim() .trim()
})(), // Required field })(), // Required field
thumbnailUrl: (typeof profileData?.pictureUrl === 'string' ? profileData.pictureUrl : typeof tags.pictureUrl === 'string' ? tags.pictureUrl : ''), // Required field thumbnailUrl: ((): string => {
if (typeof profileData?.pictureUrl === 'string') {
return profileData.pictureUrl
}
if (typeof tags.pictureUrl === 'string') {
return tags.pictureUrl
}
return ''
})(), // Required field
createdAt: event.created_at, createdAt: event.created_at,
zapAmount: 0, zapAmount: 0,
paid: true, paid: true,

View File

@ -26,7 +26,14 @@ async function buildParsedArticleFromDraft(
invoice: AlbyInvoice, invoice: AlbyInvoice,
authorPubkey: string authorPubkey: string
): Promise<{ article: Article; hash: string; version: number; index: number }> { ): 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({ const hashId = await generatePublicationHashId({
pubkey: authorPubkey, pubkey: authorPubkey,

View File

@ -174,7 +174,14 @@ function getPreviewContent(content: string, previewTag?: string): { previewConte
async function buildArticle(event: Event, tags: ReturnType<typeof extractTagsFromEvent>, preview: string): Promise<Article> { async function buildArticle(event: Event, tags: ReturnType<typeof extractTagsFromEvent>, preview: string): Promise<Article> {
// Map category from new system to old system // 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' const isPresentation = tags.type === 'author'
// Extract hash, version, index from id tag or parse it // Extract hash, version, index from id tag or parse it
@ -185,7 +192,7 @@ async function buildArticle(event: Event, tags: ReturnType<typeof extractTagsFro
if (tags.id) { if (tags.id) {
const parsed = parseObjectId(tags.id) const parsed = parseObjectId(tags.id)
if (parsed.hash) { if (parsed.hash) {
hash = parsed.hash ;({ hash } = parsed)
version = parsed.version ?? version version = parsed.version ?? version
index = parsed.index ?? index index = parsed.index ?? index
} else { } else {
@ -219,7 +226,7 @@ async function buildArticle(event: Event, tags: ReturnType<typeof extractTagsFro
pages = metadataPages pages = metadataPages
} }
} }
} catch (e) { } catch (_e) {
// Ignore JSON parsing errors // Ignore JSON parsing errors
} }
@ -237,7 +244,15 @@ async function buildArticle(event: Event, tags: ReturnType<typeof extractTagsFro
createdAt: event.created_at, createdAt: event.created_at,
zapAmount: tags.zapAmount ?? 800, zapAmount: tags.zapAmount ?? 800,
paid: false, paid: false,
thumbnailUrl: typeof tags.bannerUrl === 'string' ? tags.bannerUrl : typeof tags.pictureUrl === 'string' ? tags.pictureUrl : '', // Required field with default thumbnailUrl: ((): string => {
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.invoice ? { invoice: tags.invoice } : {}),
...(tags.paymentHash ? { paymentHash: tags.paymentHash } : {}), ...(tags.paymentHash ? { paymentHash: tags.paymentHash } : {}),
...(category ? { category } : {}), ...(category ? { category } : {}),

View File

@ -83,7 +83,7 @@ class PublishWorkerService {
if (isReady) { if (isReady) {
await swClient.stopPublishWorker() await swClient.stopPublishWorker()
} }
} catch (error) { } catch (_error) {
// Ignore errors // Ignore errors
} }
} }