diff --git a/lib/console_ui.dart b/lib/console_ui.dart index 5af6baf..ff4e947 100644 --- a/lib/console_ui.dart +++ b/lib/console_ui.dart @@ -498,7 +498,8 @@ Future otherOptionsMenuUi(Store node) async { String newId = "", newPubkey = userPublicKey, newContent = ""; int newKind = 3; - List newEtags = [], newPtags = [pk]; + List> newEtags = []; + List newPtags = [pk]; List> newTags = [[]]; Set newNewLikes = {}; int newCreatedAt = DateTime.now().millisecondsSinceEpoch ~/ 1000; @@ -517,7 +518,7 @@ Future otherOptionsMenuUi(Store node) async { case 6: //edit your profile print("Your current name: ${getAuthorName(userPublicKey)}"); 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 userAbout = getStringFromUser("Enter new 'about me' for yourself: "); @@ -530,8 +531,6 @@ Future otherOptionsMenuUi(Store node) async { String userKind0EventId = await sendEvent(node, userKind0Event); // takes 400 ms printInColor("Updated your profile.\n", gCommentColor); await processAnyIncomingEvents(node, false); // get latest event, this takes 300 ms - - break; case 7: // change number of days printed diff --git a/lib/event_ds.dart b/lib/event_ds.dart index a4050a3..59d53a6 100644 --- a/lib/event_ds.dart +++ b/lib/event_ds.dart @@ -110,7 +110,7 @@ class EventData { int createdAt; int kind; String content; - List eTags;// e tags + List> eTags;// e tags List pTags;// list of p tags for kind:1 List> tags; bool isNotification; // whether its to be highlighted using highlight color @@ -121,12 +121,22 @@ class EventData { 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 - + + + 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 String getParent(Map allEventsMap) { + if( eTags.isNotEmpty) { + 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) { String? parentId = allEventsMap[eventId]?.event.eventData.id; if( parentId != null) { @@ -138,23 +148,18 @@ class EventData { return eventId; } } + } 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) { List contactList = []; - List eTagsRead = []; - List pTagsRead = []; + List> eTagsRead = []; + List pTagsRead = []; List> tagsRead = []; var jsonTags = json['tags']; @@ -211,7 +216,11 @@ class EventData { continue; } if( tag[0] == "e") { - eTagsRead.add(tag[1]); + List listTag = []; + for(int i = 1; i < tag.length; i ++) { + listTag.add(tag[i]); + } + eTagsRead.add(listTag); } else { if( tag[0] == "p") { pTagsRead.add(tag[1]); diff --git a/lib/tree_ds.dart b/lib/tree_ds.dart index a6c6051..aafbb30 100644 --- a/lib/tree_ds.dart +++ b/lib/tree_ds.dart @@ -1200,7 +1200,7 @@ class Store { if(gDebug > 0) ("Got notification of type 7"); String reactorId = event.eventData.pubkey; 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; if( reactedToEvent != null) { Tree? reactedToTree = allChildEventsMap[reactedTo]; @@ -1962,7 +1962,7 @@ class Store { String reactorId = event.eventData.id; String comment = event.eventData.content; 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");