MOBILE-2480 course: Refresh format components if completion changes
parent
6fdb5528ed
commit
ac8c2bcee6
|
@ -325,13 +325,14 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
|||
*
|
||||
* @param {any} [refresher] Refresher.
|
||||
* @param {Function} [done] Function to call when done.
|
||||
* @param {boolean} [afterCompletionChange] Whether the refresh is due to a completion change.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
*/
|
||||
doRefresh(refresher?: any, done?: () => void): Promise<any> {
|
||||
doRefresh(refresher?: any, done?: () => void, afterCompletionChange?: boolean): Promise<any> {
|
||||
const promises = [];
|
||||
|
||||
this.dynamicComponents.forEach((component) => {
|
||||
promises.push(Promise.resolve(component.callComponentFunction('doRefresh', [refresher, done])));
|
||||
promises.push(Promise.resolve(component.callComponentFunction('doRefresh', [refresher, done, afterCompletionChange])));
|
||||
});
|
||||
|
||||
return Promise.all(promises);
|
||||
|
|
|
@ -66,9 +66,15 @@ export class CoreCourseFormatSingleActivityComponent implements OnChanges {
|
|||
*
|
||||
* @param {any} [refresher] Refresher.
|
||||
* @param {Function} [done] Function to call when done.
|
||||
* @param {boolean} [afterCompletionChange] Whether the refresh is due to a completion change.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
*/
|
||||
doRefresh(refresher?: any, done?: () => void): Promise<any> {
|
||||
doRefresh(refresher?: any, done?: () => void, afterCompletionChange?: boolean): Promise<any> {
|
||||
if (afterCompletionChange) {
|
||||
// Don't refresh the view after a completion change since completion isn't displayed.
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return Promise.resolve(this.dynamicComponent.callComponentFunction('doRefresh', [refresher, done]));
|
||||
}
|
||||
|
||||
|
|
|
@ -307,7 +307,9 @@ export class CoreCourseSectionPage implements OnDestroy {
|
|||
this.dataLoaded = false;
|
||||
this.content.scrollToTop(); // Scroll top so the spinner is seen.
|
||||
|
||||
this.loadData().finally(() => {
|
||||
this.loadData().then(() => {
|
||||
return this.formatComponent.doRefresh(undefined, undefined, true);
|
||||
}).finally(() => {
|
||||
this.dataLoaded = true;
|
||||
|
||||
// Wait for new content height to be calculated and scroll without animation.
|
||||
|
|
|
@ -86,9 +86,10 @@ export class CoreSitePluginsCourseFormatComponent implements OnChanges {
|
|||
*
|
||||
* @param {any} [refresher] Refresher.
|
||||
* @param {Function} [done] Function to call when done.
|
||||
* @param {boolean} [afterCompletionChange] Whether the refresh is due to a completion change.
|
||||
* @return {Promise<any>} Promise resolved when done.
|
||||
*/
|
||||
doRefresh(refresher?: any, done?: () => void): Promise<any> {
|
||||
return Promise.resolve(this.content.refreshContent(false));
|
||||
doRefresh(refresher?: any, done?: () => void, afterCompletionChange?: boolean): Promise<any> {
|
||||
return Promise.resolve(this.content.refreshContent(afterCompletionChange));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue