HomePhabricator
Diffusion Comm 5e42adc1f6b7

[lib] Calculate currentAsOf for every keyserver in mergeNewMessages

Description

[lib] Calculate currentAsOf for every keyserver in mergeNewMessages

Summary:
issue: https://linear.app/comm/issue/ENG-5723/update-mergenewmessages-function
We need to calculate currentAsOf for every keyserver. Previously, we calculated max of orderedNewMessageInfos[0].time and updatedMessageStore.currentAsOf[keyserverID].
orderedNewMessageInfos are messages ordered by time, and the first element was the newest message. We take orderedNewMessageInfos and find the newest message for each keyserver with findNewestMessageTimePerKeyserver.
updatedMessageStore.currentAsOf is currently the same as processedMessageStore.currentAsOf - processedMessageStore is calculated from updatedMessageStore by applying ops with processMessageStoreOperations. But if in the future we added to ops something that changes currentAsOf, we would want to use that value. So this stays correct, and is easier to maintain

Test Plan:
Logged the created messageStore and checked that currentAsOf is a "map" from keyserverID to timestamp.
Checked that the value calculated is the timestamp of the newest message from that keyserver. Tested that if a new message arrives it gets updated correctly. Tested that if older messages are fetched the value doesn't change

Reviewers: michal, kamil, ginsu

Reviewed By: michal

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D9882

Details