mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-03-27 02:01:51 +01:00
handled reactions properly
and fixed issue with wrong logic with kind 3 ( where kind 0 was overwriting info about kind 3)
This commit is contained in:
parent
d935cb24e4
commit
04e83323e5
@ -34,8 +34,8 @@ class UserNameInfo {
|
||||
int? createdAtKind3;
|
||||
Event ?latestContactEvent;
|
||||
bool nip05Verified;
|
||||
String nip05Id;
|
||||
UserNameInfo(this.createdAt, this.name, this.about, this.picture, this.latestContactEvent, [this.createdAtKind3 = null, this.nip05Verified = false, this.nip05Id = ""]);
|
||||
String? nip05Id;
|
||||
UserNameInfo(this.createdAt, this.name, this.about, this.picture, this.nip05Id , this.latestContactEvent, [this.createdAtKind3 = null, this.nip05Verified = false]);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1109,12 +1109,12 @@ bool processKind0Event(Event e) {
|
||||
|
||||
bool newEntry = false, entryModified = false;
|
||||
if( !gKindONames.containsKey(e.eventData.pubkey)) {
|
||||
gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, e);
|
||||
gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, nip05, null);
|
||||
newEntry = true;;
|
||||
} else {
|
||||
int oldTime = gKindONames[e.eventData.pubkey]?.createdAt??0;
|
||||
if( oldTime < e.eventData.createdAt) {
|
||||
gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, e);
|
||||
gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, nip05, null);
|
||||
entryModified = true;
|
||||
}
|
||||
}
|
||||
@ -1150,7 +1150,7 @@ bool processKind0Event(Event e) {
|
||||
int oldTime = 0;
|
||||
if( !gKindONames.containsKey(e.eventData.pubkey)) {
|
||||
//printWarning("in response handing. creating user info");
|
||||
gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, e);
|
||||
gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, null, null);
|
||||
} else {
|
||||
oldTime = gKindONames[e.eventData.pubkey]?.createdAt??0;
|
||||
//print("in response handing. user info exists with old time = $oldTime and this event time = ${e.eventData.createdAt}");
|
||||
@ -1186,16 +1186,19 @@ bool processKind3Event(Event newContactEvent) {
|
||||
|
||||
bool newEntry = false, entryModified = false;
|
||||
if( !gKindONames.containsKey(newContactEvent.eventData.pubkey)) {
|
||||
gKindONames[newContactEvent.eventData.pubkey] = UserNameInfo(null, null, null, null, newContactEvent, newContactEvent.eventData.createdAt);
|
||||
gKindONames[newContactEvent.eventData.pubkey] = UserNameInfo(null, null, null, null, null, newContactEvent, newContactEvent.eventData.createdAt);
|
||||
newEntry = true;;
|
||||
} else {
|
||||
// if entry already exists, then check its old time and update only if we have a newer entry now
|
||||
int oldTime = gKindONames[newContactEvent.eventData.pubkey]?.createdAtKind3??0;
|
||||
if( oldTime < newContactEvent.eventData.createdAt) {
|
||||
int? createdAt = gKindONames[newContactEvent.eventData.pubkey]?.createdAt??null;
|
||||
String? name = gKindONames[newContactEvent.eventData.pubkey]?.name, about = gKindONames[newContactEvent.eventData.pubkey]?.about, picture = gKindONames[newContactEvent.eventData.pubkey]?.picture;
|
||||
String? name = gKindONames[newContactEvent.eventData.pubkey]?.name,
|
||||
about = gKindONames[newContactEvent.eventData.pubkey]?.about,
|
||||
picture = gKindONames[newContactEvent.eventData.pubkey]?.picture,
|
||||
nip05id = gKindONames[newContactEvent.eventData.pubkey]?.nip05Id??"";
|
||||
|
||||
gKindONames[newContactEvent.eventData.pubkey] = UserNameInfo(createdAt, name, about, picture, newContactEvent, newContactEvent.eventData.createdAt );
|
||||
gKindONames[newContactEvent.eventData.pubkey] = UserNameInfo(createdAt, name, about, picture, nip05id, newContactEvent, newContactEvent.eventData.createdAt );
|
||||
entryModified = true;;
|
||||
}
|
||||
}
|
||||
|
@ -413,6 +413,10 @@ class Tree {
|
||||
printDepth(depth+1);
|
||||
stdout.write(" ┌${getNumDashes((leftShiftThreadsBy + 1) * gSpacesPerDepth - 1, "─")}┘\n");
|
||||
leftShifted = true;
|
||||
|
||||
if(false && event.eventData.id == "471bb00f66212a594c1e875f708d01fc6aa4ed83d638c928d25e37dee28f8605")
|
||||
print('left shifting for event id: ${event.eventData.id} i = $i child = ${children[i].event.eventData.id} child kind = ${children[i].event.eventData.kind}');
|
||||
|
||||
}
|
||||
|
||||
numPrinted += children[i].printTree(depth+1, newerThan, false);
|
||||
@ -1022,7 +1026,7 @@ class Store {
|
||||
}
|
||||
|
||||
if( eKind == 4) {
|
||||
totoalDirectMessages += handleDirectMessage(tempDirectRooms, tempChildEventsMap, tree.event);
|
||||
handleDirectMessage(tempDirectRooms, tempChildEventsMap, tree.event);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1032,6 +1036,11 @@ class Store {
|
||||
return;
|
||||
}
|
||||
|
||||
if( eKind == 7) {
|
||||
processReaction(tree.event, tempChildEventsMap);
|
||||
return;
|
||||
}
|
||||
|
||||
// if reacted to event is not in store, then add it to dummy list so it can be fetched
|
||||
try {
|
||||
if( tree.event.eventData.eTags.length > 0) {
|
||||
@ -1056,6 +1065,8 @@ class Store {
|
||||
// find its parent and then add this element to that parent Tree
|
||||
String parentId = tree.event.eventData.getParent(tempChildEventsMap);
|
||||
|
||||
if( false && parentId == "471bb00f66212a594c1e875f708d01fc6aa4ed83d638c928d25e37dee28f8605") print("Found child of 471bb00f66212a594c1e875f708d01fc6aa4ed83d638c928d25e37dee28f8605 id = ${tree.event.eventData.id}");
|
||||
|
||||
if( parentId != "") {
|
||||
|
||||
if( tree.event.eventData.id == gCheckEventId) {
|
||||
@ -1142,7 +1153,7 @@ class Store {
|
||||
// for pubkeys that don't have any kind 0 events ( but have other evnets), add then to global kind0 store so they can still be accessed
|
||||
tempChildEventsMap.forEach((key, value) {
|
||||
if( !gKindONames.containsKey(value.event.eventData.pubkey)) {
|
||||
gKindONames[value.event.eventData.pubkey] = UserNameInfo(null, null, null, null, null );
|
||||
gKindONames[value.event.eventData.pubkey] = UserNameInfo(null, null, null, null, null, null );
|
||||
}
|
||||
});
|
||||
|
||||
@ -1276,6 +1287,7 @@ class Store {
|
||||
case 1:
|
||||
// only kind 1 events are added to the overall tree structure
|
||||
String parentId = newTree.event.eventData.getParent(allChildEventsMap);
|
||||
if( parentId == "471bb00f66212a594c1e875f708d01fc6aa4ed83d638c928d25e37dee28f8605") print("Found child of 471bb00f66212a594c1e875f708d01fc6aa4ed83d638c928d25e37dee28f8605 id = ${newTree.event.eventData.id}");
|
||||
if( parentId == "") {
|
||||
// if its a new parent event, then add it to the main top parents
|
||||
topPosts.add(newTree);
|
||||
|
Loading…
x
Reference in New Issue
Block a user