Various improvements #169
2 changed files with 6 additions and 2 deletions
Don't download all documents when initial sync gets interrupted
commit
159c4704de
|
|
@ -75,6 +75,10 @@ export class Database {
|
||||||
Math.max(0, lastSeenUpdateId ?? 0) // the first updateId will be 1 which is the first integer after -1
|
Math.max(0, lastSeenUpdateId ?? 0) // the first updateId will be 1 which is the first integer after -1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.documents.forEach((doc) =>
|
||||||
|
this.lastSeenUpdateIds.add(doc.metadata?.parentVersionId)
|
||||||
|
);
|
||||||
|
|
||||||
this.hasInitialSyncCompleted =
|
this.hasInitialSyncCompleted =
|
||||||
initialState.hasInitialSyncCompleted ?? false;
|
initialState.hasInitialSyncCompleted ?? false;
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ export class CoveredValues {
|
||||||
this.advanceMinWhilePossible();
|
this.advanceMinWhilePossible();
|
||||||
|
|
|||||||
}
|
}
|
||||||
|
Filtering the entire seenValues array on every min update could be inefficient for large arrays. Since seenValues is sorted, consider using binary search to find the first value > this.minValue and slicing from that index instead of filtering. Filtering the entire seenValues array on every min update could be inefficient for large arrays. Since seenValues is sorted, consider using binary search to find the first value > this.minValue and slicing from that index instead of filtering.
|
|||||||
|
|
||||||
public add(value: number): void {
|
public add(value: number | undefined): void {
|
||||||
if (value < this.minValue) {
|
if (value === undefined || value < this.minValue) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue
The filter should compare against
value(the input parameter) rather thanthis.minValuesincethis.minValueis updated on line 26 and may not reflect the original intent. If the goal is to filter values greater than the new minimum, this is correct but unclear.