Update Saqel Platform: 2026-09-09 00:24:41
This commit is contained in:
@@ -35,6 +35,8 @@ class TeacherStudioState {
|
||||
final bool isUploading;
|
||||
final bool isUploaded;
|
||||
final String? uploadSuccessMessage;
|
||||
final double uploadProgress;
|
||||
final String uploadPhase;
|
||||
|
||||
const TeacherStudioState({
|
||||
required this.lessonTitle,
|
||||
@@ -57,6 +59,8 @@ class TeacherStudioState {
|
||||
this.isUploading = false,
|
||||
this.isUploaded = false,
|
||||
this.uploadSuccessMessage,
|
||||
this.uploadProgress = 0.0,
|
||||
this.uploadPhase = 'idle',
|
||||
});
|
||||
|
||||
TeacherStudioState copyWith({
|
||||
@@ -81,6 +85,8 @@ class TeacherStudioState {
|
||||
bool? isUploading,
|
||||
bool? isUploaded,
|
||||
String? uploadSuccessMessage,
|
||||
double? uploadProgress,
|
||||
String? uploadPhase,
|
||||
}) {
|
||||
return TeacherStudioState(
|
||||
lessonTitle: lessonTitle ?? this.lessonTitle,
|
||||
@@ -103,6 +109,8 @@ class TeacherStudioState {
|
||||
isUploading: isUploading ?? this.isUploading,
|
||||
isUploaded: isUploaded ?? this.isUploaded,
|
||||
uploadSuccessMessage: uploadSuccessMessage ?? this.uploadSuccessMessage,
|
||||
uploadProgress: uploadProgress ?? this.uploadProgress,
|
||||
uploadPhase: uploadPhase ?? this.uploadPhase,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -300,7 +308,13 @@ class TeacherStudioCubit extends Cubit<TeacherStudioState> {
|
||||
(state.selectedFilePath == null && state.selectedFileBytes == null)) {
|
||||
return false;
|
||||
}
|
||||
emit(state.copyWith(isUploading: true, isAuditing: true, clearError: true));
|
||||
emit(state.copyWith(
|
||||
isUploading: true,
|
||||
isAuditing: true,
|
||||
uploadProgress: 0.0,
|
||||
uploadPhase: 'uploading',
|
||||
clearError: true,
|
||||
));
|
||||
try {
|
||||
final res = await repository.uploadLesson(
|
||||
title: state.lessonTitle,
|
||||
@@ -312,6 +326,15 @@ class TeacherStudioCubit extends Cubit<TeacherStudioState> {
|
||||
fileSizeMb: state.selectedFileSizeMb,
|
||||
filePath: state.selectedFilePath,
|
||||
fileBytes: state.selectedFileBytes,
|
||||
onProgress: (sent, total) {
|
||||
if (total > 0) {
|
||||
final p = (sent / total).clamp(0.0, 1.0);
|
||||
emit(state.copyWith(
|
||||
uploadProgress: p,
|
||||
uploadPhase: p >= 1.0 ? 'auditing' : 'uploading',
|
||||
));
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
final status = res['status']?.toString();
|
||||
@@ -337,6 +360,8 @@ class TeacherStudioCubit extends Cubit<TeacherStudioState> {
|
||||
isAuditing: false,
|
||||
isUploading: false,
|
||||
isUploaded: false,
|
||||
uploadProgress: 0.0,
|
||||
uploadPhase: 'idle',
|
||||
auditResult: result,
|
||||
errorMessage: reason,
|
||||
));
|
||||
@@ -348,6 +373,8 @@ class TeacherStudioCubit extends Cubit<TeacherStudioState> {
|
||||
isAuditing: false,
|
||||
isUploading: false,
|
||||
isUploaded: true,
|
||||
uploadProgress: 1.0,
|
||||
uploadPhase: 'completed',
|
||||
auditResult: result,
|
||||
uploadSuccessMessage: msg,
|
||||
));
|
||||
@@ -356,6 +383,8 @@ class TeacherStudioCubit extends Cubit<TeacherStudioState> {
|
||||
emit(state.copyWith(
|
||||
isAuditing: false,
|
||||
isUploading: false,
|
||||
uploadProgress: 0.0,
|
||||
uploadPhase: 'idle',
|
||||
errorMessage: e.toString().replaceFirst('Bad state: ', '')));
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user