From c360be0b958d3b72360e24aa5f3cfa259c53c5a8 Mon Sep 17 00:00:00 2001
From: Nicolas Vengeon <nicolas.vengeon@savoirfairelinux.com>
Date: Thu, 22 Dec 2022 14:18:50 -0500
Subject: [PATCH] SidePanel: wrong conversation draft when account is changed

Change-Id: I7f6c6bca2cb5dd17a864c3da66a9e5e3a15400dc
GitLab: #913
---
 src/app/mainview/components/ChatViewFooter.qml | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/app/mainview/components/ChatViewFooter.qml b/src/app/mainview/components/ChatViewFooter.qml
index ade0774dd..a2f161971 100644
--- a/src/app/mainview/components/ChatViewFooter.qml
+++ b/src/app/mainview/components/ChatViewFooter.qml
@@ -31,6 +31,7 @@ Rectangle {
 
     property alias textInput: messageBar.textAreaObj
     property string previousConvId: ""
+    property string previousAccountId: ""
 
     function setFilePathsToSend(filePaths) {
         for (var index = 0; index < filePaths.length; ++index) {
@@ -48,8 +49,8 @@ Rectangle {
 
         function onSelectedConvUidChanged() {
             // Handle Draft
-            if (previousConvId !== "") {
-                LRCInstance.setContentDraft(previousConvId, LRCInstance.currentAccountId,
+            if (previousConvId !== "" && previousAccountId != "") {
+                LRCInstance.setContentDraft(previousConvId, previousAccountId,
                                             messageBar.text);
             }
 
@@ -58,6 +59,7 @@ Rectangle {
 
             messageBar.textAreaObj.clearText()
             previousConvId = LRCInstance.selectedConvUid
+            previousAccountId = LRCInstance.currentAccountId
 
             var restoredContent = LRCInstance.getContentDraft(LRCInstance.selectedConvUid,
                                                               LRCInstance.currentAccountId);
-- 
GitLab