|
|
|
@ -1,11 +1,12 @@ |
|
|
|
import 'package:get/get.dart'; |
|
|
|
|
|
|
|
import '../../../core/utils/logger.dart'; |
|
|
|
import '../../../core/utils/upload_oss.dart'; |
|
|
|
import '../db/sqflite_api.dart'; |
|
|
|
|
|
|
|
class MeetingUploadService extends GetxService { |
|
|
|
RxInt meetingId = 0.obs; |
|
|
|
RxDouble uploadProgress = 0.0.obs; |
|
|
|
RxDouble uploadProgress = 0.6.obs; |
|
|
|
RxList uploadList = [].obs; |
|
|
|
|
|
|
|
bool _isUpload = false; |
|
|
|
@ -32,19 +33,39 @@ class MeetingUploadService extends GetxService { |
|
|
|
while (_handled < uploadList.length) { |
|
|
|
Map element = uploadList[_handled]; |
|
|
|
_handled++; |
|
|
|
if (element['audiourl'].isNotEmpty) { |
|
|
|
if (element['audiourl'].isEmpty) { |
|
|
|
meetingId.value = element['id']; |
|
|
|
final audiourl = await UploadOss.upload( |
|
|
|
filepath: element['filepath'], |
|
|
|
rootDir: element['rootdir'], |
|
|
|
); |
|
|
|
await SqfliteApi.editMeetingTitle( |
|
|
|
element['id'], |
|
|
|
{'audiourl': audiourl}, |
|
|
|
); |
|
|
|
element['audiourl'] = audiourl; |
|
|
|
try { |
|
|
|
final audiourl = await UploadOss.upload( |
|
|
|
filepath: element['filepath'], |
|
|
|
rootDir: element['rootdir'], |
|
|
|
); |
|
|
|
await SqfliteApi.editMeetingTitle( |
|
|
|
element['id'], |
|
|
|
{'audiourl': audiourl}, |
|
|
|
); |
|
|
|
element['audiourl'] = audiourl; |
|
|
|
} catch (e) { |
|
|
|
Logger.error('Upload failed: $e'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
meetingId.value = 0; |
|
|
|
_isUpload = false; |
|
|
|
} |
|
|
|
|
|
|
|
void removeUpload(int id, {bool isDeleteTask = false}) { |
|
|
|
Map uploadData = uploadList.firstWhere( |
|
|
|
(element) => element['id'] == id, |
|
|
|
orElse: () => {}, |
|
|
|
); |
|
|
|
if (uploadData.isNotEmpty) { |
|
|
|
if (isDeleteTask || uploadData['audiourl'].isNotEmpty) { |
|
|
|
uploadList.remove(uploadData); |
|
|
|
if (uploadList.isEmpty) { |
|
|
|
_handled = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|