summaryrefslogtreecommitdiff
path: root/src/chatManager.cpp
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-04-02 18:49:15 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-04-07 16:32:07 +0800
commiteff21ee2ce1fdb4328d71d801352ec25f4e457ff (patch)
treef2b3febdbd84ca7e7b799f04a407bf408719c93e /src/chatManager.cpp
parent50de5f9b80f1859b6eaa3b68c10a3f1cfb994737 (diff)
feat: ftxui (#17)
* ready for merge rm sum random ocmments first and https://github.com/ArthurSonzogni/FTXUI/issues/1024 but still, ready for merge since we can't do anything on our end * style: clang-tidy * ci * ci * style: clang-tidy * fix * fix: scroll https://github.com/ArthurSonzogni/git-tui/blob/master/src/scroller.cpp * focus * update todo * style: clang-format * update todo * sticky scroll * update todxo * smol fix need event to update screen. so we just give event when IO updates * style: clang-format --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/chatManager.cpp')
-rw-r--r--src/chatManager.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/chatManager.cpp b/src/chatManager.cpp
index 3b8c82d..96c1b0c 100644
--- a/src/chatManager.cpp
+++ b/src/chatManager.cpp
@@ -1,4 +1,6 @@
#include "chatManager.hpp"
+#include "IOManager.hpp"
+#include "inputManager.hpp"
#include "log.hpp"
#include "sessionManager.hpp"
@@ -7,7 +9,6 @@ CChatManager::CChatManager() {
}
CChatManager::~CChatManager() {
- m_vMessages.clear();
log(SYS, "ChatManager: bye");
}
@@ -19,13 +20,19 @@ void CChatManager::newMessage(const SMessage &msg) {
return;
}
g_pSessionManager->broadcastChat(msg);
- m_vMessages.push_back(msg);
+ g_pIOManager->m_vIO.push_back({.msg = msg, .log = std::nullopt});
+ g_pInputManager->updateIO();
}
std::string CChatManager::fmtBroadcastMessage(const SMessage &msg) {
return NFormatter::fmt(NONE, "{}: {}", msg.username, msg.msg);
}
-const std::vector<CChatManager::SMessage> &CChatManager::getChat() const {
- return m_vMessages;
+std::vector<CChatManager::SMessage> CChatManager::getChat() const {
+ std::vector<SMessage> chat;
+
+ for (const auto &[msg, log] : g_pIOManager->getIO())
+ if (msg)
+ chat.push_back(*msg);
+ return chat;
}