Browse Source

[fix]修复文件上传成功状态未刷新的问题

zk 1 year ago
parent
commit
6f6b4fc9c2
2 changed files with 34 additions and 2 deletions
  1. 30 0
      lib/data/bean/talks.dart
  2. 4 2
      lib/module/talk/controller.dart

+ 30 - 0
lib/data/bean/talks.dart

@@ -56,6 +56,36 @@ class TalkBean {
 
   factory TalkBean.fromJson(Map<String, dynamic> json) =>
       _$TalkBeanFromJson(json);
+
+  TalkBean copyWith({
+    String? id,
+    String? taskId,
+    String? ssid,
+    String? audioUrl,
+    double? duration,
+    int? characters,
+    int? status,
+    String? title,
+    String? summary,
+    String? createTime,
+    bool? isExample,
+    bool? oversizeFile,
+  }) {
+    return TalkBean(
+      id: id ?? this.id,
+      taskId: taskId ?? this.taskId,
+      ssid: ssid ?? this.ssid,
+      audioUrl: audioUrl ?? this.audioUrl,
+      duration: duration ?? this.duration,
+      characters: characters ?? this.characters,
+      status: status ?? this.status,
+      title: title ?? this.title,
+      summary: summary ?? this.summary,
+      createTime: createTime ?? this.createTime,
+      isExample: isExample ?? this.isExample,
+      oversizeFile: oversizeFile ?? this.oversizeFile,
+    );
+  }
 }
 
 class TalkStatus {

+ 4 - 2
lib/module/talk/controller.dart

@@ -273,8 +273,10 @@ class TalkController extends BaseController {
     talkRepository.uploadTalkFile(talkId, duration, file).then((taskId) {
       ToastUtil.showToast('提交成功,小听正在分析谈话,请稍后');
       isUploadedFile = true;
-      talkBean.value?.taskId = taskId;
-      talkBean.value?.status = TalkStatus.analysing;
+      talkBean.value = talkBean.value?.copyWith(
+        taskId: taskId,
+        status: TalkStatus.analysing,
+      );
       taskRepository.addTask(taskId);
     }).catchError((error) {
       ErrorHandler.toastError(error);