X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=js%2FpageMinichat%2Fconversations.js;h=0ad7878a2d991ca97907d6e2604a7ef8558d1d5f;hp=ada8a24382bc09f8cf3c20e5b0cea8ebedf7bf17;hb=a57cb5dd4f773111f734c726f61f06434c39b94e;hpb=217c4d7a0d5f9fee3a8ef0a05ab8506c7f39d5e5 diff --git a/js/pageMinichat/conversations.js b/js/pageMinichat/conversations.js index ada8a24..0ad7878 100644 --- a/js/pageMinichat/conversations.js +++ b/js/pageMinichat/conversations.js @@ -218,9 +218,14 @@ euphorik.Conversations.prototype.ajouterMessages = function(elements, numConvers if (!elements.messages.length) { return this.conversations[numConversation] !== undefined; } - + for (var i = 0; i < elements.messages.length; i++) { - this.ajouterMessage(elements.messages[i], numConversation) + if (this.ajouterMessage(elements.messages[i], numConversation)) { + // si une nouvelle conversation a été créée alors on lui donne la racine + // TODO : ce block ne devrait pas se trouver ici mais dans "nouvelleConversation" + this.conversations[numConversation].setRacine(elements.first); + this.mettreAJourFragment(); + } } this.flush(numConversation); @@ -255,44 +260,19 @@ euphorik.Conversations.prototype.ajouterMessage = function(element, numConversat if (!this.conversations[numConversation]) { nouvelleConversation = true; - this.nouvelleConversation( - numConversation, - message, // si une nouvelle conversation a été créée alors on lui donne la racine qui correspond au premier message - function(num) { // fermeture de la conversation - thisConversations.supprimerConversation(num); - }, - function(num) { // insertion du lien vers la conversation - thisPage.util.replaceSelection( - $("form#posterMessage input.message")[0], - "{" + thisConversations.client.conversations[num-1].root.toString(36) + "}" - ); - } - ); + this.nouvelleConversation(numConversation); } this.conversations[numConversation].ajouterMessage(message); return nouvelleConversation; }; -euphorik.Conversations.prototype.nouvelleConversation = function(num, racine, funFermer, funLien) +euphorik.Conversations.prototype.nouvelleConversation = function(num) { var thisMessages = this; this.conversations[num] = new euphorik.Conversation(this, num); - - if (racine) { - this.conversations[num].racine = racine; - this.mettreAJourFragment(); - } - - if (funFermer) { - this.conversations[num].eventFermer(funFermer); - } - - if (funLien) { - this.conversations[num].eventLien(funLien); - } - + this.conversations[num].setFunPage( function(num) { // page suivante thisMessages.client.pageSuivante(num - 1);