mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-12-03 09:17:09 +01:00
only searched comments smaller than 1000, otherwise it was taking too much time. corrected selector logic in printNotifications
This commit is contained in:
@@ -114,7 +114,7 @@ Future<void> otherMenuUi(Tree node, var contactList) async {
|
|||||||
String words = $tempWords??"";
|
String words = $tempWords??"";
|
||||||
if( words != "") {
|
if( words != "") {
|
||||||
bool onlyWords (Tree t) => t.hasWords(words.toLowerCase());
|
bool onlyWords (Tree t) => t.hasWords(words.toLowerCase());
|
||||||
node.printTree(0, DateTime.now().subtract(Duration(days:gNumLastDays)), onlyWords);
|
node.printTree(0, DateTime.now().subtract(Duration(days:1000)), onlyWords); // search all the trees, hence 1000 days
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ Future<void> otherMenuUi(Tree node, var contactList) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> mainMenuUi(Tree node, var contactList) async {
|
Future<void> mainMenuUi(Tree node, var contactList) async {
|
||||||
gDebug = 0;
|
gDebug = 1;
|
||||||
// at the very beginning, show the tree as it is, and them show the options menu
|
// at the very beginning, show the tree as it is, and them show the options menu
|
||||||
node.printTree(0, DateTime.now().subtract(Duration(days:gNumLastDays)), selectAll);
|
node.printTree(0, DateTime.now().subtract(Duration(days:gNumLastDays)), selectAll);
|
||||||
bool userContinue = true;
|
bool userContinue = true;
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ Map< String, List<Contact>> gContactLists = {};
|
|||||||
// bots ignored to reduce spam
|
// bots ignored to reduce spam
|
||||||
List<String> gBots = [ "3b57518d02e6acfd5eb7198530b2e351e5a52278fb2499d14b66db2b5791c512", // robosats orderbook
|
List<String> gBots = [ "3b57518d02e6acfd5eb7198530b2e351e5a52278fb2499d14b66db2b5791c512", // robosats orderbook
|
||||||
"887645fef0ce0c3c1218d2f5d8e6132a19304cdc57cd20281d082f38cfea0072", // bestofhn
|
"887645fef0ce0c3c1218d2f5d8e6132a19304cdc57cd20281d082f38cfea0072", // bestofhn
|
||||||
"f4161c88558700d23af18d8a6386eb7d7fed769048e1297811dcc34e86858fb2" // bitcoin_bot
|
"f4161c88558700d23af18d8a6386eb7d7fed769048e1297811dcc34e86858fb2", // bitcoin_bot
|
||||||
|
"105dfb7467b6286f573cae17146c55133d0dcc8d65e5239844214412218a6c36" // zerohedge
|
||||||
];
|
];
|
||||||
|
|
||||||
//const String gDefaultEventsFilename = "events_store_nostr.txt";
|
//const String gDefaultEventsFilename = "events_store_nostr.txt";
|
||||||
@@ -307,7 +308,7 @@ class EventData {
|
|||||||
try {
|
try {
|
||||||
translator
|
translator
|
||||||
.translate(content, to: 'en')
|
.translate(content, to: 'en')
|
||||||
.then( (result) => { evaluatedContent = "$evaluatedContent\n\nTranslation: ${result.toString()}" , if( gDebug > 0) print("In google translate then")},
|
.then( (result) => { evaluatedContent = "$evaluatedContent\n\nTranslation: ${result.toString()}" , if( gDebug > 0) print("Google translate returned successfully for one call.")},
|
||||||
onError : (error, stackTrace) => "error in google translate");
|
onError : (error, stackTrace) => "error in google translate");
|
||||||
} on Exception catch(err) {
|
} on Exception catch(err) {
|
||||||
if( gDebug > 0) print("Error in trying to use google translate: $err");
|
if( gDebug > 0) print("Error in trying to use google translate: $err");
|
||||||
@@ -524,7 +525,7 @@ String getRelayOfUser(String userPubkey, String contactPubkey) {
|
|||||||
if( gDebug > 0) print( contacts[i].toString() );
|
if( gDebug > 0) print( contacts[i].toString() );
|
||||||
if( contacts[i].id == contactPubkey) {
|
if( contacts[i].id == contactPubkey) {
|
||||||
relay = contacts[i].relay;
|
relay = contacts[i].relay;
|
||||||
if(gDebug > 0) print("In getRelayOfUser: found relay $relay for contact $contactPubkey" );
|
//if(gDebug > 0) print("In getRelayOfUser: found relay $relay for contact $contactPubkey" );
|
||||||
return relay;
|
return relay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ class Tree {
|
|||||||
bool leftShifted = false;
|
bool leftShifted = false;
|
||||||
for( int i = 0; i < children.length; i++) {
|
for( int i = 0; i < children.length; i++) {
|
||||||
// continue if this children isn't going to get printed anyway
|
// continue if this children isn't going to get printed anyway
|
||||||
|
//if( gDebug > 0) print("going to call tree selector");
|
||||||
if( !treeSelector(children[i])) {
|
if( !treeSelector(children[i])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -200,6 +201,7 @@ class Tree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
numPrinted += children[i].printTree(depth+1, newerThan, treeSelector);
|
numPrinted += children[i].printTree(depth+1, newerThan, treeSelector);
|
||||||
|
//if( gDebug > 0) print("at end for loop iteraion: numPrinted = $numPrinted");
|
||||||
}
|
}
|
||||||
|
|
||||||
if( leftShifted) {
|
if( leftShifted) {
|
||||||
@@ -225,8 +227,27 @@ class Tree {
|
|||||||
Set temp = {};
|
Set temp = {};
|
||||||
newEventsId.retainWhere((event) => temp.add(newEventsId));
|
newEventsId.retainWhere((event) => temp.add(newEventsId));
|
||||||
|
|
||||||
|
(allChildEventsMap[""]?.e.eventData.id??-1) == 7 || (allChildEventsMap[""]?.e.eventData.id??-1) == 1;
|
||||||
|
|
||||||
String strToWrite = "Notifications: ";
|
String strToWrite = "Notifications: ";
|
||||||
if( newEventsId.isEmpty) {
|
int count17 = 0;
|
||||||
|
//newEventsId.forEach((element) { (allChildEventsMap[element]?.e.eventData.id??-1) == 7 || (allChildEventsMap[element]?.e.eventData.id??-1) == 1 ? count17++:count17; });
|
||||||
|
for( int i =0 ; i < newEventsId.length; i++) {
|
||||||
|
if( (allChildEventsMap[newEventsId[i]]?.e.eventData.kind??-1) == 7 || (allChildEventsMap[newEventsId[i]]?.e.eventData.kind??-1) == 1) {
|
||||||
|
|
||||||
|
count17++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( allChildEventsMap.containsKey(newEventsId[i])) {
|
||||||
|
if( gDebug > 0) print( "id = ${ (allChildEventsMap[newEventsId[i]]?.e.eventData.id??-1)}");
|
||||||
|
} else {
|
||||||
|
if( gDebug > 0) print( "could not find event id in map");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if(gDebug > 0) print("Info: In printNotifications: newEventsId len = $newEventsId count17 = $count17");
|
||||||
|
|
||||||
|
if( count17 == 0) {
|
||||||
strToWrite += "No new replies/posts.\n";
|
strToWrite += "No new replies/posts.\n";
|
||||||
stdout.write("${getNumDashes(strToWrite.length - 1)}\n$strToWrite");
|
stdout.write("${getNumDashes(strToWrite.length - 1)}\n$strToWrite");
|
||||||
stdout.write("Total posts : ${count()}\n");
|
stdout.write("Total posts : ${count()}\n");
|
||||||
@@ -268,10 +289,15 @@ class Tree {
|
|||||||
reactedToTree.e.eventData.newLikes.add( reactorId);
|
reactedToTree.e.eventData.newLikes.add( reactorId);
|
||||||
Tree topTree = getTopTree(reactedToTree);
|
Tree topTree = getTopTree(reactedToTree);
|
||||||
topTrees.add(topTree);
|
topTrees.add(topTree);
|
||||||
|
} else {
|
||||||
|
if(gDebug > 0) print("Could not find reactedTo tree");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if(gDebug > 0) print("Could not find reactedTo event");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if(gDebug > 0) print("got an event thats not 1 or 7(reaction). its id = ${t.e.eventData.kind} count17 = $count17");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -451,10 +477,22 @@ class Tree {
|
|||||||
|
|
||||||
// returns true if the given words exists in it or its children
|
// returns true if the given words exists in it or its children
|
||||||
bool hasWords(String word) {
|
bool hasWords(String word) {
|
||||||
|
//if(gDebug > 0) print("In tree selector hasWords: this id = ${e.eventData.id} word = $word");
|
||||||
|
if( e.eventData.content.length > 1000) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( e.eventData.content.toLowerCase().contains(word)) {
|
if( e.eventData.content.toLowerCase().contains(word)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for( int i = 0; i < children.length; i++ ) {
|
for( int i = 0; i < children.length; i++ ) {
|
||||||
|
//if(gDebug > 0) print("this id = ${e.eventData.id} word = $word i = $i ");
|
||||||
|
|
||||||
|
// ignore too large comments
|
||||||
|
if( children[i].e.eventData.content.length > 1000) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if( children[i].e.eventData.content.toLowerCase().contains(word)) {
|
if( children[i].e.eventData.content.toLowerCase().contains(word)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user