applesauce-loaders 6.0.0 → 6.1.0

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.
@@ -42,13 +42,18 @@ export function loadBackwardBlocks(request, opts) {
42
42
  loading = true;
43
43
  // Count returned events so complete set
44
44
  let count = 0;
45
+ let minCreatedAt;
46
+ const until = cursor;
45
47
  log?.(`Loading block since:${cursor}`);
46
48
  // Request the next block of events
47
- return request(cursor).pipe(tap((event) => {
49
+ return request(until).pipe(tap((event) => {
48
50
  count++;
49
- // Track the minimum created_at seen from the events
50
- cursor = Math.min(event.created_at, cursor ?? Infinity);
51
+ minCreatedAt = Math.min(event.created_at, minCreatedAt ?? Infinity);
51
52
  }), finalize(() => {
53
+ // NIP-01 defines `until` as inclusive. Move past the oldest event in
54
+ // the block so the next request does not repeat the boundary second.
55
+ if (minCreatedAt !== undefined)
56
+ cursor = minCreatedAt - 1;
52
57
  loading = false;
53
58
  complete = count === 0;
54
59
  log?.(`Found ${count} events`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-loaders",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "A collection of observable based loaders built on rx-nostr",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -52,7 +52,7 @@
52
52
  }
53
53
  },
54
54
  "dependencies": {
55
- "applesauce-core": "^6.0.0",
55
+ "applesauce-core": "^6.1.0",
56
56
  "nanoid": "^5.0.9",
57
57
  "rxjs": "^7.8.1"
58
58
  },