mirror of
https://github.com/tutao/tutanota.git
synced 2025-12-08 06:09:50 +00:00
Fix initializing cache with batch ids for the first time
For each group we record the last batch we processed so that we can download events since that batch and update the cache. Unfortunately we would only write those ids when some events are processed. In case there are no events we would not download any batches on next login. This fixes plugs the issue with this case by preemptively writing last id if none could be loaded. Next time we will download batches starting with that id.
This commit is contained in:
parent
b2a01f5164
commit
d572734d87
4 changed files with 24 additions and 4 deletions
|
|
@ -44,6 +44,13 @@ export interface IEntityRestCache extends EntityRestInterface {
|
|||
*/
|
||||
getLastEntityEventBatchForGroup(groupId: Id): Promise<Id | null>;
|
||||
|
||||
/**
|
||||
* Saved tha batch id of the most recently processed batch manually.
|
||||
*
|
||||
* Is needed when the cache is new but we want to make sure that the next time we will download from this moment, even if we don't receive any events.
|
||||
*/
|
||||
setLastEntityEventBatchForGroup(groupId: Id, batchId: Id): Promise<void>;
|
||||
|
||||
/**
|
||||
* Persist the last time client downloaded event batches. This is not the last *processed* item, merely when things were *downloaded*. We use it to
|
||||
* detect out-of-sync.
|
||||
|
|
@ -198,6 +205,10 @@ export class EntityRestCache implements IEntityRestCache {
|
|||
return this.storage.getLastBatchIdForGroup(groupId)
|
||||
}
|
||||
|
||||
setLastEntityEventBatchForGroup(groupId: Id, batchId: Id): Promise<void> {
|
||||
return this.storage.putLastBatchIdForGroup(groupId, batchId)
|
||||
}
|
||||
|
||||
purgeStorage(): Promise<void> {
|
||||
return this.storage.purgeStorage()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue