From df58083c460c05956e8e953ee7def56029923ced Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?=
Date: Wed, 30 Nov 2022 09:54:38 +0100
Subject: [PATCH] MOBILE-4081 user: Use lastcourseaccess if not undefined
---
scripts/langindex.json | 1 +
src/core/features/user/lang.json | 1 +
.../user/pages/participants/participants.html | 13 ++++++++-----
src/core/features/user/pages/profile/profile.html | 5 +++++
src/core/features/user/services/user.ts | 2 +-
src/core/pipes/time-ago.ts | 2 +-
6 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/scripts/langindex.json b/scripts/langindex.json
index f3ca9d8c7..d319bd42f 100644
--- a/scripts/langindex.json
+++ b/scripts/langindex.json
@@ -2387,6 +2387,7 @@
"core.user.errorloaduser": "local_moodlemobileapp",
"core.user.firstname": "moodle",
"core.user.interests": "moodle",
+ "core.user.lastcourseaccess": "moodle",
"core.user.lastname": "moodle",
"core.user.manager": "role",
"core.user.newpicture": "moodle",
diff --git a/src/core/features/user/lang.json b/src/core/features/user/lang.json
index 5be59a0aa..027f190f4 100644
--- a/src/core/features/user/lang.json
+++ b/src/core/features/user/lang.json
@@ -19,6 +19,7 @@
"errorloaduser": "Error loading user.",
"firstname": "First name",
"interests": "Interests",
+ "lastcourseaccess": "Last access to course",
"lastname": "Surname",
"manager": "Manager",
"newpicture": "New picture",
diff --git a/src/core/features/user/pages/participants/participants.html b/src/core/features/user/pages/participants/participants.html
index 6fa6a38d8..d413aa56f 100644
--- a/src/core/features/user/pages/participants/participants.html
+++ b/src/core/features/user/pages/participants/participants.html
@@ -34,13 +34,16 @@
{{ participant.fullname }}
-
- {{ 'core.lastaccess' | translate }}:
- {{ participant.lastcourseaccess | coreTimeAgo }}
+
+ {{ 'core.user.lastcourseaccess' | translate }}:
+ {{ participant.lastcourseaccess | coreTimeAgo }}
+
+ {{ 'core.never' | translate }}
-
+
{{ 'core.lastaccess' | translate }}:
- {{ participant.lastaccess | coreTimeAgo }}
+ {{ participant.lastaccess | coreTimeAgo }}
+ {{ 'core.never' | translate }}
diff --git a/src/core/features/user/pages/profile/profile.html b/src/core/features/user/pages/profile/profile.html
index 52d71a6cf..006e7cc20 100644
--- a/src/core/features/user/pages/profile/profile.html
+++ b/src/core/features/user/pages/profile/profile.html
@@ -26,6 +26,11 @@
{{ 'core.user.roles' | translate}}{{'core.labelsep' | translate}}
{{ rolesFormatted }}
+
+ {{ 'core.lastaccess' | translate }}:
+ {{ user.lastaccess | coreTimeAgo }}
+ {{ 'core.never' | translate }}
+
diff --git a/src/core/features/user/services/user.ts b/src/core/features/user/services/user.ts
index e54cdb230..d0156e5c1 100644
--- a/src/core/features/user/services/user.ts
+++ b/src/core/features/user/services/user.ts
@@ -1003,7 +1003,7 @@ export type CoreUserParticipant = CoreUserBasicData & {
interests?: string; // User interests (separated by commas).
firstaccess?: number; // First access to the site (0 if never).
lastaccess?: number; // Last access to the site (0 if never).
- lastcourseaccess?: number | null; // Last access to the course (0 if never).
+ lastcourseaccess?: number | null; // @since 3.7. Last access to the course (0 if never).
description?: string; // User profile description.
descriptionformat?: number; // Description format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN).
city?: string; // Home city of the user.
diff --git a/src/core/pipes/time-ago.ts b/src/core/pipes/time-ago.ts
index b301c5751..211950459 100644
--- a/src/core/pipes/time-ago.ts
+++ b/src/core/pipes/time-ago.ts
@@ -38,7 +38,7 @@ export class CoreTimeAgoPipe implements PipeTransform {
* @return Formatted time.
*/
transform(timestamp: string | number): string {
- if (typeof timestamp == 'string') {
+ if (typeof timestamp === 'string') {
// Convert the value to a number.
const numberTimestamp = parseInt(timestamp, 10);
if (isNaN(numberTimestamp)) {