From 8d6728101b93b159de178096cd3b71816332bad8 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 7 Sep 2018 15:41:48 +0200 Subject: [PATCH 1/2] MOBILE-2567 resource: Fix date displayed in course page --- src/addon/mod/resource/lang/en.json | 1 + .../mod/resource/providers/module-handler.ts | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/addon/mod/resource/lang/en.json b/src/addon/mod/resource/lang/en.json index 46a1f7e35..54d284bf5 100644 --- a/src/addon/mod/resource/lang/en.json +++ b/src/addon/mod/resource/lang/en.json @@ -1,5 +1,6 @@ { "errorwhileloadingthecontent": "Error while loading the content.", + "modifieddate": "Modified {{$a}}", "openthefile": "Open the file", "uploadeddate": "Uploaded {{$a}}" } \ No newline at end of file diff --git a/src/addon/mod/resource/providers/module-handler.ts b/src/addon/mod/resource/providers/module-handler.ts index 79700acb2..b44775b42 100644 --- a/src/addon/mod/resource/providers/module-handler.ts +++ b/src/addon/mod/resource/providers/module-handler.ts @@ -156,16 +156,24 @@ export class AddonModResourceModuleHandler implements CoreCourseModuleHandler { if (options.showtype) { extra.push(this.mimetypeUtils.getMimetypeDescription(file)); } + + if (options.showdate) { + /* Modified date may be up to several minutes later than uploaded date just because + teacher did not submit the form promptly. Give teacher up to 5 minutes to do it. */ + if (file.timemodified > file.timecreated + CoreConstants.SECONDS_MINUTE * 5) { + extra.push(this.translate.instant('addon.mod_resource.modifieddate', + {$a: moment(file.timemodified * 1000).format('LLL')})); + } else { + extra.push(this.translate.instant('addon.mod_resource.uploadeddate', + {$a: moment(file.timecreated * 1000).format('LLL')})); + } + } } if (resourceData.icon == '') { resourceData.icon = this.courseProvider.getModuleIconSrc(this.modName); } - if (options.showdate) { - extra.push(this.translate.instant('addon.mod_resource.uploadeddate', - {$a: moment(resourceInfo.timemodified * 1000).format('LLL')})); - } resourceData.extra += extra.join(' '); return resourceData; From ec6ee6a51aff0fc970eacdd3c42f21858d5bd9eb Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 7 Sep 2018 15:50:05 +0200 Subject: [PATCH 2/2] MOBILE-2567 notifications: Fix tslint warning --- src/addon/notifications/pages/list/list.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/addon/notifications/pages/list/list.ts b/src/addon/notifications/pages/list/list.ts index 241a54e09..07de7da86 100644 --- a/src/addon/notifications/pages/list/list.ts +++ b/src/addon/notifications/pages/list/list.ts @@ -176,6 +176,7 @@ export class AddonNotificationsListPage { // Check if mark all notifications as read is enabled and there are some to read. if (this.notificationsProvider.isMarkAllNotificationsAsReadEnabled()) { this.loadingMarkAllNotificationsAsRead = true; + return this.notificationsProvider.getUnreadNotificationsCount().then((unread) => { this.canMarkAllNotificationsAsRead = unread > 0; this.loadingMarkAllNotificationsAsRead = false;