diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-05-17 03:34:41 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-05-17 03:34:43 +0200 |
commit | e4cc9c03bf2578cbe2b8c9e909e9803ff856dd9d (patch) | |
tree | 88f9a2c72c678ff0df966769efb67184604c9ea1 /src | |
parent | 528a61c86876de814ff4e65855926a750ba24587 (diff) |
Fix url parsing in text, sort messages by timestamp
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; |