Merge pull request #1849 from dpalou/MOBILE-2901

MOBILE-2901 file: Support offline files for Nextcloud
main
Juan Leyva 2019-04-26 15:14:16 +02:00 committed by GitHub
commit 21288dd285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 4 deletions

View File

@ -113,7 +113,8 @@ export class AddonModResourceHelperProvider {
* @return {boolean} Whether the resource should be displayed embeded.
*/
isDisplayedEmbedded(module: any, display: number): boolean {
if (!module.contents.length || !this.fileProvider.isAvailable() || this.isNextcloudFile(module)) {
if (!module.contents.length || !this.fileProvider.isAvailable() ||
(!this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.7') && this.isNextcloudFile(module))) {
return false;
}

View File

@ -130,7 +130,12 @@ export class AddonModResourcePrefetchHandler extends CoreCourseResourcePrefetchH
* @return {Promise<boolean>} Promise resolved with true if downloadable, resolved with false otherwise.
*/
isDownloadable(module: any, courseId: number): Promise<boolean> {
// Don't allow downloading Nextcloud files for now.
if (this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.7')) {
// Nextcloud files are downloadable from 3.7 onwards.
return Promise.resolve(true);
}
// Don't allow downloading Nextcloud files in older sites.
return this.loadContents(module, courseId, false).then(() => {
return !this.resourceHelper.isNextcloudFile(module);
});

View File

@ -86,12 +86,15 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
if (data.componentId === this.module.id && this.prefetchHandler &&
data.component === this.prefetchHandler.component) {
// Call determineModuleStatus to get the right status to display.
const status = this.prefetchDelegate.determineModuleStatus(this.module, data.status);
if (this.downloadEnabled) {
// Download is enabled, show the status.
this.showStatus(data.status);
this.showStatus(status);
} else if (this.module.handlerData.updateStatus) {
// Download isn't enabled but the handler defines a updateStatus function, call it anyway.
this.module.handlerData.updateStatus(data.status);
this.module.handlerData.updateStatus(status);
}
}
}, this.sitesProvider.getCurrentSiteId());

View File

@ -387,6 +387,8 @@ export class CoreCourseModulePrefetchDelegate extends CoreDelegate {
}
} else if (handler.determineStatus) {
// The handler implements a determineStatus function. Apply it.
canCheck = canCheck || this.canCheckUpdates();
return handler.determineStatus(module, status, canCheck);
}
}