From 186164ac4e802ba3880391341be039c9fb08809a Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 11 Jun 2024 14:50:28 +0200 Subject: [PATCH 1/3] MOBILE-4470 chat: Fix beeps not appearing anymore --- src/addons/mod/chat/pages/chat/chat.ts | 12 ++++++------ .../chat/pages/session-messages/session-messages.ts | 10 +++++----- src/addons/mod/chat/services/chat-helper.ts | 5 ++++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/addons/mod/chat/pages/chat/chat.ts b/src/addons/mod/chat/pages/chat/chat.ts index dd0add80e..2c0d46706 100644 --- a/src/addons/mod/chat/pages/chat/chat.ts +++ b/src/addons/mod/chat/pages/chat/chat.ts @@ -166,7 +166,7 @@ export class AddonModChatChatPage implements OnInit, OnDestroy, CanLeave { const message = this.messages[index]; - if (message.beep && message.beep != String(this.currentUserId)) { + if (message.beep && message.beep !== this.currentUserId) { this.loadMessageBeepWho(message); } } @@ -212,11 +212,11 @@ export class AddonModChatChatPage implements OnInit, OnDestroy, CanLeave { * @param id User Id before parsing. * @returns User fullname. */ - protected async getUserFullname(id: string): Promise { - const idNumber = parseInt(id, 10); + protected async getUserFullname(id: string | number): Promise { + const idNumber = Number(id); if (isNaN(idNumber)) { - return id; + return String(id); } const user = this.users.find((user) => user.id == idNumber); @@ -235,10 +235,10 @@ export class AddonModChatChatPage implements OnInit, OnDestroy, CanLeave { return user.fullname; } - return id; + return String(id); } catch { // Ignore errors. - return id; + return String(id); } } diff --git a/src/addons/mod/chat/pages/session-messages/session-messages.ts b/src/addons/mod/chat/pages/session-messages/session-messages.ts index e3143eec7..682bb738e 100644 --- a/src/addons/mod/chat/pages/session-messages/session-messages.ts +++ b/src/addons/mod/chat/pages/session-messages/session-messages.ts @@ -112,7 +112,7 @@ export class AddonModChatSessionMessagesPage implements OnInit { const message = this.messages[index]; - if (message.beep && message.beep != String(this.currentUserId)) { + if (message.beep && message.beep !== this.currentUserId) { this.loadMessageBeepWho(message); } } @@ -135,11 +135,11 @@ export class AddonModChatSessionMessagesPage implements OnInit { * @param id User Id before parsing. * @returns User fullname. */ - protected async getUserFullname(id: string): Promise { - const idNumber = parseInt(id, 10); + protected async getUserFullname(id: string | number): Promise { + const idNumber = Number(id); if (isNaN(idNumber)) { - return id; + return String(id); } try { @@ -148,7 +148,7 @@ export class AddonModChatSessionMessagesPage implements OnInit { return user.fullname; } catch { // Error getting profile. - return id; + return String(id); } } diff --git a/src/addons/mod/chat/services/chat-helper.ts b/src/addons/mod/chat/services/chat-helper.ts index 49f466243..2380408df 100644 --- a/src/addons/mod/chat/services/chat-helper.ts +++ b/src/addons/mod/chat/services/chat-helper.ts @@ -54,6 +54,9 @@ export class AddonModChatHelperProvider { formattedMessage.showDate = this.showDate(message, prevMessage); formattedMessage.beep = (message.message.substring(0, 5) == 'beep ' && message.message.substring(5).trim()) || undefined; + if (formattedMessage.beep && !isNaN(Number(formattedMessage.beep))) { + formattedMessage.beep = Number(formattedMessage.beep); + } formattedMessage.special = !!formattedMessage.beep || ( message).issystem || ( message).system; @@ -133,7 +136,7 @@ export const AddonModChatHelper = makeSingleton(AddonModChatHelperProvider); */ type AddonModChatInfoForView = { showDate?: boolean; // If date should be displayed before the message. - beep?: string; // User id of the beeped user or 'all'. + beep?: string | number; // User id of the beeped user or 'all'. special?: boolean; // True if is an special message (system, beep or command). showUserData?: boolean; // If user data should be displayed. showTail?: boolean; // If tail should be displayed (decoration). From ce56d9dd2f20b6883150bf6f763493f45b87181b Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 12 Jun 2024 11:17:10 +0200 Subject: [PATCH 2/3] MOBILE-4470 ddmarker: Fix regression caused by MOBILE-3403 --- src/addons/qtype/ddmarker/classes/ddmarker.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/addons/qtype/ddmarker/classes/ddmarker.ts b/src/addons/qtype/ddmarker/classes/ddmarker.ts index fead3a931..98d937316 100644 --- a/src/addons/qtype/ddmarker/classes/ddmarker.ts +++ b/src/addons/qtype/ddmarker/classes/ddmarker.ts @@ -20,6 +20,8 @@ import { CoreLogger } from '@singletons/logger'; import { AddonQtypeDdMarkerQuestionData } from '../component/ddmarker'; import { AddonQtypeDdMarkerGraphicsApi } from './graphics_api'; import { CoreUtils } from '@services/utils/utils'; +import { CoreDirectivesRegistry } from '@singletons/directives-registry'; +import { CoreExternalContentDirective } from '@directives/external-content'; /** * Class to make a question of ddmarker type work. @@ -678,7 +680,7 @@ export class AddonQtypeDdMarkerQuestion { /** * Wait for the background image to be loaded. */ - pollForImageLoad(): void { + async pollForImageLoad(): Promise { if (this.afterImageLoadDone) { // Already treated. return; @@ -689,6 +691,9 @@ export class AddonQtypeDdMarkerQuestion { return; } + // Wait for external-content to finish, otherwise the image doesn't have a src and the calculations are wrong. + await CoreDirectivesRegistry.waitDirectivesReady(bgImg, undefined, CoreExternalContentDirective); + if (!bgImg.src && this.imgSrc) { bgImg.src = this.imgSrc; } From 766a3345706024395db079dcde512a9a9149f20b Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 12 Jun 2024 11:28:42 +0200 Subject: [PATCH 3/3] MOBILE-4470 core: Bump version code to 44001 --- config.xml | 4 ++-- moodle.config.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config.xml b/config.xml index ae0292fe4..79dd29a95 100644 --- a/config.xml +++ b/config.xml @@ -1,5 +1,5 @@ - + Moodle Moodle official app Moodle Mobile team @@ -28,7 +28,7 @@ - + diff --git a/moodle.config.json b/moodle.config.json index 2fc0be9b2..5340d79db 100644 --- a/moodle.config.json +++ b/moodle.config.json @@ -1,7 +1,7 @@ { "app_id": "com.moodle.moodlemobile", "appname": "Moodle Mobile", - "versioncode": 44000, + "versioncode": 44001, "versionname": "4.4.0", "cache_update_frequency_usually": 420000, "cache_update_frequency_often": 1200000,