mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-03-29 19:21:49 +01:00
fixed comparator which improves the display a lot
This commit is contained in:
parent
a656ad7fe8
commit
87b4ce846c
@ -91,7 +91,7 @@ Future<void> otherMenuUi(Tree node, var contactList) async {
|
||||
}
|
||||
|
||||
Future<void> mainMenuUi(Tree node, var contactList) async {
|
||||
gDebug = 1;
|
||||
//gDebug = 1;
|
||||
// at the very beginning, show the tree as it is the, and them show the options menu
|
||||
node.printTree(0, true, DateTime.now().subtract(Duration(days:gNumLastDays)));
|
||||
//gDebug = 1;
|
||||
@ -142,7 +142,7 @@ Future<void> mainMenuUi(Tree node, var contactList) async {
|
||||
print("Since no user private key has been supplied, posts/messages can't be sent. Invoke with --prikey \n");
|
||||
break;
|
||||
}
|
||||
stdout.write("Type comment to post/reply: ");
|
||||
stdout.write("Type comment to post/reply (type just '+' to send a like): ");
|
||||
String? $contentVar = stdin.readLineSync();
|
||||
String content = $contentVar??"";
|
||||
if( content == "") {
|
||||
|
@ -188,8 +188,8 @@ class EventData {
|
||||
print("----------------------------------------Creating EventData with content: ${json['content']}");
|
||||
}
|
||||
|
||||
if( json['id'] == "af57a41047c339e25f2dcf46e20de883b885b22499642813954545eefc1a192c") {
|
||||
if(gDebug > 0) print("got message: af57a41047c339e25f2dcf46e20de883b885b22499642813954545eefc1a192c");
|
||||
if( json['id'] == "f0cfda6c5d20de2becdf3ebf50e87a9bb1042b3fb4b7e03adefd892d46e65ba7") {
|
||||
if(gDebug >= 1) print("got message: f0cfda6c5d20de2becdf3ebf50e87a9bb1042b3fb4b7e03adefd892d46e65ba7");
|
||||
}
|
||||
|
||||
return EventData(json['id'] as String, json['pubkey'] as String,
|
||||
|
@ -100,16 +100,6 @@ class Tree {
|
||||
return newEventsId;
|
||||
}
|
||||
|
||||
void addChild(Event child) {
|
||||
Tree node;
|
||||
node = Tree(child, [], {}, []);
|
||||
children.add(node);
|
||||
}
|
||||
|
||||
void addChildNode(Tree node) {
|
||||
children.add(node);
|
||||
}
|
||||
|
||||
int printTree(int depth, bool onlyPrintChildren, var newerThan) {
|
||||
|
||||
int numPrinted = 0;
|
||||
@ -166,19 +156,6 @@ class Tree {
|
||||
return numPrinted;
|
||||
}
|
||||
|
||||
Tree getTopTree(Tree t) {
|
||||
|
||||
while( true) {
|
||||
Tree? parent = allChildEventsMap[ t.e.eventData.getParent()];
|
||||
if( parent != null) {
|
||||
t = parent;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/*
|
||||
* @printNotifications Add the given events to the Tree, and print the events as notifications
|
||||
* It should be ensured that these are only kind 1 events
|
||||
@ -275,11 +252,38 @@ class Tree {
|
||||
}
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
void addChild(Event child) {
|
||||
Tree node;
|
||||
node = Tree(child, [], {}, []);
|
||||
children.add(node);
|
||||
}
|
||||
|
||||
void addChildNode(Tree node) {
|
||||
children.add(node);
|
||||
}
|
||||
|
||||
Tree getTopTree(Tree t) {
|
||||
|
||||
while( true) {
|
||||
Tree? parent = allChildEventsMap[ t.e.eventData.getParent()];
|
||||
if( parent != null) {
|
||||
t = parent;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
int ascendingTimeTree(Tree a, Tree b) {
|
||||
if(a.e.eventData.createdAt < b.e.eventData.createdAt) {
|
||||
return 0;
|
||||
return -1;
|
||||
} else {
|
||||
if( a.e.eventData.createdAt == b.e.eventData.createdAt) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user