Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F16923955
D255.1766154800.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D255.1766154800.diff
View Options
diff --git a/src/client/client.hpp b/src/client/client.hpp
--- a/src/client/client.hpp
+++ b/src/client/client.hpp
@@ -615,6 +615,18 @@
*/
PromiseT purgeRoomEvents(immer::map<std::string, std::size_t> roomIdToMaxToKeepMap) const;
+ /**
+ * Load events from storage into the model.
+ *
+ * @param timelineEvents Map from room id to a list of message events that
+ * should be put into the timeline.
+ * @param relatedEvents Map from room id to a list of message events that should
+ * not be put into the timeline (for example, because the storage does not
+ * know or care where it should go in the timeline).
+ * @return A Promise that resolves when the events are loaded into the store.
+ */
+ PromiseT loadEventsFromStorage(immer::map<std::string, EventList> timelineEvents, immer::map<std::string, EventList> relatedEvents) const;
+
private:
void syncForever(std::optional<int> retryTime = std::nullopt) const;
diff --git a/src/client/client.cpp b/src/client/client.cpp
--- a/src/client/client.cpp
+++ b/src/client/client.cpp
@@ -505,4 +505,12 @@
{
return m_ctx.dispatch(PurgeRoomTimelineAction{roomIdToMaxToKeepMap});
}
+
+ auto Client::loadEventsFromStorage(immer::map<std::string, EventList> timelineEvents, immer::map<std::string, EventList> relatedEvents) const -> PromiseT
+ {
+ return m_ctx.dispatch(LoadEventsFromStorageAction{
+ std::move(timelineEvents),
+ std::move(relatedEvents),
+ });
+ }
}
diff --git a/src/tests/client/storage-actions-test.cpp b/src/tests/client/storage-actions-test.cpp
--- a/src/tests/client/storage-actions-test.cpp
+++ b/src/tests/client/storage-actions-test.cpp
@@ -5,6 +5,7 @@
*/
#include <libkazv-config.hpp>
+#include "action-mock-utils.hpp"
#include "actions/storage.hpp"
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_quantifiers.hpp>
@@ -85,6 +86,24 @@
}
}
+TEST_CASE("Client::loadEventsFromStorage()", "[client][storage-actions]")
+{
+ auto c = makeClient(withRoom(makeRoom(withRoomId(roomId))));
+ auto u = makeMockSdkUtil(c);
+ auto d = u.getMockDispatcher(passDown<LoadEventsFromStorageAction>());
+ auto client = u.getClient(d);
+ auto events = EventList{makeEvent(), makeEvent()};
+ client.loadEventsFromStorage({{roomId, events}}, {}).then([&u](const auto &stat) {
+ REQUIRE(stat);
+ u.io.stop();
+ });
+ u.io.run();
+ auto room = client.room(roomId);
+ REQUIRE(room.timelineEventIds().get().size() == events.size());
+ REQUIRE(room.messagesMap().get().size() == events.size());
+ REQUIRE(d.calledTimes<LoadEventsFromStorageAction>() == 1);
+}
+
TEST_CASE("maybeAddSaveEventsTrigger", "[client][storage-actions]")
{
WHEN("compare with self") {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 19, 6:33 AM (14 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
797923
Default Alt Text
D255.1766154800.diff (2 KB)
Attached To
Mode
D255: Add Client::loadEventsFromStorage function
Attached
Detach File
Event Timeline
Log In to Comment