MOBILE-4470 chat: Fix beeps not appearing anymore

main
Dani Palou 2024-06-11 14:50:28 +02:00
parent ad08fcf4b9
commit 186164ac4e
3 changed files with 15 additions and 12 deletions

View File

@ -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<string> {
const idNumber = parseInt(id, 10);
protected async getUserFullname(id: string | number): Promise<string> {
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);
}
}

View File

@ -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<string> {
const idNumber = parseInt(id, 10);
protected async getUserFullname(id: string | number): Promise<string> {
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);
}
}

View File

@ -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 || (<AddonModChatSessionMessage> message).issystem ||
(<AddonModChatMessage> 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).