Merge pull request #1849 from dpalou/MOBILE-2901
MOBILE-2901 file: Support offline files for Nextcloudmain
commit
21288dd285
|
@ -113,7 +113,8 @@ export class AddonModResourceHelperProvider {
|
||||||
* @return {boolean} Whether the resource should be displayed embeded.
|
* @return {boolean} Whether the resource should be displayed embeded.
|
||||||
*/
|
*/
|
||||||
isDisplayedEmbedded(module: any, display: number): boolean {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,12 @@ export class AddonModResourcePrefetchHandler extends CoreCourseResourcePrefetchH
|
||||||
* @return {Promise<boolean>} Promise resolved with true if downloadable, resolved with false otherwise.
|
* @return {Promise<boolean>} Promise resolved with true if downloadable, resolved with false otherwise.
|
||||||
*/
|
*/
|
||||||
isDownloadable(module: any, courseId: number): Promise<boolean> {
|
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.loadContents(module, courseId, false).then(() => {
|
||||||
return !this.resourceHelper.isNextcloudFile(module);
|
return !this.resourceHelper.isNextcloudFile(module);
|
||||||
});
|
});
|
||||||
|
|
|
@ -86,12 +86,15 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
|
||||||
if (data.componentId === this.module.id && this.prefetchHandler &&
|
if (data.componentId === this.module.id && this.prefetchHandler &&
|
||||||
data.component === this.prefetchHandler.component) {
|
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) {
|
if (this.downloadEnabled) {
|
||||||
// Download is enabled, show the status.
|
// Download is enabled, show the status.
|
||||||
this.showStatus(data.status);
|
this.showStatus(status);
|
||||||
} else if (this.module.handlerData.updateStatus) {
|
} else if (this.module.handlerData.updateStatus) {
|
||||||
// Download isn't enabled but the handler defines a updateStatus function, call it anyway.
|
// 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());
|
}, this.sitesProvider.getCurrentSiteId());
|
||||||
|
|
|
@ -387,6 +387,8 @@ export class CoreCourseModulePrefetchDelegate extends CoreDelegate {
|
||||||
}
|
}
|
||||||
} else if (handler.determineStatus) {
|
} else if (handler.determineStatus) {
|
||||||
// The handler implements a determineStatus function. Apply it.
|
// The handler implements a determineStatus function. Apply it.
|
||||||
|
canCheck = canCheck || this.canCheckUpdates();
|
||||||
|
|
||||||
return handler.determineStatus(module, status, canCheck);
|
return handler.determineStatus(module, status, canCheck);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue