1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

feat(history): Enable group history

Fix #5452
This commit is contained in:
Anthony Bilinski 2022-03-09 02:58:58 -08:00
parent cd3c7b392e
commit 0352ada08c
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C

View File

@ -2135,16 +2135,13 @@ Group* Widget::createGroup(uint32_t groupnumber, const GroupId& groupId)
auto messageDispatcher = auto messageDispatcher =
std::make_shared<GroupMessageDispatcher>(*newgroup, std::move(messageProcessor), *core, std::make_shared<GroupMessageDispatcher>(*newgroup, std::move(messageProcessor), *core,
*core, settings); *core, settings);
auto groupChatLog = std::make_shared<SessionChatLog>(*core, *friendList);
connect(messageDispatcher.get(), &IMessageDispatcher::messageReceived, groupChatLog.get(), auto history = profile.getHistory();
&SessionChatLog::onMessageReceived); // Note: We do not have to connect the message dispatcher signals since
connect(messageDispatcher.get(), &IMessageDispatcher::messageSent, groupChatLog.get(), // ChatHistory hooks them up in a very specific order
&SessionChatLog::onMessageSent); auto chatHistory =
connect(messageDispatcher.get(), &IMessageDispatcher::messageComplete, groupChatLog.get(), std::make_shared<ChatHistory>(*newgroup, history, *core, settings,
&SessionChatLog::onMessageComplete); *messageDispatcher, *friendList);
connect(messageDispatcher.get(), &IMessageDispatcher::messageBroken, groupChatLog.get(),
&SessionChatLog::onMessageBroken);
auto notifyReceivedCallback = [this, groupId](const ToxPk& author, const Message& message) { auto notifyReceivedCallback = [this, groupId](const ToxPk& author, const Message& message) {
auto isTargeted = std::any_of(message.metadata.begin(), message.metadata.end(), 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); connect(messageDispatcher.get(), &IMessageDispatcher::messageReceived, notifyReceivedCallback);
groupAlertConnections.insert(groupId, notifyReceivedConnection); 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); settings, *documentCache, *smileyPack, style, messageBoxManager, *friendList);
connect(&settings, &Settings::nameColorsChanged, form, &GenericChatForm::setColorizedNames); connect(&settings, &Settings::nameColorsChanged, form, &GenericChatForm::setColorizedNames);
form->setColorizedNames(settings.getEnableGroupChatsColor()); form->setColorizedNames(settings.getEnableGroupChatsColor());
groupMessageDispatchers[groupId] = messageDispatcher; groupMessageDispatchers[groupId] = messageDispatcher;
groupChatLogs[groupId] = groupChatLog; groupChatLogs[groupId] = chatHistory;
groupWidgets[groupId] = widget; groupWidgets[groupId] = widget;
groupChatrooms[groupId] = chatroom; groupChatrooms[groupId] = chatroom;
groupChatForms[groupId] = QSharedPointer<GroupChatForm>(form); groupChatForms[groupId] = QSharedPointer<GroupChatForm>(form);