mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-07-12 21:32:17 +02:00
printed number of trees displayed. added option to change number of days dispayed
This commit is contained in:
@ -46,21 +46,44 @@ String getShaId(String pubkey, int createdAt, String strTags, String content) {
|
||||
}
|
||||
|
||||
Future<void> otherMenuUi(Tree node, var contactList) async {
|
||||
bool continueOtherMenu = true;
|
||||
while(continueOtherMenu) {
|
||||
print('\n\nPick an option by typing the corresponding\nnumber and then pressing <enter>:');
|
||||
int option = showMenu([ 'Display Contact List', // 1
|
||||
'Change number of days printed',
|
||||
'Go back to main menu']); // 3
|
||||
print('You picked: $option');
|
||||
switch(option) {
|
||||
case 1:
|
||||
String authorName = getAuthorName(userPublicKey);
|
||||
print("\nHere is the contact list for user $userPublicKey ($authorName), which has ${contactList.length} profiles in it:\n");
|
||||
contactList.forEach((x) => stdout.write("${getAuthorName(x)}, "));
|
||||
print("");
|
||||
break;
|
||||
case 2:
|
||||
String? $tempNumDays = stdin.readLineSync();
|
||||
String newNumDays = $tempNumDays??"";
|
||||
|
||||
print('\n\nPick an option by typing the corresponding\nnumber and then pressing <enter>:');
|
||||
int option = showMenu([ 'Display Contact List', // 1
|
||||
'Go back']); // 3
|
||||
print('You picked: $option');
|
||||
switch(option) {
|
||||
case 1:
|
||||
String authorName = getAuthorName(userPublicKey);
|
||||
print("\nHere is the contact list for user $userPublicKey ($authorName), which has ${contactList.length} profiles in it:\n");
|
||||
contactList.forEach((x) => stdout.write("${getAuthorName(x)}, "));
|
||||
print("");
|
||||
break;
|
||||
try {
|
||||
gNumLastDays = int.parse(newNumDays);
|
||||
print("Changed number of days printed to $gNumLastDays");
|
||||
} on FormatException catch (e) {
|
||||
print(e.message);
|
||||
return;
|
||||
} on Exception catch (e) {
|
||||
print(e);
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
continueOtherMenu = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -122,7 +122,7 @@ class Relays {
|
||||
print( 'exception in fromJson for event');
|
||||
}
|
||||
},
|
||||
onError: (e) { print("\n${warningColor}Warning: In SendRequest creating connection onError. Kindly check your internet connection or change the relay by command line --relay=<relay wss url>"); print(colorEndMarker); },
|
||||
onError: (err) { print("\n${warningColor}Warning: In SendRequest creating connection onError. Kindly check your internet connection or change the relay by command line --relay=<relay wss url>"); print(colorEndMarker); },
|
||||
onDone: () { if( gDebug != 0) print('Info: In onDone'); }
|
||||
);
|
||||
} on WebSocketException {
|
||||
@ -151,7 +151,7 @@ class Relays {
|
||||
relays[relay] = fws;
|
||||
fws.stream.listen(
|
||||
(d) {}, //
|
||||
onError: (e) { print("\n${warningColor}Warning: In SendRequest creating connection onError. Kindly check your internet connection or change the relay by command line --relay=<relay wss url>"); print(colorEndMarker); },
|
||||
onError: (err) { print("\n${warningColor}Warning: In SendRequest creating connection onError. Kindly check your internet connection or change the relay by command line --relay=<relay wss url>"); print(colorEndMarker); },
|
||||
onDone: () { if( gDebug != 0) print('in onDone'); }
|
||||
);
|
||||
} on WebSocketException {
|
||||
|
@ -110,11 +110,13 @@ class Tree {
|
||||
children.add(node);
|
||||
}
|
||||
|
||||
void printTree(int depth, bool onlyPrintChildren, var newerThan) {
|
||||
int printTree(int depth, bool onlyPrintChildren, var newerThan) {
|
||||
|
||||
int numPrinted = 0;
|
||||
children.sort(ascendingTimeTree);
|
||||
if( !onlyPrintChildren) {
|
||||
e.printEvent(depth);
|
||||
numPrinted++;
|
||||
} else {
|
||||
depth = depth - 1;
|
||||
}
|
||||
@ -147,7 +149,7 @@ class Tree {
|
||||
leftShifted = true;
|
||||
}
|
||||
|
||||
children[i].printTree(depth+1, false, newerThan);
|
||||
numPrinted += children[i].printTree(depth+1, false, newerThan);
|
||||
}
|
||||
|
||||
if( leftShifted) {
|
||||
@ -156,6 +158,12 @@ class Tree {
|
||||
print(">");
|
||||
}
|
||||
|
||||
if( onlyPrintChildren) {
|
||||
print("\nTotal posts/replies printed: $numPrinted for last $gNumLastDays days");
|
||||
}
|
||||
|
||||
|
||||
return numPrinted;
|
||||
}
|
||||
|
||||
Tree getTopTree(Tree t) {
|
||||
@ -181,7 +189,7 @@ class Tree {
|
||||
Set temp = {};
|
||||
newEventsId.retainWhere((event) => temp.add(newEventsId));
|
||||
|
||||
stdout.write("\n\n\n\n\n\n---------------------------------------\nNotifications: ");
|
||||
stdout.write("\n---------------------------------------\nNotifications: ");
|
||||
if( newEventsId.isEmpty) {
|
||||
stdout.write("No new replies/posts.\nTotal posts: ${count()}\n");
|
||||
return;
|
||||
|
Reference in New Issue
Block a user