mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-04-19 01:01:26 +02:00
fixed issue where had to go to main menu from SN menu to get notifications
improved notification count and display with recent clipped-thread change
This commit is contained in:
parent
141c8e2622
commit
e11c374d66
@ -31,7 +31,13 @@ Future<void> processAnyIncomingEvents(Store node, [bool printNotifications = tru
|
||||
List<int> numPrinted1 = [0,0,0];
|
||||
if( printNotifications) {
|
||||
numPrinted1 = node.printTreeNotifications(newEventIds);
|
||||
showAllNotifications(node, numPrinted1[0], numPrinted1[2]);
|
||||
|
||||
// need to clear because only top 20 events in each thread are printed or cleared with above
|
||||
int clearNotifications (Tree t) => t.treeSelector_clearNotifications();
|
||||
node.traverseStoreTrees(clearNotifications);
|
||||
|
||||
// print direc room notifications if any, and print summary of all notifications printed
|
||||
directRoomNotifications(node, numPrinted1[0], numPrinted1[2]);
|
||||
}
|
||||
|
||||
});
|
||||
@ -1290,6 +1296,7 @@ Future<void> socialMenuUi(Store node) async {
|
||||
switch(option) {
|
||||
case 1:
|
||||
node.printStoreTrees(0, DateTime.now().subtract(Duration(hours:gHoursDefaultPrint)), selectorTrees_all);
|
||||
await processAnyIncomingEvents(node, true);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
@ -1338,6 +1345,8 @@ Future<void> socialMenuUi(Store node) async {
|
||||
} else {
|
||||
print("No notifications.");
|
||||
}
|
||||
|
||||
await processAnyIncomingEvents(node, true);
|
||||
break;
|
||||
case 4:
|
||||
clearScreen();
|
||||
@ -1347,6 +1356,8 @@ Future<void> socialMenuUi(Store node) async {
|
||||
} else {
|
||||
print("No posts made by you in last $gHoursDefaultPrint hours.");
|
||||
}
|
||||
|
||||
await processAnyIncomingEvents(node, true);
|
||||
break;
|
||||
case 5:
|
||||
clearScreen();
|
||||
@ -1357,7 +1368,9 @@ Future<void> socialMenuUi(Store node) async {
|
||||
} else {
|
||||
print("No replies/likes made by you in last $gHoursDefaultPrint hours.");
|
||||
}
|
||||
await processAnyIncomingEvents(node, true);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
clearScreen();
|
||||
bool selectorTrees_followActions (Tree t) => t.treeSelectorUserPostAndLike(getFollows( userPublicKey));
|
||||
@ -1367,7 +1380,9 @@ Future<void> socialMenuUi(Store node) async {
|
||||
} else {
|
||||
print("No threads to show where your follows participated in last $gHoursDefaultPrint hours.");
|
||||
}
|
||||
await processAnyIncomingEvents(node, true);
|
||||
break;
|
||||
|
||||
case 7: // search word or event id
|
||||
clearScreen();
|
||||
stdout.write("Enter word(s) to search: ");
|
||||
@ -1380,6 +1395,7 @@ Future<void> socialMenuUi(Store node) async {
|
||||
print("\nNot found in the last $gHoursDefaultPrint hours. 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;
|
||||
|
||||
/*
|
||||
@ -1470,8 +1486,10 @@ Future<void> socialMenuUi(Store node) async {
|
||||
}
|
||||
}
|
||||
}
|
||||
await processAnyIncomingEvents(node, true);
|
||||
break;
|
||||
|
||||
|
||||
case 9:
|
||||
clearScreen();
|
||||
stdout.write("Printing profile of a user; type username or first few letters of user's public key( or full public key): ");
|
||||
@ -1524,26 +1542,20 @@ Future<void> socialMenuUi(Store node) async {
|
||||
} // end while
|
||||
} // end socialMenuUi()
|
||||
|
||||
void showAllNotifications(Store node, [int x = 0, int y = 0]) {
|
||||
void directRoomNotifications(Store node, [int x = 0, int y = 0]) {
|
||||
//print("In showAllNotifications. x = $x y = $y");
|
||||
|
||||
List<int> numPrinted = [x, 0, y];
|
||||
|
||||
bool hasNotifications (Tree t) => t.treeSelectorNotifications();
|
||||
List<int> temp = node.printStoreTrees(0, DateTime.now().subtract(Duration(hours:gHoursDefaultPrint)), hasNotifications);
|
||||
numPrinted[0] = temp[0];
|
||||
numPrinted[1] = temp[1];
|
||||
numPrinted[2] = temp[2];
|
||||
|
||||
int numNotificationsPrinted = numPrinted[2];
|
||||
|
||||
// print direct messages and count the number printed
|
||||
bool showNotifications (ScrollableMessages room) => room.selectorNotifications();
|
||||
int numDirectRoomsPrinted = node.printDirectRoomsOverview( showNotifications, 100, node.allChildEventsMap);
|
||||
|
||||
if( numDirectRoomsPrinted > 0)
|
||||
print("\n");
|
||||
|
||||
int totalNotifications = numNotificationsPrinted + numDirectRoomsPrinted;
|
||||
int totalNotifications = numPrinted[2] + numDirectRoomsPrinted;
|
||||
if( totalNotifications > 0) {
|
||||
print("Showed $totalNotifications notifications.\n");
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import 'package:logging/logging.dart';
|
||||
|
||||
// name of executable
|
||||
const String exename = "nostr_console";
|
||||
const String version = "0.3.1-beta";
|
||||
const String version = "0.3.1a-beta";
|
||||
|
||||
int gDebug = 0;
|
||||
int gSpecificDebug = 0;
|
||||
|
@ -10,6 +10,8 @@ import 'dart:math'; // for Point
|
||||
|
||||
|
||||
typedef fTreeSelector = bool Function(Tree a);
|
||||
typedef fTreeSelector_int = int Function(Tree a);
|
||||
|
||||
typedef fRoomSelector = bool Function(ScrollableMessages room);
|
||||
|
||||
typedef fvisitorMarkNotifications = void Function(Event e);
|
||||
@ -425,7 +427,7 @@ class Tree {
|
||||
List<int> printTree(int depth, DateTime newerThan, bool topPost, [int countPrinted = 0, int maxToPrint = gMaxEventsInThreadPrinted]) {
|
||||
List<int> ret = [0,0,0];
|
||||
|
||||
if(event.eventData.isNotification) {
|
||||
if(event.eventData.isNotification || event.eventData.newLikes.length > 0) {
|
||||
ret[2] = 1;
|
||||
}
|
||||
|
||||
@ -658,7 +660,7 @@ class Tree {
|
||||
} // end treeSelectorClientName()
|
||||
|
||||
// returns true if the event or any of its children were made from the given client, and they are marked for notification
|
||||
bool treeSelectorNotifications() {
|
||||
bool treeSelector_hasNotifications() {
|
||||
|
||||
bool hasNotifications = false;
|
||||
if( event.eventData.isNotification || event.eventData.newLikes.length > 0) {
|
||||
@ -667,7 +669,7 @@ class Tree {
|
||||
|
||||
bool childMatch = false;
|
||||
for( int i = 0; i < children.length; i++ ) {
|
||||
if( children[i].treeSelectorNotifications()) {
|
||||
if( children[i].treeSelector_hasNotifications()) {
|
||||
childMatch = true;
|
||||
break;
|
||||
}
|
||||
@ -677,7 +679,34 @@ class Tree {
|
||||
}
|
||||
|
||||
return false;
|
||||
} // end treeSelectorNotifications()
|
||||
} // end treeSelector_hasNotifications()
|
||||
|
||||
|
||||
// clears all notifications; returns true always
|
||||
int treeSelector_clearNotifications() {
|
||||
|
||||
int count = 0;
|
||||
|
||||
if( event.eventData.isNotification) {
|
||||
event.eventData.isNotification = false;
|
||||
count = 1;
|
||||
}
|
||||
|
||||
if( event.eventData.newLikes.length > 0) {
|
||||
event.eventData.newLikes = {};
|
||||
count = 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
for( int i = 0; i < children.length; i++ ) {
|
||||
count += children[i].treeSelector_clearNotifications();
|
||||
}
|
||||
|
||||
return count;
|
||||
} // end treeSelector_clearNotifications()
|
||||
|
||||
|
||||
// counts all valid events in the tree: ignores the dummy nodes that are added for events which aren't yet known
|
||||
int count() {
|
||||
@ -1588,7 +1617,7 @@ class Store {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// returns Point , where first int is total Threads ( or top trees) printed, second is total events printed, and third is notifications printed
|
||||
// returns list , where first int is total Threads ( or top trees) printed, second is total events printed, and third is notifications printed
|
||||
static List<int> printTopPost(Tree topTree, int depth, DateTime newerThan, [int maxToPrint = gMaxEventsInThreadPrinted]) {
|
||||
stdout.write(Store.startMarkerStr);
|
||||
|
||||
@ -1599,6 +1628,15 @@ class Store {
|
||||
return counts;
|
||||
}
|
||||
|
||||
// will just traverse all trees in store
|
||||
int traverseStoreTrees(fTreeSelector_int treeSelector) {
|
||||
int count = 0;
|
||||
for( int i = 0; i < topPosts.length; i++) {
|
||||
count += treeSelector(topPosts[i]);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************/
|
||||
/* The main print tree function. Calls the treeSelector() for every node and prints it( and its children), only if it returns true.
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: nostr_console
|
||||
description: A multi-platform nostr client built for terminal/console
|
||||
version: 0.3.1-beta
|
||||
version: 0.3.1a-beta
|
||||
homepage: https://github.com/vishalxl/nostr_console
|
||||
|
||||
|
||||
@ -14,6 +14,10 @@ homepage: https://github.com/vishalxl/nostr_console
|
||||
# if too many wrong menu inputs are given ( >40) then program exits without saving any new events. for issue #49
|
||||
# showed lud06 and lud16, if any, in profile as qr code
|
||||
|
||||
# after tagging
|
||||
# improved notification count and display with recent clipped-thread change
|
||||
# fixed issue where had to go to main menu from SN menu to get notifications ; related: also got notifications in other menus so now on following someone, that event is processed in this menu itself
|
||||
|
||||
|
||||
# 0.3.0
|
||||
# added check marks; added more default users
|
||||
|
Loading…
x
Reference in New Issue
Block a user