applesauce-core 0.0.0-next-20250211174631 → 0.0.0-next-20250212000029
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.
|
@@ -224,7 +224,9 @@ export class EventStore {
|
|
|
224
224
|
}
|
|
225
225
|
// subscribe to future events
|
|
226
226
|
const inserted = this.database.inserted.subscribe((event) => {
|
|
227
|
-
if (
|
|
227
|
+
if (isReplaceable(event.kind) &&
|
|
228
|
+
getEventUID(event) === uid &&
|
|
229
|
+
(!current || event.created_at > current.created_at)) {
|
|
228
230
|
// remove old claim
|
|
229
231
|
if (current)
|
|
230
232
|
this.database.removeClaim(current, observer);
|
package/dist/helpers/event.js
CHANGED
|
@@ -37,20 +37,20 @@ export function isReplaceable(kind) {
|
|
|
37
37
|
* For parametrized replaceable events this is ( event.kind + ":" + event.pubkey + ":" + event.tags.d.1 )
|
|
38
38
|
*/
|
|
39
39
|
export function getEventUID(event) {
|
|
40
|
-
let
|
|
41
|
-
if (!
|
|
40
|
+
let uid = event[EventUIDSymbol];
|
|
41
|
+
if (!uid) {
|
|
42
42
|
if (isReplaceable(event.kind)) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
id = event.id;
|
|
43
|
+
let d = event.tags.find((t) => t[0] === "d")?.[1];
|
|
44
|
+
uid = getReplaceableUID(event.kind, event.pubkey, d);
|
|
48
45
|
}
|
|
46
|
+
else
|
|
47
|
+
uid = event.id;
|
|
48
|
+
event[EventUIDSymbol] = uid;
|
|
49
49
|
}
|
|
50
|
-
return
|
|
50
|
+
return uid;
|
|
51
51
|
}
|
|
52
52
|
export function getReplaceableUID(kind, pubkey, d) {
|
|
53
|
-
return d ?
|
|
53
|
+
return d ? kind + ":" + pubkey + ":" + d : kind + ":" + pubkey;
|
|
54
54
|
}
|
|
55
55
|
/** Returns a Set of tag names and values that are indexable */
|
|
56
56
|
export function getIndexableTags(event) {
|
|
@@ -58,7 +58,7 @@ export function getIndexableTags(event) {
|
|
|
58
58
|
if (!indexable) {
|
|
59
59
|
const tags = new Set();
|
|
60
60
|
for (const tag of event.tags) {
|
|
61
|
-
if (tag[0] &&
|
|
61
|
+
if (tag[0] && tag[0].length >= 2 && INDEXABLE_TAGS.has(tag[0])) {
|
|
62
62
|
tags.add(tag[0] + ":" + tag[1]);
|
|
63
63
|
}
|
|
64
64
|
}
|
package/dist/helpers/filter.js
CHANGED
|
@@ -17,7 +17,8 @@ export function matchFilter(filter, event) {
|
|
|
17
17
|
for (let f in filter) {
|
|
18
18
|
if (f[0] === "#") {
|
|
19
19
|
let tagName = f.slice(1);
|
|
20
|
-
|
|
20
|
+
// @ts-expect-error
|
|
21
|
+
let values = filter[f];
|
|
21
22
|
if (values) {
|
|
22
23
|
const tags = getIndexableTags(event);
|
|
23
24
|
if (values.some((v) => tags.has(tagName + ":" + v)) === false)
|
package/dist/helpers/pointers.js
CHANGED
|
@@ -148,7 +148,7 @@ export function isEventPointer(pointer) {
|
|
|
148
148
|
}
|
|
149
149
|
/** Returns the coordinate string for an AddressPointer */
|
|
150
150
|
export function getCoordinateFromAddressPointer(pointer) {
|
|
151
|
-
return
|
|
151
|
+
return pointer.kind + ":" + pointer.pubkey + ":" + pointer.identifier;
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
154
|
* Returns an AddressPointer for a replaceable event
|