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()
// 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,

View File

@ -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

View File

@ -166,7 +166,14 @@ export async function parsePresentationEvent(event: Event): Promise<import('@/ty
}
// 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
let hash: string
@ -176,7 +183,7 @@ export async function parsePresentationEvent(event: Event): Promise<import('@/ty
if (tags.id) {
const parsed = parseObjectId(tags.id)
if (parsed.hash) {
hash = parsed.hash
;({ hash } = parsed)
version = parsed.version ?? version
index = parsed.index ?? index
} else {
@ -219,7 +226,15 @@ export async function parsePresentationEvent(event: Event): Promise<import('@/ty
.join('\n')
.trim()
})(), // 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,
zapAmount: 0,
paid: true,

View File

@ -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,

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> {
// 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<typeof extractTagsFro
if (tags.id) {
const parsed = parseObjectId(tags.id)
if (parsed.hash) {
hash = parsed.hash
;({ hash } = parsed)
version = parsed.version ?? version
index = parsed.index ?? index
} else {
@ -219,7 +226,7 @@ async function buildArticle(event: Event, tags: ReturnType<typeof extractTagsFro
pages = metadataPages
}
}
} catch (e) {
} catch (_e) {
// Ignore JSON parsing errors
}
@ -237,7 +244,15 @@ async function buildArticle(event: Event, tags: ReturnType<typeof extractTagsFro
createdAt: event.created_at,
zapAmount: tags.zapAmount ?? 800,
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.paymentHash ? { paymentHash: tags.paymentHash } : {}),
...(category ? { category } : {}),

View File

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