Skip to content

Commit f297c58

Browse files
committed
Merge pull request #448 from crazyserver/MOBILE-1524
MOBILE-1524 prefetch: Show spinner when retrieving status & size
2 parents bc7082c + c62450f commit f297c58

File tree

10 files changed

+21
-10
lines changed

10 files changed

+21
-10
lines changed

www/addons/mod_book/services/handlers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ angular.module('mm.addons.mod_book')
8787
$scope.title = module.name;
8888
$scope.icon = $mmCourse.getModuleIconSrc('book');
8989
$scope.buttons = [downloadBtn, refreshBtn];
90-
$scope.spinner = false;
90+
$scope.spinner = true; // Show spinner while calculating status.
9191

9292
$scope.action = function(e) {
9393
if (e) {

www/addons/mod_folder/services/handlers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ angular.module('mm.addons.mod_folder')
9393
$scope.icon = $mmCourse.getModuleIconSrc('folder');
9494
$scope.title = module.name;
9595
$scope.buttons = [downloadBtn, refreshBtn];
96-
$scope.spinner = false;
96+
$scope.spinner = true; // Show spinner while calculating status.
9797

9898
$scope.action = function(e) {
9999
if (e) {

www/addons/mod_imscp/services/handlers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ angular.module('mm.addons.mod_imscp')
9393
$scope.title = module.name;
9494
$scope.icon = $mmCourse.getModuleIconSrc('imscp');
9595
$scope.buttons = [downloadBtn, refreshBtn];
96-
$scope.spinner = false;
96+
$scope.spinner = true; // Show spinner while calculating status.
9797

9898
$scope.action = function(e) {
9999
if (e) {

www/addons/mod_page/services/handlers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ angular.module('mm.addons.mod_page')
8787
$scope.title = module.name;
8888
$scope.icon = $mmCourse.getModuleIconSrc('page');
8989
$scope.buttons = [downloadBtn, refreshBtn];
90-
$scope.spinner = false;
90+
$scope.spinner = true; // Show spinner while calculating status.
9191

9292
$scope.action = function(e) {
9393
if (e) {

www/addons/mod_resource/services/handlers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ angular.module('mm.addons.mod_resource')
9898
$scope.icon = $mmCourse.getModuleIconSrc('resource');
9999
}
100100
$scope.buttons = [downloadBtn, refreshBtn];
101-
$scope.spinner = false;
101+
$scope.spinner = true; // Show spinner while calculating status.
102102

103103
$scope.action = function(e) {
104104
if (e) {

www/addons/mod_scorm/services/handlers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ angular.module('mm.addons.mod_scorm')
7474
$scope.icon = $mmCourse.getModuleIconSrc('scorm');
7575
$scope.title = module.name;
7676
$scope.buttons = [downloadBtn, refreshBtn];
77-
$scope.spinner = false;
77+
$scope.spinner = true; // Show spinner while calculating status.
7878

7979
$scope.action = function(e) {
8080
if (e) {

www/addons/mod_wiki/services/handlers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ angular.module('mm.addons.mod_wiki')
8585
$scope.title = module.name;
8686
$scope.icon = $mmCourse.getModuleIconSrc('wiki');
8787
$scope.buttons = [downloadBtn, refreshBtn];
88-
$scope.spinner = false;
88+
$scope.spinner = true; // Show spinner while calculating status.
8989

9090
$scope.action = function(e) {
9191
if (e) {

www/core/components/course/controllers/sections.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,11 @@ angular.module('mm.core.course')
155155
e.preventDefault();
156156
e.stopPropagation();
157157

158+
section.isCalculating = true;
158159
$mmCourseHelper.confirmDownloadSize(courseId, section, $scope.sections).then(function() {
159160
prefetch(section, true);
161+
}).finally(function() {
162+
section.isCalculating = false;
160163
});
161164
};
162165

www/core/components/course/services/helper.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,16 @@ angular.module('mm.core.course')
107107
if (section.id === mmCoreCourseAllSectionsId) {
108108
// "All sections" section status is calculated using the status of the rest of sections.
109109
allsectionssection = section;
110+
section.isCalculating = true;
110111
} else {
112+
section.isCalculating = true;
111113
statuspromises.push(self.calculateSectionStatus(section, courseid, restoreDownloads, refresh, downloadpromises)
112114
.then(function(result) {
113115

114116
// Calculate "All sections" status.
115117
allsectionsstatus = $mmFilepool.determinePackagesStatus(allsectionsstatus, result.status);
118+
}).finally(function() {
119+
section.isCalculating = false;
116120
}));
117121
}
118122
});
@@ -125,6 +129,10 @@ angular.module('mm.core.course')
125129
allsectionssection.isDownloading = allsectionsstatus === mmCoreDownloading;
126130
}
127131
return downloadpromises;
132+
}).finally(function() {
133+
if (allsectionssection) {
134+
allsectionssection.isCalculating = false;
135+
}
128136
});
129137
};
130138

www/core/components/course/templates/sections.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
<a class="item item-text-wrap item-button-right" mm-split-view-link="site.mm_course-section({cid: courseId, sectionid: section.id, mid: moduleId})" title="{{section.name}}">
1010
<mm-format-text watch="true">{{section.name}}</mm-format-text>
1111

12-
<button ng-if="section.showDownload && !section.isDownloading" ng-click="prefetch($event, section)" class="button button-icon" aria-label="{{ 'mm.core.download' | translate }}">
12+
<button ng-if="section.showDownload && !section.isDownloading && !section.isCalculating" ng-click="prefetch($event, section)" class="button button-icon" aria-label="{{ 'mm.core.download' | translate }}">
1313
<i class="icon ion-ios-cloud-download-outline"></i>
1414
</button>
15-
<button ng-if="section.showRefresh && !section.isDownloading" ng-click="prefetch($event, section)" class="button button-icon" aria-label="{{ 'mm.core.refresh' | translate }}">
15+
<button ng-if="section.showRefresh && !section.isDownloading && !section.isCalculating" ng-click="prefetch($event, section)" class="button button-icon" aria-label="{{ 'mm.core.refresh' | translate }}">
1616
<i class="icon ion-android-refresh"></i>
1717
</button>
1818

19-
<ion-spinner ng-if="section.isDownloading && section.total > 0"></ion-spinner>
19+
<ion-spinner ng-if="(section.isDownloading && section.total > 0) || section.isCalculating"></ion-spinner>
2020
<span class="badge mm-course-download" ng-if="section.isDownloading && section.total > 0 && section.count < section.total">{{section.count}} / {{section.total}}</span>
2121
</a>
2222
</li>

0 commit comments

Comments
 (0)