From a531204489936c34f2bdfb96dba0fa456c47d7b4 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 7 Dec 2017 17:25:35 +0100 Subject: [PATCH] fix(BasicChatRoom): do not notify chat room state when it is fetched from database --- src/chat/chat-room/chat-room-p.h | 3 ++- src/core/core-chat-room.cpp | 9 ++++++--- src/core/core-p.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/chat/chat-room/chat-room-p.h b/src/chat/chat-room/chat-room-p.h index 2f5f0bdac..4ba48402b 100644 --- a/src/chat/chat-room/chat-room-p.h +++ b/src/chat/chat-room/chat-room-p.h @@ -69,7 +69,6 @@ public: std::shared_ptr createChatMessage (ChatMessage::Direction direction); LinphoneCall *call = nullptr; - ChatRoom::State state = ChatRoom::State::None; bool isComposing = false; std::list
remoteIsComposing; std::list> transientEvents; @@ -82,6 +81,8 @@ public: // TODO: Check all fields before this point. + ChatRoom::State state = ChatRoom::State::None; + public: virtual void onChatMessageReceived (const std::shared_ptr &chatMessage) = 0; diff --git a/src/core/core-chat-room.cpp b/src/core/core-chat-room.cpp index 164be345d..94e3d9df7 100644 --- a/src/core/core-chat-room.cpp +++ b/src/core/core-chat-room.cpp @@ -61,7 +61,7 @@ static IdentityAddress getDefaultLocalAddress (const shared_ptr &core, con // ----------------------------------------------------------------------------- -shared_ptr CorePrivate::createBasicChatRoom (const ChatRoomId &chatRoomId, bool isRtt) { +shared_ptr CorePrivate::createBasicChatRoom (const ChatRoomId &chatRoomId, bool isRtt, bool notifyCreation) { L_Q(); shared_ptr chatRoom; @@ -73,8 +73,11 @@ shared_ptr CorePrivate::createBasicChatRoom (const ChatRoomId &chatRoo ChatRoomPrivate *dChatRoom = chatRoom->getPrivate(); - dChatRoom->setState(ChatRoom::State::Instantiated); - dChatRoom->setState(ChatRoom::State::Created); + if (notifyCreation) { + dChatRoom->setState(ChatRoom::State::Instantiated); + dChatRoom->setState(ChatRoom::State::Created); + } else + dChatRoom->state = ChatRoom::State::Created; return chatRoom; } diff --git a/src/core/core-p.h b/src/core/core-p.h index e0904c757..a887b7f47 100644 --- a/src/core/core-p.h +++ b/src/core/core-p.h @@ -54,7 +54,7 @@ public: void insertChatRoom (const std::shared_ptr &chatRoom); void insertChatRoomWithDb (const std::shared_ptr &chatRoom); - std::shared_ptr createBasicChatRoom (const ChatRoomId &chatRoomId, bool isRtt); + std::shared_ptr createBasicChatRoom (const ChatRoomId &chatRoomId, bool isRtt, bool notifyCreation = true); std::unique_ptr mainDb;