このコミットが含まれているのは:
@@ -145,6 +145,16 @@ const shouldFetchMetadata = (row: PostImportRow): boolean =>
|
|||||||
&& !(isNonRecoverableFailedRow (row))
|
&& !(isNonRecoverableFailedRow (row))
|
||||||
&& row.metadataUrl == null
|
&& 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 = (
|
const applyDuplicateUrlErrors = (
|
||||||
rows: PostImportRow[],
|
rows: PostImportRow[],
|
||||||
): PostImportRow[] => {
|
): PostImportRow[] => {
|
||||||
@@ -356,7 +366,7 @@ const indexedBulkResults = (
|
|||||||
sourceRow: row.sourceRow,
|
sourceRow: row.sourceRow,
|
||||||
status: 'skipped',
|
status: 'skipped',
|
||||||
existingPostId,
|
existingPostId,
|
||||||
existingPost: result.existingPost,
|
existingPost: result.existingPost ?? row.existingPost,
|
||||||
fieldWarnings: result.fieldWarnings,
|
fieldWarnings: result.fieldWarnings,
|
||||||
baseWarnings: result.baseWarnings,
|
baseWarnings: result.baseWarnings,
|
||||||
errors }
|
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 buildBulkFormData = (rows: PostImportRow[]): FormData => {
|
||||||
const formData = new FormData ()
|
const formData = new FormData ()
|
||||||
formData.append (
|
formData.append (
|
||||||
@@ -478,14 +503,25 @@ const buildBulkFormData = (rows: PostImportRow[]): FormData => {
|
|||||||
|
|
||||||
|
|
||||||
const ExistingSkippedRows: FC<ExistingSkippedRowsProps> = ({ id, rows }) => {
|
const ExistingSkippedRows: FC<ExistingSkippedRowsProps> = ({ id, rows }) => {
|
||||||
const posts = rows
|
|
||||||
.map (row => row.existingPost)
|
|
||||||
.filter ((post): post is NonNullable<PostImportRow['existingPost']> => post != null)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id={id} className="mt-3 max-h-72 overflow-y-auto rounded border">
|
<div id={id} className="mt-3 max-h-72 overflow-y-auto rounded border">
|
||||||
<div className="divide-y">
|
<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 (
|
return (
|
||||||
<PrefetchLink
|
<PrefetchLink
|
||||||
key={post.id}
|
key={post.id}
|
||||||
@@ -620,13 +656,14 @@ const PostImportReviewPage: FC<Props> = ({ user }) => {
|
|||||||
|
|
||||||
if (sessionRef.current != null
|
if (sessionRef.current != null
|
||||||
&& persistedSearchRef.current === location.search
|
&& persistedSearchRef.current === location.search
|
||||||
&& !(sessionRef.current.rows.some (row => shouldFetchMetadata (row))))
|
&& !(sessionRef.current.rows.some (row => shouldFetchReviewRow (row))))
|
||||||
return () => {
|
return () => {
|
||||||
previewSequenceRef.current = previewSequence
|
previewSequenceRef.current = previewSequence
|
||||||
}
|
}
|
||||||
|
|
||||||
const refreshRows = async (baseSession: PostImportSession) => {
|
const refreshRows = async (baseSession: PostImportSession) => {
|
||||||
if (active)
|
const blocksSubmit = baseSession.rows.some (row => shouldFetchMetadata (row))
|
||||||
|
if (active && blocksSubmit)
|
||||||
setMetadataLoading (true)
|
setMetadataLoading (true)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -652,7 +689,7 @@ const PostImportReviewPage: FC<Props> = ({ user }) => {
|
|||||||
|
|
||||||
const baseRow = baseSession.rows[index]
|
const baseRow = baseSession.rows[index]
|
||||||
const currentRow = currentRowBySource (baseRow.sourceRow, baseSession)
|
const currentRow = currentRowBySource (baseRow.sourceRow, baseSession)
|
||||||
if (currentRow == null || !(shouldFetchMetadata (currentRow)))
|
if (currentRow == null || !(shouldFetchReviewRow (currentRow)))
|
||||||
continue
|
continue
|
||||||
const controller = new AbortController ()
|
const controller = new AbortController ()
|
||||||
controllers.add (controller)
|
controllers.add (controller)
|
||||||
@@ -669,7 +706,9 @@ const PostImportReviewPage: FC<Props> = ({ user }) => {
|
|||||||
|| isNonRecoverableFailedRow (row)
|
|| isNonRecoverableFailedRow (row)
|
||||||
|| row.skipReason === 'manual'
|
|| row.skipReason === 'manual'
|
||||||
? row
|
? row
|
||||||
: mergePreviewRow (row, preview))
|
: (shouldFetchMetadata (row)
|
||||||
|
? mergePreviewRow (row, preview)
|
||||||
|
: mergeExistingSkippedRow (row, preview)))
|
||||||
}
|
}
|
||||||
catch (requestError)
|
catch (requestError)
|
||||||
{
|
{
|
||||||
@@ -723,7 +762,9 @@ const PostImportReviewPage: FC<Props> = ({ user }) => {
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (active && metadataSequenceRef.current === previewSequence)
|
if (active
|
||||||
|
&& blocksSubmit
|
||||||
|
&& metadataSequenceRef.current === previewSequence)
|
||||||
setMetadataLoading (false)
|
setMetadataLoading (false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
新しい課題から参照
ユーザをブロックする