From 1fc0b9184b02a0a401e6107f9a1dbc912c14b03b Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 6 Apr 2022 12:55:13 +0200 Subject: [PATCH] MOBILE-3833 assign: Fix error displayed after sync --- .../mod/assign/components/index/index.ts | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/addons/mod/assign/components/index/index.ts b/src/addons/mod/assign/components/index/index.ts index adef90a39..37998df5b 100644 --- a/src/addons/mod/assign/components/index/index.ts +++ b/src/addons/mod/assign/components/index/index.ts @@ -312,12 +312,13 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo } /** - * Checks if sync has succeed from result sync data. - * - * @param result Data returned by the sync function. - * @return If succeed or not. + * @inheritdoc */ - protected hasSyncSucceed(result: AddonModAssignSyncResult): boolean { + protected hasSyncSucceed(result?: AddonModAssignSyncResult): boolean { + if (!result) { + return false; + } + if (result.updated) { this.submissionComponent?.invalidateAndRefresh(false); } @@ -326,9 +327,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo } /** - * Perform the invalidate content function. - * - * @return Resolved when done. + * @inheritdoc */ protected async invalidateContent(): Promise { const promises: Promise[] = []; @@ -367,10 +366,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo } /** - * Compares sync event data with current data to check if refresh content is needed. - * - * @param syncEventData Data receiven on sync observer. - * @return True if refresh is needed, false otherwise. + * @inheritdoc */ protected isRefreshSyncNeeded(syncEventData: AddonModAssignAutoSyncData): boolean { if (!this.assign || syncEventData.assignId != this.assign.id) { @@ -386,20 +382,18 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo } /** - * Performs the sync of the activity. - * - * @return Promise resolved when done. + * @inheritdoc */ protected async sync(): Promise { if (!this.assign) { return; } - await AddonModAssignSync.syncAssign(this.assign.id); + return await AddonModAssignSync.syncAssign(this.assign.id); } /** - * Component being destroyed. + * @inheritdoc */ ngOnDestroy(): void { super.ngOnDestroy();