From b11ae7add71f92d540fffec9ef97bc224ef01825 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 30 Apr 2023 10:59:27 +0200 Subject: Update cache version because cache is corrupt (missing messages) --- src/plugins/Matrix.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index b0af624..41dea9f 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -1691,7 +1691,8 @@ namespace QuickMedia { return; } - const bool cache_updated = get_file_type(get_cache_dir().join("matrix").join("updated-cache-version1")) == FileType::REGULAR; + const char *update_cache_file_name = "updated-cache-version2"; + const bool cache_updated = get_file_type(get_cache_dir().join("matrix").join(update_cache_file_name)) == FileType::REGULAR; bool overwrite_cache = !cache_updated; std::ifstream sync_cache_file_stream; sync_cache_file_stream.open(matrix_cache_dir.data.c_str(), std::ifstream::in | std::ifstream::binary); @@ -1858,7 +1859,7 @@ namespace QuickMedia { json_data += '\n'; fwrite(json_data.data(), 1, json_data.size(), sync_cache_file); - file_overwrite(get_cache_dir().join("matrix").join("updated-cache-version1"), "1"); // To make sure the cache format is up to date + file_overwrite(get_cache_dir().join("matrix").join(update_cache_file_name), "1"); // To make sure the cache format is up to date malloc_trim(0); } fclose(sync_cache_file); @@ -2323,6 +2324,12 @@ namespace QuickMedia { has_unread_notifications = true; } + // TODO: timeline_json may contain "prev_batch", if so set it for the room. + // TODO: timeline_json may contain "limited" and if it's set to true then clear the messages in the room + // here so we only show the new messages. + // This will allow us to fetch older messages. But what if we do sync and we have limited messages + // but then receive a new sync and then restart quickmedia again and this time we dont have "limited" messages? + const rapidjson::Value &events_json = GetMember(timeline_json, "events"); events_add_user_info(events_json, room, 0); events_set_room_info(events_json, room, 0); -- cgit v1.2.3