mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 07:26:19 +00:00
WIP preserve local changes before duckie merge
This commit is contained in:
@@ -48,6 +48,18 @@ export class MessengerThread
|
||||
return chat;
|
||||
}
|
||||
|
||||
public getChat(chatId: number): MessengerThreadChat
|
||||
{
|
||||
for(const group of this._groups)
|
||||
{
|
||||
const chat = group.chats.find(existingChat => (existingChat.id === chatId));
|
||||
|
||||
if(chat) return chat;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private pruneChats(): void
|
||||
{
|
||||
let totalChats = this._groups.reduce((total, current) => (total + current.chats.length), 0);
|
||||
|
||||
@@ -4,22 +4,49 @@ export class MessengerThreadChat
|
||||
public static ROOM_INVITE: number = 1;
|
||||
public static STATUS_NOTIFICATION: number = 2;
|
||||
public static SECURITY_NOTIFICATION: number = 3;
|
||||
private static CHAT_ID: number = 0;
|
||||
|
||||
private _id: number;
|
||||
private _type: number;
|
||||
private _senderId: number;
|
||||
private _message: string;
|
||||
private _secondsSinceSent: number;
|
||||
private _extraData: string;
|
||||
private _date: Date;
|
||||
private _showTranslation: boolean;
|
||||
private _originalMessage: string;
|
||||
private _translatedMessage: string;
|
||||
private _detectedLanguage: string;
|
||||
private _targetLanguage: string;
|
||||
|
||||
constructor(senderId: number, message: string, secondsSinceSent: number = 0, extraData: string = null, type: number = 0)
|
||||
{
|
||||
this._id = ++MessengerThreadChat.CHAT_ID;
|
||||
this._type = type;
|
||||
this._senderId = senderId;
|
||||
this._message = message;
|
||||
this._secondsSinceSent = secondsSinceSent;
|
||||
this._extraData = extraData;
|
||||
this._date = new Date();
|
||||
this._showTranslation = false;
|
||||
this._originalMessage = message;
|
||||
this._translatedMessage = '';
|
||||
this._detectedLanguage = '';
|
||||
this._targetLanguage = '';
|
||||
}
|
||||
|
||||
public setTranslation(originalMessage: string, translatedMessage: string, detectedLanguage: string, targetLanguage: string): void
|
||||
{
|
||||
this._showTranslation = true;
|
||||
this._originalMessage = originalMessage || this._message || '';
|
||||
this._translatedMessage = translatedMessage || this._originalMessage;
|
||||
this._detectedLanguage = detectedLanguage || '';
|
||||
this._targetLanguage = targetLanguage || '';
|
||||
}
|
||||
|
||||
public get id(): number
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public get type(): number
|
||||
@@ -51,4 +78,29 @@ export class MessengerThreadChat
|
||||
{
|
||||
return this._date;
|
||||
}
|
||||
|
||||
public get showTranslation(): boolean
|
||||
{
|
||||
return this._showTranslation;
|
||||
}
|
||||
|
||||
public get originalMessage(): string
|
||||
{
|
||||
return this._originalMessage;
|
||||
}
|
||||
|
||||
public get translatedMessage(): string
|
||||
{
|
||||
return this._translatedMessage;
|
||||
}
|
||||
|
||||
public get detectedLanguage(): string
|
||||
{
|
||||
return this._detectedLanguage;
|
||||
}
|
||||
|
||||
public get targetLanguage(): string
|
||||
{
|
||||
return this._targetLanguage;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user