16
16
*/
17
17
18
18
import { User } from '../auth/user' ;
19
- import { DocumentKeySet } from '../model/collections' ;
19
+ import {
20
+ DocumentKeySet ,
21
+ DocumentKeyToMutationMap ,
22
+ DocumentKeyToOverlayMap ,
23
+ newDocumentKeyToOverlayMap
24
+ } from '../model/collections' ;
20
25
import { DocumentKey } from '../model/document_key' ;
21
- import { Mutation } from '../model/mutation' ;
22
26
import { Overlay } from '../model/overlay' ;
23
27
import { ResourcePath } from '../model/path' ;
24
28
@@ -74,10 +78,10 @@ export class IndexedDbDocumentOverlayCache implements DocumentOverlayCache {
74
78
saveOverlays (
75
79
transaction : PersistenceTransaction ,
76
80
largestBatchId : number ,
77
- overlays : Map < DocumentKey , Mutation >
81
+ overlays : DocumentKeyToMutationMap
78
82
) : PersistencePromise < void > {
79
83
const promises : Array < PersistencePromise < void > > = [ ] ;
80
- overlays . forEach ( mutation => {
84
+ overlays . forEach ( ( _ , mutation ) => {
81
85
const overlay = new Overlay ( largestBatchId , mutation ) ;
82
86
promises . push ( this . saveOverlay ( transaction , overlay ) ) ;
83
87
} ) ;
@@ -118,8 +122,8 @@ export class IndexedDbDocumentOverlayCache implements DocumentOverlayCache {
118
122
transaction : PersistenceTransaction ,
119
123
collection : ResourcePath ,
120
124
sinceBatchId : number
121
- ) : PersistencePromise < Map < DocumentKey , Overlay > > {
122
- const result = new Map < DocumentKey , Overlay > ( ) ;
125
+ ) : PersistencePromise < DocumentKeyToOverlayMap > {
126
+ const result = newDocumentKeyToOverlayMap ( ) ;
123
127
const collectionPath = encodeResourcePath ( collection ) ;
124
128
// We want batch IDs larger than `sinceBatchId`, and so the lower bound
125
129
// is not inclusive.
@@ -144,8 +148,8 @@ export class IndexedDbDocumentOverlayCache implements DocumentOverlayCache {
144
148
collectionGroup : string ,
145
149
sinceBatchId : number ,
146
150
count : number
147
- ) : PersistencePromise < Map < DocumentKey , Overlay > > {
148
- const result = new Map < DocumentKey , Overlay > ( ) ;
151
+ ) : PersistencePromise < DocumentKeyToOverlayMap > {
152
+ const result = newDocumentKeyToOverlayMap ( ) ;
149
153
let currentBatchId : number | undefined = undefined ;
150
154
// We want batch IDs larger than `sinceBatchId`, and so the lower bound
151
155
// is not inclusive.
@@ -167,7 +171,7 @@ export class IndexedDbDocumentOverlayCache implements DocumentOverlayCache {
167
171
// `count` if there are more overlays from the `currentBatchId`.
168
172
const overlay = fromDbDocumentOverlay ( this . serializer , dbOverlay ) ;
169
173
if (
170
- result . size < count ||
174
+ result . size ( ) < count ||
171
175
overlay . largestBatchId === currentBatchId
172
176
) {
173
177
result . set ( overlay . getKey ( ) , overlay ) ;
0 commit comments