diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2023-12-17 18:01:01 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2023-12-18 21:38:53 +0100 |
commit | fb65f6a6e802e5bb9ec80d0e91177a35a206e7a1 (patch) | |
tree | 3ea73b2f0c30356e69c62179d91f225c9f934ac4 /src/message.cpp | |
parent | 0bcef826baaa6a335d8fddafdbebd00fbf421c2c (diff) |
Message: use ready state before sending messages
Diffstat (limited to 'src/message.cpp')
-rw-r--r-- | src/message.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/message.cpp b/src/message.cpp index a9d6139..1ee362a 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -202,6 +202,7 @@ DirectMessageState DirectMessageState::load(const Ref & ref) .prev = rec->items("PREV").as<DirectMessageState>(), .peer = Identity::load(rec->items("peer").asRef()), + .ready = rec->items("ready").as<DirectMessageData>(), .sent = rec->items("sent").as<DirectMessageData>(), .received = rec->items("received").as<DirectMessageData>(), .seen = rec->items("seen").as<DirectMessageData>(), @@ -221,6 +222,8 @@ Ref DirectMessageState::store(const Storage & st) const for (const auto & ref : peer->refs()) items.emplace_back("peer", ref); + for (const auto & x : ready) + items.emplace_back("ready", x.ref()); for (const auto & x : sent) items.emplace_back("sent", x.ref()); for (const auto & x : received) @@ -280,8 +283,8 @@ bool DirectMessageThreads::operator!=(const DirectMessageThreads & other) const DirectMessageThread DirectMessageThreads::thread(const Identity & peer) const { vector<Stored<DirectMessageData>> head; - for (const auto & c : findThreadComponents(state, peer, &DirectMessageState::sent)) - for (const auto & m : c->sent) + for (const auto & c : findThreadComponents(state, peer, &DirectMessageState::ready)) + for (const auto & m : c->ready) head.push_back(m); for (const auto & c : findThreadComponents(state, peer, &DirectMessageState::received)) for (const auto & m : c->received) @@ -345,9 +348,7 @@ void DirectMessageService::handle(Context & ctx) auto state = st.store(DirectMessageState { .prev = threads.data(), .peer = powner, - .sent = {}, .received = { msg }, - .seen = {}, }); auto res = st.store(loc->shared<DirectMessageThreads>(DirectMessageThreads(state))); @@ -381,9 +382,7 @@ DirectMessage DirectMessageService::send(const Identity & to, const string & tex auto state = st.store(DirectMessageState { .prev = threads.data(), .peer = to, - .sent = { msg }, - .received = {}, - .seen = {}, + .ready = { msg }, }); return st.store(loc->shared<DirectMessageThreads>(DirectMessageThreads(state))); |