From 0352ada08c7efa4ad6523071bde566f506daeb4d Mon Sep 17 00:00:00 2001 From: Anthony Bilinski Date: Wed, 9 Mar 2022 02:58:58 -0800 Subject: [PATCH] feat(history): Enable group history Fix #5452 --- src/widget/widget.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 5a6b46eaa..20e6aff42 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -2135,16 +2135,13 @@ Group* Widget::createGroup(uint32_t groupnumber, const GroupId& groupId) auto messageDispatcher = std::make_shared(*newgroup, std::move(messageProcessor), *core, *core, settings); - auto groupChatLog = std::make_shared(*core, *friendList); - connect(messageDispatcher.get(), &IMessageDispatcher::messageReceived, groupChatLog.get(), - &SessionChatLog::onMessageReceived); - connect(messageDispatcher.get(), &IMessageDispatcher::messageSent, groupChatLog.get(), - &SessionChatLog::onMessageSent); - connect(messageDispatcher.get(), &IMessageDispatcher::messageComplete, groupChatLog.get(), - &SessionChatLog::onMessageComplete); - connect(messageDispatcher.get(), &IMessageDispatcher::messageBroken, groupChatLog.get(), - &SessionChatLog::onMessageBroken); + auto history = profile.getHistory(); + // Note: We do not have to connect the message dispatcher signals since + // ChatHistory hooks them up in a very specific order + auto chatHistory = + std::make_shared(*newgroup, history, *core, settings, + *messageDispatcher, *friendList); auto notifyReceivedCallback = [this, groupId](const ToxPk& author, const Message& message) { auto isTargeted = std::any_of(message.metadata.begin(), message.metadata.end(), @@ -2159,12 +2156,12 @@ Group* Widget::createGroup(uint32_t groupnumber, const GroupId& groupId) connect(messageDispatcher.get(), &IMessageDispatcher::messageReceived, notifyReceivedCallback); groupAlertConnections.insert(groupId, notifyReceivedConnection); - auto form = new GroupChatForm(*core, newgroup, *groupChatLog, *messageDispatcher, + auto form = new GroupChatForm(*core, newgroup, *chatHistory, *messageDispatcher, settings, *documentCache, *smileyPack, style, messageBoxManager, *friendList); connect(&settings, &Settings::nameColorsChanged, form, &GenericChatForm::setColorizedNames); form->setColorizedNames(settings.getEnableGroupChatsColor()); groupMessageDispatchers[groupId] = messageDispatcher; - groupChatLogs[groupId] = groupChatLog; + groupChatLogs[groupId] = chatHistory; groupWidgets[groupId] = widget; groupChatrooms[groupId] = chatroom; groupChatForms[groupId] = QSharedPointer(form);