|  |  |  | 
|---|
|  |  |  | const meanTime = totalTime / (i + batch.length); | 
|---|
|  |  |  | setImporter(previous => { | 
|---|
|  |  |  | if (previous.state === 'running') { | 
|---|
|  |  |  | const importCount = | 
|---|
|  |  |  | previous.importCount + batch.length; | 
|---|
|  |  |  | const importCount = previous.importCount + batch.length; | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | ...previous, | 
|---|
|  |  |  | importCount, | 
|---|
|  |  |  | remainingTime: | 
|---|
|  |  |  | meanTime * | 
|---|
|  |  |  | (results.data.length - importCount), | 
|---|
|  |  |  | remainingTime: meanTime * (results.data.length - importCount), | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return previous; | 
|---|
|  |  |  | 
|---|
|  |  |  | previous.state === 'running' | 
|---|
|  |  |  | ? { | 
|---|
|  |  |  | ...previous, | 
|---|
|  |  |  | errorCount: | 
|---|
|  |  |  | previous.errorCount + | 
|---|
|  |  |  | batch.length, | 
|---|
|  |  |  | errorCount: previous.errorCount + batch.length, | 
|---|
|  |  |  | } | 
|---|
|  |  |  | : previous | 
|---|
|  |  |  | ); | 
|---|