mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-06-20 05:40:53 +02:00
added eTags in EventData as List of List
for root/reply change in getParent
This commit is contained in:
parent
cb2b34f947
commit
23dc5883ca
@ -498,7 +498,8 @@ Future<void> otherOptionsMenuUi(Store node) async {
|
|||||||
|
|
||||||
String newId = "", newPubkey = userPublicKey, newContent = "";
|
String newId = "", newPubkey = userPublicKey, newContent = "";
|
||||||
int newKind = 3;
|
int newKind = 3;
|
||||||
List<String> newEtags = [], newPtags = [pk];
|
List<List<String>> newEtags = [];
|
||||||
|
List<String> newPtags = [pk];
|
||||||
List<List<String>> newTags = [[]];
|
List<List<String>> newTags = [[]];
|
||||||
Set<String> newNewLikes = {};
|
Set<String> newNewLikes = {};
|
||||||
int newCreatedAt = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
int newCreatedAt = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||||
@ -517,7 +518,7 @@ Future<void> otherOptionsMenuUi(Store node) async {
|
|||||||
case 6: //edit your profile
|
case 6: //edit your profile
|
||||||
print("Your current name: ${getAuthorName(userPublicKey)}");
|
print("Your current name: ${getAuthorName(userPublicKey)}");
|
||||||
print("Your about me: ${gKindONames[userPublicKey]?.about}");
|
print("Your about me: ${gKindONames[userPublicKey]?.about}");
|
||||||
print("Your current profile picture: ${gKindONames[userPublicKey]?.picture}");
|
print("Your current profile picture: ${gKindONames[userPublicKey]?.picture}\n");
|
||||||
|
|
||||||
String userName = getStringFromUser("Enter your new display name: ");
|
String userName = getStringFromUser("Enter your new display name: ");
|
||||||
String userAbout = getStringFromUser("Enter new 'about me' for yourself: ");
|
String userAbout = getStringFromUser("Enter new 'about me' for yourself: ");
|
||||||
@ -530,8 +531,6 @@ Future<void> otherOptionsMenuUi(Store node) async {
|
|||||||
String userKind0EventId = await sendEvent(node, userKind0Event); // takes 400 ms
|
String userKind0EventId = await sendEvent(node, userKind0Event); // takes 400 ms
|
||||||
printInColor("Updated your profile.\n", gCommentColor);
|
printInColor("Updated your profile.\n", gCommentColor);
|
||||||
await processAnyIncomingEvents(node, false); // get latest event, this takes 300 ms
|
await processAnyIncomingEvents(node, false); // get latest event, this takes 300 ms
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7: // change number of days printed
|
case 7: // change number of days printed
|
||||||
|
@ -110,7 +110,7 @@ class EventData {
|
|||||||
int createdAt;
|
int createdAt;
|
||||||
int kind;
|
int kind;
|
||||||
String content;
|
String content;
|
||||||
List<String> eTags;// e tags
|
List<List<String>> eTags;// e tags
|
||||||
List<String> pTags;// list of p tags for kind:1
|
List<String> pTags;// list of p tags for kind:1
|
||||||
List<List<String>> tags;
|
List<List<String>> tags;
|
||||||
bool isNotification; // whether its to be highlighted using highlight color
|
bool isNotification; // whether its to be highlighted using highlight color
|
||||||
@ -122,11 +122,21 @@ class EventData {
|
|||||||
bool isHidden; // hidden by sending a reaction kind 7 event to this event, by the logged in user
|
bool isHidden; // hidden by sending a reaction kind 7 event to this event, by the logged in user
|
||||||
bool isDeleted; // deleted by kind 5 event
|
bool isDeleted; // deleted by kind 5 event
|
||||||
|
|
||||||
|
|
||||||
|
EventData(this.id, this.pubkey, this.createdAt, this.kind, this.content,
|
||||||
|
this.eTags, this.pTags, this.contactList,this.tags, this.newLikes,
|
||||||
|
{
|
||||||
|
this.isNotification = false, this.evaluatedContent = "", this.isHidden = false, this.isDeleted = false
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// returns the immediate kind 1 parent
|
// returns the immediate kind 1 parent
|
||||||
String getParent(Map<String, Tree> allEventsMap) {
|
String getParent(Map<String, Tree> allEventsMap) {
|
||||||
|
|
||||||
if( eTags.isNotEmpty) {
|
if( eTags.isNotEmpty) {
|
||||||
|
|
||||||
for( int i = eTags.length - 1; i >= 0; i--) {
|
for( int i = eTags.length - 1; i >= 0; i--) {
|
||||||
String eventId = eTags[i];
|
String eventId = eTags[i][0];
|
||||||
if( allEventsMap[eventId]?.event.eventData.kind == 1) {
|
if( allEventsMap[eventId]?.event.eventData.kind == 1) {
|
||||||
String? parentId = allEventsMap[eventId]?.event.eventData.id;
|
String? parentId = allEventsMap[eventId]?.event.eventData.id;
|
||||||
if( parentId != null) {
|
if( parentId != null) {
|
||||||
@ -138,22 +148,17 @@ class EventData {
|
|||||||
return eventId;
|
return eventId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EventData(this.id, this.pubkey, this.createdAt, this.kind, this.content,
|
|
||||||
this.eTags, this.pTags, this.contactList,this.tags, this.newLikes,
|
|
||||||
{
|
|
||||||
this.isNotification = false, this.evaluatedContent = "", this.isHidden = false, this.isDeleted = false
|
|
||||||
});
|
|
||||||
|
|
||||||
factory EventData.fromJson(dynamic json) {
|
factory EventData.fromJson(dynamic json) {
|
||||||
|
|
||||||
List<Contact> contactList = [];
|
List<Contact> contactList = [];
|
||||||
|
|
||||||
List<String> eTagsRead = [];
|
List<List<String>> eTagsRead = [];
|
||||||
List<String> pTagsRead = [];
|
List<String> pTagsRead = [];
|
||||||
List<List<String>> tagsRead = [];
|
List<List<String>> tagsRead = [];
|
||||||
|
|
||||||
@ -211,7 +216,11 @@ class EventData {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if( tag[0] == "e") {
|
if( tag[0] == "e") {
|
||||||
eTagsRead.add(tag[1]);
|
List<String> listTag = [];
|
||||||
|
for(int i = 1; i < tag.length; i ++) {
|
||||||
|
listTag.add(tag[i]);
|
||||||
|
}
|
||||||
|
eTagsRead.add(listTag);
|
||||||
} else {
|
} else {
|
||||||
if( tag[0] == "p") {
|
if( tag[0] == "p") {
|
||||||
pTagsRead.add(tag[1]);
|
pTagsRead.add(tag[1]);
|
||||||
|
@ -1200,7 +1200,7 @@ class Store {
|
|||||||
if(gDebug > 0) ("Got notification of type 7");
|
if(gDebug > 0) ("Got notification of type 7");
|
||||||
String reactorId = event.eventData.pubkey;
|
String reactorId = event.eventData.pubkey;
|
||||||
int lastEIndex = event.eventData.eTags.length - 1;
|
int lastEIndex = event.eventData.eTags.length - 1;
|
||||||
String reactedTo = event.eventData.eTags[lastEIndex];
|
String reactedTo = event.eventData.eTags[lastEIndex][0];
|
||||||
Event? reactedToEvent = allChildEventsMap[reactedTo]?.event;
|
Event? reactedToEvent = allChildEventsMap[reactedTo]?.event;
|
||||||
if( reactedToEvent != null) {
|
if( reactedToEvent != null) {
|
||||||
Tree? reactedToTree = allChildEventsMap[reactedTo];
|
Tree? reactedToTree = allChildEventsMap[reactedTo];
|
||||||
@ -1962,7 +1962,7 @@ class Store {
|
|||||||
String reactorId = event.eventData.id;
|
String reactorId = event.eventData.id;
|
||||||
String comment = event.eventData.content;
|
String comment = event.eventData.content;
|
||||||
int lastEIndex = event.eventData.eTags.length - 1;
|
int lastEIndex = event.eventData.eTags.length - 1;
|
||||||
String reactedToId = event.eventData.eTags[lastEIndex];
|
String reactedToId = event.eventData.eTags[lastEIndex][0];
|
||||||
|
|
||||||
if( gDebug > 0 && event.eventData.id == gCheckEventId)print("in processReaction: 1 got reaction $gCheckEventId");
|
if( gDebug > 0 && event.eventData.id == gCheckEventId)print("in processReaction: 1 got reaction $gCheckEventId");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user