mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-04-25 16:00:43 +02:00
still fixing notifications
This commit is contained in:
parent
61b27e3de7
commit
24c83ce45f
@ -16,12 +16,15 @@ Future<void> processAnyIncomingEvents(Store node, [bool printNotifications = tru
|
||||
const int waitMilliSeconds = 200;
|
||||
Future.delayed(const Duration(milliseconds: waitMilliSeconds), () {
|
||||
|
||||
node.processIncomingEvent(getRecievedEvents());
|
||||
Set<String> newEventIds = node.processIncomingEvent(getRecievedEvents());
|
||||
clearEvents();
|
||||
|
||||
Point numPrinted1 = Point(0,0);
|
||||
if( printNotifications) {
|
||||
showAllNotifications(node);
|
||||
numPrinted1 = node.printTreeNotifications(newEventIds);
|
||||
}
|
||||
|
||||
showAllNotifications(node, numPrinted1.x.toInt(), numPrinted1.y.toInt());
|
||||
});
|
||||
|
||||
|
||||
@ -1210,7 +1213,9 @@ Future<void> socialMenuUi(Store node) async {
|
||||
}
|
||||
|
||||
await sendReplyPostLike(node, replyToId, replyKind, content);
|
||||
await processAnyIncomingEvents(node, false);
|
||||
clearScreen();
|
||||
|
||||
await processAnyIncomingEvents(node, true);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
@ -1387,12 +1392,12 @@ Future<void> socialMenuUi(Store node) async {
|
||||
} // end while
|
||||
} // end socialMenuUi()
|
||||
|
||||
void showAllNotifications(Store node) {
|
||||
void showAllNotifications(Store node, [int x = 0, int y = 0]) {
|
||||
|
||||
//printUnderlined("Notifications:");
|
||||
Point numPrinted = Point(x, y);
|
||||
|
||||
bool hasNotifications (Tree t) => t.treeSelectorNotifications();
|
||||
Point numPrinted = node.printTree(0, DateTime.now().subtract(Duration(days:gNumLastDays)), hasNotifications);
|
||||
numPrinted += node.printTree(0, DateTime.now().subtract(Duration(days:gNumLastDays)), hasNotifications);
|
||||
int numNotificationsPrinted = numPrinted.y.toInt();
|
||||
|
||||
bool showNotifications (ScrollableMessages room) => room.selectorNotifications();
|
||||
@ -1413,7 +1418,7 @@ Future<void> mainMenuUi(Store node) async {
|
||||
clearScreen();
|
||||
|
||||
//Show only notifications
|
||||
showAllNotifications(node);
|
||||
await processAnyIncomingEvents(node); // this takes 300 ms
|
||||
|
||||
bool mainMenuContinue = true;
|
||||
bool firstTime = true;
|
||||
|
@ -1343,10 +1343,8 @@ class Store {
|
||||
* @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
|
||||
*/
|
||||
void printNotifications(Set<String> newEventIdsSet, String userName) {
|
||||
if( gDebug > 0) print("Info: in printNotifications: num new evetns = ${newEventIdsSet.length}");
|
||||
Point printTreeNotifications(Set<String> newEventIdsSet) {
|
||||
|
||||
String strToWrite = "";
|
||||
int countNotificationEvents = 0;
|
||||
for( var newEventId in newEventIdsSet) {
|
||||
int k = (allChildEventsMap[newEventId]?.event.eventData.kind??-1);
|
||||
@ -1361,18 +1359,11 @@ class Store {
|
||||
}
|
||||
}
|
||||
|
||||
if(gDebug > 0) print("Info: In printNotifications: newEventsId = $newEventIdsSet count17 = $countNotificationEvents");
|
||||
|
||||
if( countNotificationEvents == 0) {
|
||||
return;
|
||||
return Point(0,0);
|
||||
}
|
||||
// TODO call count() less
|
||||
strToWrite += "Number of new replies/posts = ${newEventIdsSet.length}\n";
|
||||
stdout.write("${getNumDashes(strToWrite.length -1 )}\n$strToWrite");
|
||||
//stdout.write("Total posts : ${count()}\n");
|
||||
stdout.write("Signed in as : $userName\n");
|
||||
stdout.write("\nHere are the threads with new replies or new likes: \n\n");
|
||||
|
||||
|
||||
|
||||
List<Tree> topNotificationTree = []; // collect all top tress to display in this list. only unique tress will be displayed
|
||||
newEventIdsSet.forEach((eventID) {
|
||||
|
||||
@ -1422,14 +1413,16 @@ class Store {
|
||||
// remove duplicate top trees
|
||||
Set ids = {};
|
||||
topNotificationTree.retainWhere((t) => ids.add(t.event.eventData.id));
|
||||
|
||||
|
||||
Store.reCalculateMarkerStr();
|
||||
|
||||
Point retval = Point(0,0);
|
||||
topNotificationTree.forEach( (t) {
|
||||
Store.printTopPost(t, 0, DateTime(0));
|
||||
retval += Store.printTopPost(t, 0, DateTime(0));
|
||||
print("\n");
|
||||
});
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static Point printTopPost(Tree topTree, int depth, DateTime newerThan) {
|
||||
@ -1712,7 +1705,7 @@ class Store {
|
||||
if( iNotification++ > numNotificationRooms) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
DirectMessageRoom room = directRooms[j];
|
||||
String id = room.otherPubkey.substring(0, 6);
|
||||
String name = getAuthorName(room.otherPubkey, 4);
|
||||
|
@ -9,6 +9,7 @@ homepage: https://github.com/vishalxl/nostr_console
|
||||
# chmod in actions
|
||||
# improved channel display
|
||||
# /help in enc groups
|
||||
# still fixing notifications
|
||||
|
||||
|
||||
environment:
|
||||
|
Loading…
x
Reference in New Issue
Block a user