|
|
|
@ -1,10 +1,13 @@ |
|
|
|
import 'package:get/get.dart'; |
|
|
|
import 'package:get_storage/get_storage.dart'; |
|
|
|
|
|
|
|
import '../../../core/utils/logger.dart'; |
|
|
|
import '../../../core/utils/upload_oss.dart'; |
|
|
|
import '../db/sqflite_api.dart'; |
|
|
|
|
|
|
|
class MeetingUploadService extends GetxService { |
|
|
|
final GetStorage _storage = GetStorage(); |
|
|
|
|
|
|
|
RxInt meetingId = 0.obs; |
|
|
|
RxDouble uploadProgress = 0.0.obs; |
|
|
|
RxList uploadList = [].obs; |
|
|
|
@ -18,7 +21,10 @@ class MeetingUploadService extends GetxService { |
|
|
|
_getUploadList(); |
|
|
|
} |
|
|
|
|
|
|
|
void _getUploadList() {} |
|
|
|
void _getUploadList() { |
|
|
|
uploadList.value = _storage.read("upload_list") ?? []; |
|
|
|
_executeUpload(); |
|
|
|
} |
|
|
|
|
|
|
|
void addUpload(int id, String filePath, String rootDir) async { |
|
|
|
uploadList.add({ |
|
|
|
@ -27,6 +33,11 @@ class MeetingUploadService extends GetxService { |
|
|
|
'rootdir': rootDir, |
|
|
|
'audiourl': '', |
|
|
|
}); |
|
|
|
_storage.write("upload_list", uploadList); |
|
|
|
_executeUpload(); |
|
|
|
} |
|
|
|
|
|
|
|
void _executeUpload() async { |
|
|
|
if (_isUpload) return; |
|
|
|
_isUpload = true; |
|
|
|
_handled = 0; |
|
|
|
@ -48,6 +59,8 @@ class MeetingUploadService extends GetxService { |
|
|
|
{'audiourl': audiourl}, |
|
|
|
); |
|
|
|
element['audiourl'] = audiourl; |
|
|
|
uploadProgress.value = 0.0; |
|
|
|
_storage.write("upload_list", uploadList); |
|
|
|
} catch (e) { |
|
|
|
Logger.error('Upload failed: $e'); |
|
|
|
} |
|
|
|
@ -65,6 +78,7 @@ class MeetingUploadService extends GetxService { |
|
|
|
if (uploadData.isNotEmpty) { |
|
|
|
if (isDeleteTask || uploadData['audiourl'].isNotEmpty) { |
|
|
|
uploadList.remove(uploadData); |
|
|
|
_storage.write("upload_list", uploadList); |
|
|
|
if (uploadList.isEmpty) { |
|
|
|
_handled = 0; |
|
|
|
} |
|
|
|
|