8#include <unordered_map>
49class ChatManager :
public std::enable_shared_from_this<ChatManager>
55 void setNetwork(std::weak_ptr<NetworkManager> nm);
71 const std::string& fromPeer,
72 const std::string& username,
73 const std::string& text,
105 std::unordered_map<uint64_t, ChatGroupModel>
groups_;
144 static ImVec4
HSVtoRGB(
float h,
float s,
float v);
149 std::filesystem::path
chatFilePathFor(uint64_t tableId,
const std::string& name)
const;
157 void emitChatMessageFrame(uint64_t groupId,
const std::string& username,
const std::string& text, uint64_t ts);
169 bool saveLog(std::vector<uint8_t>& buf)
const;
170 bool loadLog(
const std::vector<uint8_t>& buf);
void renderRightPanel(float leftPanelWidth)
uint64_t makeGroupIdFromName(const std::string &name) const
void renderPlainMessage(const std::string &text) const
void pushMessageLocal(uint64_t groupId, const std::string &fromPeer, const std::string &username, const std::string &text, double ts, bool incoming)
std::array< char, 512 > input_
ChatGroupModel * getGroup(uint64_t id)
void renderEditGroupPopup()
std::set< std::string > resolvePeerIdsForParticipants(const std::set< std::string > &participantUids) const
void renderCreateGroupPopup()
std::array< char, 128 > editGroupName_
std::set< std::string > newGroupSel_
static ImVec4 HSVtoRGB(float h, float s, float v)
void emitGroupLeave(uint64_t groupId)
void tryHandleSlashCommand(uint64_t threadId, const std::string &input)
void emitChatMessageFrame(uint64_t groupId, const std::string &username, const std::string &text, uint64_t ts)
void renderColoredUsername(const std::string &name) const
ImU32 getUsernameColor(const std::string &name) const
void setActiveGameTable(uint64_t tableId, const std::string &gameTableName)
std::set< std::string > editGroupSel_
void emitGroupUpdate(const ChatGroupModel &g)
void replaceUsernameForUnique(const std::string &uniqueId, const std::string &newUsername)
std::filesystem::path chatFilePathFor(uint64_t tableId, const std::string &name) const
std::unordered_map< std::string, ImU32 > nameColorCache_
std::string currentTableName_
bool isMeParticipantOf(const ChatGroupModel &g) const
void renderDeleteGroupPopup()
bool saveLog(std::vector< uint8_t > &buf) const
void writeGroupsToSnapshotGT(std::vector< unsigned char > &buf) const
static ChatMessageModel::Kind classifyMessage(const std::string &s)
std::unordered_map< uint64_t, ChatGroupModel > groups_
static constexpr uint64_t generalGroupId_
void emitGroupCreate(const ChatGroupModel &g)
bool loadLog(const std::vector< uint8_t > &buf)
std::array< char, 128 > newGroupName_
void setNetwork(std::weak_ptr< NetworkManager > nm)
ChatManager(std::weak_ptr< NetworkManager > nm, std::shared_ptr< IdentityManager > identity_manager)
std::shared_ptr< IdentityManager > identity_manager
void readGroupsFromSnapshotGT(const std::vector< unsigned char > &buf, size_t &off)
void markGroupRead(uint64_t groupId)
void renderLeftPanel(float width)
std::weak_ptr< NetworkManager > network_
void applyReady(const msg::ReadyMessage &m)
void emitGroupDelete(uint64_t groupId)
std::string ownerUniqueId
std::deque< ChatMessageModel > messages
std::set< std::string > participants
std::string senderUniqueId