multiple deep comment display done, with minimum support, not all cases covered

This commit is contained in:
vishalxl
2022-07-31 20:55:27 +05:30
parent 8bb9e66efe
commit dde172030e
2 changed files with 34 additions and 14 deletions

View File

@@ -22,7 +22,7 @@ Future<void> main() async {
var e = events[i]; var e = events[i];
if( e.eventData.kind == 3) { if( e.eventData.kind == 3) {
print('calling getfeed'); print('calling getfeed');
getFeed(e.eventData.contactList, events, 5); getFeed(e.eventData.contactList, events, 10);
} }
} }

View File

@@ -109,7 +109,7 @@ class EventData {
printDepth(depth); printDepth(depth);
stdout.write("|Author : ${max3(pubkey)}\n"); stdout.write("|Author : ${max3(pubkey)}\n");
printDepth(depth); printDepth(depth);
stdout.write("|"); stdout.write("|\n");
printDepth(depth); printDepth(depth);
stdout.write("|id : ${max3(id)} Time: $dTime"); stdout.write("|id : ${max3(id)} Time: $dTime");
//stdout.write("\n$eTagsRest\n"); //stdout.write("\n$eTagsRest\n");
@@ -200,29 +200,49 @@ class Tree {
// add each of nonTopEvents to their parent tree ( if parent is found in tree) // add each of nonTopEvents to their parent tree ( if parent is found in tree)
for(int i = 0; i < nonTopEvents.length; i++) { for(int i = 0; i < nonTopEvents.length; i++) {
Event e = nonTopEvents[i]; Event e = nonTopEvents[i];
insertEvent( childTrees, e); insertIntoTrees( childTrees, e);
// String parentId = e.eventData.tags // String parentId = e.eventData.tags
} }
stdout.write("Ending: factory fromEvents list. number of events: ${events.length}\n"); stdout.write("Ending: factory fromEvents list. number of events: ${events.length}\n");
return Tree( events[0], childTrees); // TODO remove events[0] return Tree( events[0], childTrees); // TODO remove events[0]
} }
// @function insertIntoTree will insert the event e into the given tree if
// any of the events in the tree is a parent of this event
static bool insertIntoTree( Tree tree, Event e) {
bool inserted = false;
String parent = e.eventData.eTagParent;
if( parent == "") {
parent = e.eventData.eTagsRest.last;
}
if( tree.e.eventData.id == parent) {
//stdout.write("In isertEvent: found parent for event $e \n");
tree.addChild(e);
return true;
} else {
for(int i = 0; i < tree.children.length; i++) {
Tree child = tree.children[i];
if( insertIntoTree(child, e)) {
return true;
}
}
}
return false;
}
// @function insertEvent will insert the event e into the given list of trees if its // @function insertEvent will insert the event e into the given list of trees if its
// parent is in that list of trees // parent is in that list of trees
static void insertEvent( List<Tree> trees, Event e) { static void insertIntoTrees( List<Tree> trees, Event e) {
for( int i = 0; i < trees.length; i++) { for( int i = 0; i < trees.length; i++) {
Tree tree = trees[i]; Tree tree = trees[i];
//stdout.write("In isertEvent: processing event $e \n"); //stdout.write("In isertEvent: processing event $e \n");
String parent = e.eventData.eTagParent; if( insertIntoTree(tree, e) == true) {
if( parent == "") { return;
parent = e.eventData.eTagsRest[0];
}
if( tree.e.eventData.id == parent) {
//stdout.write("In isertEvent: found parent for event $e \n");
tree.addChild(e);
} }
} }
return; return;
@@ -234,7 +254,7 @@ class Tree {
children.add(node); children.add(node);
} }
addChildNode(Tree node) { void addChildNode(Tree node) {
children.add(node); children.add(node);
} }