a bunch of cache logic fixes and futher support for reconnect on android #431

Merged
sarah merged 3 commits from cachefixes into trunk 2022-04-20 18:16:47 +00:00
Owner
needs https://git.openprivacy.ca/cwtch.im/libcwtch-go/pulls/85
dan changed title from WIP a bunch of cache logic fixes and futher support for reconnect on android to a bunch of cache logic fixes and futher support for reconnect on android 2022-04-20 00:43:07 +00:00
Member
Drone Build Status: success https://build.openprivacy.ca/cwtch.im/cwtch-ui/706
sarah reviewed 2022-04-20 02:19:02 +00:00
@ -97,0 +101,4 @@
// if we find the last seen ID, the diff of unread count is what's unsynced
for(var i = 0; i < (count+1) && i < cacheByIndex.length; i++) {
if (this.cacheByIndex[i].messageId == lastSeenId) {
// we have
Owner

we have....

we have....
dan marked this conversation as resolved
@ -124,6 +149,9 @@ class MessageCache extends ChangeNotifier {
void lockIndexes(int start, int end) {
for (var i = start; i < end; i++) {
this.cacheByIndex.insert(i, LocalIndexMessage(null, isLoading: true));
if (this._indexUnsynced > 0) {
Owner

document why this is here

document why this is here
dan marked this conversation as resolved
@ -177,6 +177,13 @@ class ProfileInfoState extends ChangeNotifier {
profileContact.status = contact["status"];
profileContact.totalMessages = contact["numMessages"];
profileContact.unreadMessages = contact["numUnread"];
// we only count up to 100 unread messages, if more than that we can't accuratly resync message cache, just reset
Owner

accurately

accurately
Owner

also..where do we document the 100 unread messages limitation?

also..where do we document the `100` unread messages limitation?
Author
Owner
https://git.openprivacy.ca/cwtch.im/libcwtch-go/src/branch/trunk/utils/eventHandler.go#L210
Author
Owner

added more comments, named consts

added more comments, named consts
dan marked this conversation as resolved
@ -178,2 +178,4 @@
profileContact.totalMessages = contact["numMessages"];
profileContact.unreadMessages = contact["numUnread"];
// we only count up to 100 unread messages, if more than that we can't accuratly resync message cache, just reset
if (contact["numUnread"] > 100 || (contact["numUnread"] > 0 && contact["lastSeenMessageId"] == -1)) {
Owner

>= 100 ?

`>= 100` ?
Author
Owner

100 should be ok, it's fetch
this is just a work saver, if it passes through and ultimatly fails to find a lastSeenIdMatch it'll also reset

100 should be ok, it's fetch this is just a work saver, if it passes through and ultimatly fails to find a lastSeenIdMatch it'll also reset
dan marked this conversation as resolved
@ -180,0 +181,4 @@
if (contact["numUnread"] > 100 || (contact["numUnread"] > 0 && contact["lastSeenMessageId"] == -1)) {
profileContact.messageCache.resetIndexCache();
} else if (contact["numUnread"] > 0) {
print("contact ${contact["name"]} with unread ${contact["numUnread"]} so addFrontIndexGap");
Owner

DebugLog

DebugLog
Author
Owner

ah deleted, left over debug code

ah deleted, left over debug code
dan marked this conversation as resolved
dan force-pushed cachefixes from d85b168c72 to 4bd92d854f 2022-04-20 03:47:12 +00:00 Compare
Member
Drone Build Status: success https://build.openprivacy.ca/cwtch.im/cwtch-ui/709
sarah approved these changes 2022-04-20 18:16:43 +00:00
sarah merged commit e0bf47b6ab into trunk 2022-04-20 18:16:47 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cwtch.im/cwtch-ui#431
No description provided.