added eTags in EventData as List of List

for root/reply change in getParent
This commit is contained in:
Vishal 2022-11-11 12:57:08 +05:30
parent cb2b34f947
commit 23dc5883ca
3 changed files with 26 additions and 18 deletions

View File

@ -498,7 +498,8 @@ Future<void> otherOptionsMenuUi(Store node) async {
String newId = "", newPubkey = userPublicKey, newContent = "";
int newKind = 3;
List<String> newEtags = [], newPtags = [pk];
List<List<String>> newEtags = [];
List<String> newPtags = [pk];
List<List<String>> newTags = [[]];
Set<String> newNewLikes = {};
int newCreatedAt = DateTime.now().millisecondsSinceEpoch ~/ 1000;
@ -517,7 +518,7 @@ Future<void> 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<void> 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

View File

@ -110,7 +110,7 @@ class EventData {
int createdAt;
int kind;
String content;
List<String> eTags;// e tags
List<List<String>> eTags;// e tags
List<String> pTags;// list of p tags for kind:1
List<List<String>> 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<String, Tree> 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<Contact> contactList = [];
List<String> eTagsRead = [];
List<String> pTagsRead = [];
List<List<String>> eTagsRead = [];
List<String> pTagsRead = [];
List<List<String>> tagsRead = [];
var jsonTags = json['tags'];
@ -211,7 +216,11 @@ class EventData {
continue;
}
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 {
if( tag[0] == "p") {
pTagsRead.add(tag[1]);

View File

@ -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");