Skip to content

Commit

Permalink
修復「讀取學生列表時出現大量延遲」的問題 (#231)
Browse files Browse the repository at this point in the history
* Implement: Loading Text

* Fix: Loading Twice

* Chore: Format
  • Loading branch information
ntut-xuan authored Mar 1, 2024
1 parent b11f6be commit ef45e69
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 14 deletions.
2 changes: 2 additions & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class MessageLookup extends MessageLookupByLibrary {
"getScoreRankError": MessageLookupByLibrary.simpleMessage("There\'s an error getting the grades"),
"getScoreRankQuestionnaireError": MessageLookupByLibrary.simpleMessage(
"There\'s an error getting the grades.\nPlease check if the Online Course Evaluation Questionnaire has been completed"),
"getStudentList": MessageLookupByLibrary.simpleMessage("Getting student list..."),
"getStudentListError": MessageLookupByLibrary.simpleMessage("Getting student list error"),
"github": MessageLookupByLibrary.simpleMessage("Github"),
"graduationSetting": MessageLookupByLibrary.simpleMessage("Graduation credit standard setting"),
"historicalDimension": MessageLookupByLibrary.simpleMessage("Historical dimension"),
Expand Down
2 changes: 2 additions & 0 deletions lib/generated/intl/messages_zh_TW.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ class MessageLookup extends MessageLookupByLibrary {
"getScoreRank": MessageLookupByLibrary.simpleMessage("取得成績中..."),
"getScoreRankError": MessageLookupByLibrary.simpleMessage("取得成績錯誤"),
"getScoreRankQuestionnaireError": MessageLookupByLibrary.simpleMessage("取得成績錯誤,請確認期末教學評量是否填寫完成"),
"getStudentList": MessageLookupByLibrary.simpleMessage("取得修課名單..."),
"getStudentListError": MessageLookupByLibrary.simpleMessage("取得修課名單錯誤"),
"github": MessageLookupByLibrary.simpleMessage("Github"),
"graduationSetting": MessageLookupByLibrary.simpleMessage("畢業學分標準設定"),
"historicalDimension": MessageLookupByLibrary.simpleMessage("歷史向度"),
Expand Down
20 changes: 20 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
"getScoreRankQuestionnaireError": "There's an error getting the grades.\nPlease check if the Online Course Evaluation Questionnaire has been completed",
"getCalendar": "Getting calendar...",
"getCalendarError": "Getting calendar error",
"getStudentList": "Getting student list...",
"getStudentListError": "Getting student list error",
"deleteMessage": "Deleting message...",
"deleteMessageError": "Delete error",
"loginNTUTApp": "Login to the NTUTApp...",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/intl_zh_TW.arb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
"getScoreRankQuestionnaireError": "取得成績錯誤,請確認期末教學評量是否填寫完成",
"getCalendar": "取得行事曆中...",
"getCalendarError": "取得行事曆錯誤",
"getStudentList": "取得修課名單...",
"getStudentListError": "取得修課名單錯誤",
"deleteMessage": "刪除訊息中...",
"deleteMessageError": "刪除錯誤",
"loginNTUTApp": "登入北科助理...",
Expand Down
6 changes: 3 additions & 3 deletions lib/src/task/iplus/iplus_get_course_student_list_task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ import 'iplus_system_task.dart';
class IPlusGetStudentListTask extends IPlusSystemTask<List<CourseStudent>> {
String courseId;

IPlusGetStudentListTask({required this.courseId}) : super("IPlusCourseAnnouncementTask");
IPlusGetStudentListTask({required this.courseId}) : super("IPlusGetStudentListTask");

@override
Future<TaskStatus> execute() async {
final status = await super.execute();
if (status == TaskStatus.success) {
super.onStart(R.current.getISchoolPlusCourseAnnouncement);
super.onStart(R.current.getStudentList);
final value = await ISchoolPlusConnector.getCourseStudent(courseId);
super.onEnd();
switch (value.status) {
case IPlusReturnStatus.success:
result = value.result;
return TaskStatus.success;
case IPlusReturnStatus.fail:
return super.onError(R.current.getISchoolPlusCourseAnnouncementError);
return super.onError(R.current.getStudentListError);
case IPlusReturnStatus.noPermission:
final parameter = MsgDialogParameter(
title: R.current.warning,
Expand Down
11 changes: 0 additions & 11 deletions lib/ui/pages/coursedetail/screen/course_info_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class _CourseInfoPageState extends State<CourseInfoPage> with AutomaticKeepAlive
super.initState();
isLoading = true;
BackButtonInterceptor.add(myInterceptor);
Future.microtask(() => _loadCourseStudent());
Future.delayed(Duration.zero, () {
_addTask();
});
Expand Down Expand Up @@ -228,16 +227,6 @@ class _CourseInfoPageState extends State<CourseInfoPage> with AutomaticKeepAlive
return <String, String>{};
}

void _loadCourseStudent() async {
TaskFlow taskFlow = TaskFlow();
final courseMainInfo = widget.courseInfo.main;
final task = IPlusGetStudentListTask(courseId: courseMainInfo.course.id);
taskFlow.addTask(task);
if (await taskFlow.start()) {
task.result;
}
}

String getDepartment(Map<String, String> departmentMap, String studentId) {
/*
* Since we don't have official data to describe the following hard-coded rule is correct.
Expand Down

0 comments on commit ef45e69

Please sign in to comment.