document-drive 1.0.0-alpha.6 → 1.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-drive",
3
- "version": "1.0.0-alpha.6",
3
+ "version": "1.0.0-alpha.8",
4
4
  "license": "AGPL-3.0-only",
5
5
  "type": "module",
6
6
  "module": "./src/index.ts",
@@ -19,7 +19,12 @@ import {
19
19
  import { createNanoEvents, Unsubscribe } from 'nanoevents';
20
20
  import { MemoryStorage } from '../storage/memory';
21
21
  import type { DocumentStorage, IDriveStorage } from '../storage/types';
22
- import { generateUUID, isDocumentDrive, isNoopUpdate } from '../utils';
22
+ import {
23
+ generateUUID,
24
+ isBefore,
25
+ isDocumentDrive,
26
+ isNoopUpdate
27
+ } from '../utils';
23
28
  import { requestPublicDrive } from '../utils/graphql';
24
29
  import { OperationError } from './error';
25
30
  import { ListenerManager } from './listener/manager';
@@ -305,10 +310,10 @@ export class DocumentDriveServer extends BaseDocumentDriveServer {
305
310
  const filteredOperations = operations.filter(
306
311
  operation =>
307
312
  Object.keys(filter).length === 0 ||
308
- (filter.since !== undefined &&
309
- filter.since <= operation.timestamp) ||
310
- (filter.fromRevision !== undefined &&
311
- operation.index > filter.fromRevision)
313
+ ((filter.since === undefined ||
314
+ isBefore(filter.since, operation.timestamp)) &&
315
+ (filter.fromRevision === undefined ||
316
+ operation.index > filter.fromRevision))
312
317
  );
313
318
 
314
319
  return filteredOperations.map(operation => ({
@@ -208,6 +208,7 @@ export class PullResponderTransmitter implements IPullResponderTransmitter {
208
208
 
209
209
  // if there are no new strands then do nothing
210
210
  if (!strands.length) {
211
+ onRevisions?.([]);
211
212
  return;
212
213
  }
213
214
 
@@ -75,3 +75,8 @@ export function isNoopUpdate(
75
75
  isSkipOpGreaterThanLatestOp
76
76
  );
77
77
  }
78
+
79
+ // return true if dateA is before dateB
80
+ export function isBefore(dateA: Date | string, dateB: Date | string) {
81
+ return new Date(dateA) < new Date(dateB);
82
+ }