広場投稿追加画面の刷新 (#399) #413

マージ済み
みてるぞ が 103 個のコミットを feature/399 から main へマージ 2026-07-19 00:03:11 +09:00
コミット 7c808a6f76 の変更だけを表示してゐます - すべてのコミットを表示
+52 -11
ファイルの表示
@@ -145,6 +145,16 @@ const shouldFetchMetadata = (row: PostImportRow): boolean =>
&& !(isNonRecoverableFailedRow (row))
&& row.metadataUrl == null
const shouldHydrateExistingPost = (row: PostImportRow): boolean =>
row.skipReason === 'existing'
&& row.existingPostId != null
&& row.existingPost == null
&& row.importStatus !== 'created'
&& row.importStatus !== 'skipped'
const shouldFetchReviewRow = (row: PostImportRow): boolean =>
shouldFetchMetadata (row) || shouldHydrateExistingPost (row)
const applyDuplicateUrlErrors = (
rows: PostImportRow[],
): PostImportRow[] => {
@@ -356,7 +366,7 @@ const indexedBulkResults = (
sourceRow: row.sourceRow,
status: 'skipped',
existingPostId,
existingPost: result.existingPost,
existingPost: result.existingPost ?? row.existingPost,
fieldWarnings: result.fieldWarnings,
baseWarnings: result.baseWarnings,
errors }
@@ -454,6 +464,21 @@ const mergePreviewRow = (
}
const mergeExistingSkippedRow = (
currentRow: PostImportRow,
preview: PostMetadataResponse,
): PostImportRow =>
preview.existingPostId != null || preview.existingPost?.id != null
? {
...currentRow,
url: preview.url,
existingPostId: preview.existingPostId ?? preview.existingPost?.id,
existingPost: preview.existingPost ?? currentRow.existingPost,
skipReason: 'existing',
metadataUrl: preview.url }
: currentRow
const buildBulkFormData = (rows: PostImportRow[]): FormData => {
const formData = new FormData ()
formData.append (
@@ -478,14 +503,25 @@ const buildBulkFormData = (rows: PostImportRow[]): FormData => {
const ExistingSkippedRows: FC<ExistingSkippedRowsProps> = ({ id, rows }) => {
const posts = rows
.map (row => row.existingPost)
.filter ((post): post is NonNullable<PostImportRow['existingPost']> => post != null)
return (
<div id={id} className="mt-3 max-h-72 overflow-y-auto rounded border">
<div className="divide-y">
{posts.map (post => {
{rows.map (row => {
const post = row.existingPost
if (post == null)
{
return (
<div key={row.sourceRow} className="flex items-center gap-3 p-3">
<PostThumbnailPreview
url=""
className="h-10 w-10 shrink-0"/>
<div className="min-w-0 flex-1">
<div className="truncate text-xs text-neutral-600 dark:text-neutral-300">
{row.url}
</div>
</div>
</div>)
}
return (
<PrefetchLink
key={post.id}
@@ -620,13 +656,14 @@ const PostImportReviewPage: FC<Props> = ({ user }) => {
if (sessionRef.current != null
&& persistedSearchRef.current === location.search
&& !(sessionRef.current.rows.some (row => shouldFetchMetadata (row))))
&& !(sessionRef.current.rows.some (row => shouldFetchReviewRow (row))))
return () => {
previewSequenceRef.current = previewSequence
}
const refreshRows = async (baseSession: PostImportSession) => {
if (active)
const blocksSubmit = baseSession.rows.some (row => shouldFetchMetadata (row))
if (active && blocksSubmit)
setMetadataLoading (true)
try
{
@@ -652,7 +689,7 @@ const PostImportReviewPage: FC<Props> = ({ user }) => {
const baseRow = baseSession.rows[index]
const currentRow = currentRowBySource (baseRow.sourceRow, baseSession)
if (currentRow == null || !(shouldFetchMetadata (currentRow)))
if (currentRow == null || !(shouldFetchReviewRow (currentRow)))
continue
const controller = new AbortController ()
controllers.add (controller)
@@ -669,7 +706,9 @@ const PostImportReviewPage: FC<Props> = ({ user }) => {
|| isNonRecoverableFailedRow (row)
|| row.skipReason === 'manual'
? row
: mergePreviewRow (row, preview))
: (shouldFetchMetadata (row)
? mergePreviewRow (row, preview)
: mergeExistingSkippedRow (row, preview)))
}
catch (requestError)
{
@@ -723,7 +762,9 @@ const PostImportReviewPage: FC<Props> = ({ user }) => {
}
finally
{
if (active && metadataSequenceRef.current === previewSequence)
if (active
&& blocksSubmit
&& metadataSequenceRef.current === previewSequence)
setMetadataLoading (false)
}
}