このコミットが含まれているのは:
@@ -113,7 +113,7 @@ const PostImportPage: FC<Props> = ({ user }) => {
|
||||
url_column: urlColumn,
|
||||
mappings,
|
||||
existing })
|
||||
setRows (data.rows)
|
||||
setRows (current => mergeValidatedRows (current, data.rows))
|
||||
setPhase ('preview')
|
||||
}
|
||||
catch
|
||||
@@ -126,6 +126,15 @@ const PostImportPage: FC<Props> = ({ user }) => {
|
||||
}
|
||||
}
|
||||
|
||||
const mergeValidatedRows = (current: ImportRow[], validated: ImportRow[]): ImportRow[] =>
|
||||
current.filter (row => row.importStatus === 'created').concat (validated.map (row => {
|
||||
const previous = current.find (_1 => _1.sourceRow === row.sourceRow)
|
||||
return previous ? { ...row,
|
||||
importStatus: previous.importStatus,
|
||||
createdPostId: previous.createdPostId,
|
||||
errors: previous.importStatus === 'failed' ? previous.errors : row.errors } : row
|
||||
}))
|
||||
|
||||
const updateAttribute = async (index: number, field: string, value: string) => {
|
||||
const row = rows[index]
|
||||
const next = { ...row,
|
||||
@@ -138,10 +147,10 @@ const PostImportPage: FC<Props> = ({ user }) => {
|
||||
try
|
||||
{
|
||||
const validated = await apiPost<{ rows: ImportRow[] }> ('/posts/import/validate',
|
||||
{ rows: nextRows, existing,
|
||||
{ rows: nextRows.filter (row => row.importStatus !== 'created'), existing,
|
||||
changed_row: -1 })
|
||||
if (generation === validationGeneration.current)
|
||||
setRows (validated.rows)
|
||||
setRows (current => mergeValidatedRows (current, validated.rows))
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -164,10 +173,10 @@ const PostImportPage: FC<Props> = ({ user }) => {
|
||||
try
|
||||
{
|
||||
const validated = await apiPost<{ rows: ImportRow[] }> ('/posts/import/validate',
|
||||
{ rows: nextRows, existing,
|
||||
{ rows: nextRows.filter (row => row.importStatus !== 'created'), existing,
|
||||
changed_row: row.sourceRow })
|
||||
if (generation === validationGeneration.current)
|
||||
setRows (validated.rows)
|
||||
setRows (current => mergeValidatedRows (current, validated.rows))
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -187,9 +196,9 @@ const PostImportPage: FC<Props> = ({ user }) => {
|
||||
try
|
||||
{
|
||||
const validated = await apiPost<{ rows: ImportRow[] }> ('/posts/import/validate',
|
||||
{ rows, existing: value, changed_row: -1 })
|
||||
{ rows: rows.filter (row => row.importStatus !== 'created'), existing: value, changed_row: -1 })
|
||||
if (generation === validationGeneration.current)
|
||||
setRows (validated.rows)
|
||||
setRows (current => mergeValidatedRows (current, validated.rows))
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
新しい課題から参照
ユーザをブロックする