From 8e7114c54f79c4dd8714d128e41943ae70b38c2e Mon Sep 17 00:00:00 2001 From: Thomas Chazot Date: Sun, 16 Oct 2022 13:08:13 +0200 Subject: [PATCH] Fix:Changement du tableau de conversation des user Ajout d'une conv test pour Alban --- bob_party/src/constCov.ts | 23 +++++++++++++++++++++++ bob_party/src/core/conversation.ts | 2 +- bob_party/src/core/user.ts | 14 +++++++++----- 3 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 bob_party/src/constCov.ts diff --git a/bob_party/src/constCov.ts b/bob_party/src/constCov.ts new file mode 100644 index 0000000..fb0ccf3 --- /dev/null +++ b/bob_party/src/constCov.ts @@ -0,0 +1,23 @@ +import { Message } from "./core/message" +import { Conversation } from "./core/conversation" +import tabSkinApp from './constSkin' +import { User } from "./core/user"; + + +let UserActu:User=new User("14", "leBg", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, tabSkinApp[0], tabSkinApp, undefined); +let UserTest:User=new User("48", "Wesh Wesh", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, tabSkinApp[0], tabSkinApp, undefined); + +let tabMessageTest:Message[]=[ + new Message("Salut", UserActu, new Date(2022,12,12)), + new Message("Wesh", UserTest, new Date(2022,12,13)), + new Message("Ca va", UserActu, new Date(2022,12,14)), + new Message("Ouais et toi?", UserTest, new Date(2022,12,15)), +] + +let tabUS:User[]=[UserActu, UserTest]; + +let conv = new Conversation(tabUS, tabMessageTest, "le super nom"); + +export default conv; + + diff --git a/bob_party/src/core/conversation.ts b/bob_party/src/core/conversation.ts index 52fdc34..abbe1c2 100644 --- a/bob_party/src/core/conversation.ts +++ b/bob_party/src/core/conversation.ts @@ -41,7 +41,7 @@ export class Conversation{ getLastMessage(){ this.sortMessageDesc(); - return this.TabMessage[0]; + return this.TabMessage[0].getMessageContent(); } sortMessageDesc(){ diff --git a/bob_party/src/core/user.ts b/bob_party/src/core/user.ts index 0bb386f..5cba515 100644 --- a/bob_party/src/core/user.ts +++ b/bob_party/src/core/user.ts @@ -11,10 +11,10 @@ export class User{ private TotalCoins: number; private CurrentSkin: Skin; private TabSkin: Skin[]; - private TabConv: Conversation[]; + private TabConv?: Conversation[]; constructor(id: string, username: string, nationality: string, sexe: string, dateOfBirth: Date, currentCoins: number, totalCoins: number, - currentSkin: Skin, tabSkin: Skin[], tabConv: Conversation[] ){ + currentSkin: Skin, tabSkin: Skin[], tabConv?: Conversation[] ){ this.Id=id; this.Username=username; this.Nationality=nationality; @@ -24,7 +24,9 @@ export class User{ this.TotalCoins=totalCoins; this.CurrentSkin=currentSkin; this.TabSkin=[...tabSkin]; - this.TabConv=[...tabConv]; + tabConv?.forEach(conv => { + this.TabConv?.push(conv); + }); } getUsername(){ @@ -103,7 +105,9 @@ export class User{ return this.TabConv; } - setTabConv(tabConv: Conversation[]){ - this.TabConv=[...tabConv]; + setTabConv(tabConv?: Conversation[]){ + tabConv?.forEach(conv => { + this.TabConv?.push(conv); + }); } } \ No newline at end of file