diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Channel.cpp | 1 | ||||
-rw-r--r-- | src/MessageBoard.cpp | 13 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/Channel.cpp b/src/Channel.cpp index 06c0b79..c1e63ea 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -22,6 +22,7 @@ namespace dchat addLocalMessage(u8"[emoji](https://discordemoji.com/assets/emoji/PepeDab.gif) deaf [emoji](https://discordemoji.com/assets/emoji/COGGERS.gif)", &systemUser, 0, odhtdb::Hash()); addLocalMessage(u8"[emoji](https://discordemoji.com/assets/emoji/PepeDab.gif)[emoji](https://discordemoji.com/assets/emoji/COGGERS.gif)", &systemUser, 0, odhtdb::Hash()); addLocalMessage(u8"pepedab https://discordemoji.com/assets/emoji/PepeDab.gif coggers https://discordemoji.com/assets/emoji/COGGERS.gif check out this url http://www.grandtournation.com/6808/start-date-of-the-grand-tour-season-3-confirmed-mark-your-calendars/ owo", &systemUser, 0, odhtdb::Hash()); + addLocalMessage(u8"ht clic", &systemUser, 0, odhtdb::Hash()); if(database) database->seed(databaseNodeInfo); diff --git a/src/MessageBoard.cpp b/src/MessageBoard.cpp index b1f8b0b..bc53ae3 100644 --- a/src/MessageBoard.cpp +++ b/src/MessageBoard.cpp @@ -59,6 +59,17 @@ namespace dchat } } + // TODO: Optimize this with binary search + usize MessageBoard::findPositionToInsertMessageByTimestamp(Message *message) + { + for(usize i = 0; i < messages.size(); ++i) + { + if(message->timestampSeconds < messages[i]->timestampSeconds) + return i; + } + return messages.size(); + } + void MessageBoard::updateStaticContentTexture(const sf::Vector2u &newSize) { //if(!staticContentTexture.create(newSize.x, newSize.y)) @@ -69,7 +80,7 @@ namespace dchat void MessageBoard::addMessage(Message *message, const odhtdb::Hash &id) { lock_guard<mutex> lock(messageProcessMutex); - messages.push_back(message); + messages.insert(messages.begin() + findPositionToInsertMessageByTimestamp(message), message); if(!id.isEmpty()) messageIdMap[id] = message; dirty = true; |