Browse Source

录制完成及时刷新列表

bill 2 years ago
parent
commit
aacd0dad80
1 changed files with 7 additions and 2 deletions
  1. 7 2
      src/store/record.ts

+ 7 - 2
src/store/record.ts

@@ -56,12 +56,17 @@ export const backupRecords = () => {
 }
 export const recoverRecords = recoverStoreItems(records, getBackupRecords)
 
+const refreshRecords: NodeJS.Timeout[] = []
 const refreshRecordStatus = async (record: Record) => {
   const status = await fetchRecordStatus(record.id)
   if (status === RecordStatus.SUCCESS) {
-    unSetModelUpdate(() => record.status = RecordStatus.SUCCESS)
+    refreshRecords.forEach(clearTimeout)
+    refreshRecords.length = 0
+    initialRecords()
   } else {
-    setTimeout(refreshRecordStatus.bind(null, record), 3000)
+    refreshRecords.push(
+      setTimeout(refreshRecordStatus.bind(null, record), 3000)
+    )
   }
 }