Skip to content

Commit

Permalink
added cls and improved ui related to word search
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalxl committed Nov 24, 2022
1 parent 8f7b7b0 commit a1014f9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
17 changes: 14 additions & 3 deletions lib/console_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1184,28 +1184,35 @@ Future<void> socialMenuUi(Store node) async {
break;

case 3:

clearScreen();
String temp = userPublicKey;
bool selectorTrees_userNotifications (Tree t) => t.treeSelectorRepliesAndLikes(temp);
node.printTree(0, DateTime.now().subtract(Duration(days:gNumLastDays)), selectorTrees_userNotifications);
break;

case 4:
clearScreen();
node.printTree(0, DateTime.now().subtract(Duration(days:gNumLastDays)), selectorTrees_selfPosts);
break;
case 5:
clearScreen();
node.printTree(0, DateTime.now().subtract(Duration(days:gNumLastDays)), selectorTrees_userRepliesLikes);
break;
case 6:
clearScreen();
node.printTree(0, DateTime.now().subtract(Duration(days:gNumLastDays)), selectorTrees_followsPosts);
break;
case 7: // search word or event id
clearScreen();
stdout.write("Enter word(s) to search: ");
String? $tempWords = stdin.readLineSync();
String words = $tempWords??"";
if( words != "") {
bool onlyWords (Tree t) => t.treeSelectorHasWords(words.toLowerCase());
node.printTree(0, DateTime.now().subtract(Duration(days:gNumLastDays)), onlyWords); // search for last gNumLastDays only
int numPrinted = node.printTree(0, DateTime.now().subtract(Duration(days:gNumLastDays)), onlyWords); // search for last gNumLastDays only
if( numPrinted == 0) {
print("Word(s) not found in last $gNumLastDays days. Try increasing the number of days printed, from social network options to search further back into history.\n");
}
} else printWarning("Blank word entered. Try again.");
break;

Expand All @@ -1221,12 +1228,14 @@ Future<void> socialMenuUi(Store node) async {
break;
*/
case 8: // follow new contact

// in case the program was invoked with --pubkey, then user can't send messages
if( userPrivateKey == "") {
printWarning("Since no user private key has been supplied, posts/messages can't be sent. Invoke with --prikey");
break;
}

clearScreen();
stdout.write("Enter username or first few letters of user's public key( or full public key): ");
String? $tempUserName = stdin.readLineSync();
String userName = $tempUserName??"";
Expand Down Expand Up @@ -1299,6 +1308,7 @@ Future<void> socialMenuUi(Store node) async {
break;

case 9: // change number of days printed
clearScreen();
stdout.write("Enter number of days for which you want to see posts: ");
String? $tempNumDays = stdin.readLineSync();
String newNumDays = $tempNumDays??"";
Expand All @@ -1318,7 +1328,8 @@ Future<void> socialMenuUi(Store node) async {
break;

case 10:
stdout.write("Type username or first few letters of user's public key( or full public key): ");
clearScreen();
stdout.write("Printing profile of a user; type username or first few letters of user's public key( or full public key): ");
String? $tempUserName = stdin.readLineSync();
String userName = $tempUserName??"";
if( userName != "") {
Expand Down
2 changes: 1 addition & 1 deletion lib/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:logging/logging.dart';

// name of executable
const String exename = "nostr_console";
const String version = "0.1.7-beta";
const String version = "0.1.8-beta";

int gDebug = 0;
int gSpecificDebug = 0;
Expand Down
6 changes: 4 additions & 2 deletions lib/tree_ds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1439,8 +1439,10 @@ class Store {
numPrinted += printTopPost(topPosts[i], depth, newerThan);
}

if( numPrinted > 0)
print("\nTotal posts printed: $numPrinted for last $gNumLastDays days");
if( numPrinted > 0) {
print("\nTotal posts printed: $numPrinted for last $gNumLastDays days\n.");
}

return numPrinted;
}

Expand Down
7 changes: 3 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: nostr_console
description: A multi-platform nostr client built for terminal/console.
version: 0.1.7-beta
version: 0.1.8-beta
homepage: https://github.com/vishalxl/nostr_console

# Release 0.1.6-beta
# update when sending kind 1
# improved url breaking
# Release 0.1.8-beta
# menu changed

environment:
sdk: '>=2.17.3 <3.0.0'
Expand Down

0 comments on commit a1014f9

Please sign in to comment.