mirror of
https://github.com/BlowaterNostr/blowater.git
synced 2024-10-18 07:33:22 +00:00
correct database new data streaming (#419)
This commit is contained in:
parent
9d2901fe39
commit
1bc41d6852
@ -102,7 +102,6 @@ Deno.test("Relay Record", async () => {
|
||||
),
|
||||
);
|
||||
|
||||
await stream.pop();
|
||||
await stream.pop();
|
||||
await stream.pop();
|
||||
|
||||
|
@ -214,8 +214,9 @@ export class Database_View
|
||||
return false;
|
||||
}
|
||||
|
||||
let new_relay_record = false;
|
||||
if (url) {
|
||||
await this.recordRelay(event.id, url);
|
||||
new_relay_record = await this.recordRelay(event.id, url);
|
||||
}
|
||||
|
||||
// parse the event to desired format
|
||||
@ -233,7 +234,7 @@ export class Database_View
|
||||
// check if the event exists
|
||||
const storedEvent = await this.eventsAdapter.get({ id: event.id });
|
||||
if (storedEvent) { // event exist
|
||||
if (url) {
|
||||
if (new_relay_record) {
|
||||
this.sourceOfChange.put({ event: parsedEvent, relay: url });
|
||||
}
|
||||
return false;
|
||||
@ -281,13 +282,16 @@ export class Database_View
|
||||
}
|
||||
|
||||
private async recordRelay(eventID: string, url: string) {
|
||||
await this.relayRecorder.setRelayRecord(eventID, url);
|
||||
const records = this.relayRecords.get(eventID);
|
||||
if (records) {
|
||||
const size = records.size;
|
||||
records.add(url);
|
||||
return records.size > size;
|
||||
} else {
|
||||
this.relayRecords.set(eventID, new Set([url]));
|
||||
return true;
|
||||
}
|
||||
await this.relayRecorder.setRelayRecord(eventID, url);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user