mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-04-18 00:31:13 +02:00
fixing notifications
This commit is contained in:
parent
24c83ce45f
commit
fde809dfd4
@ -9,27 +9,35 @@ import 'package:nostr_console/utils.dart';
|
||||
import 'package:bip340/bip340.dart';
|
||||
|
||||
Future<void> processAnyIncomingEvents(Store node, [bool printNotifications = true]) async {
|
||||
//print("In process incoming");
|
||||
reAdjustAlignment();
|
||||
|
||||
const int waitMilliSeconds1 = 100, waitMilliSeconds2 = 200;
|
||||
|
||||
Future<void> foo1() async {
|
||||
await Future.delayed(Duration(milliseconds: waitMilliSeconds1));
|
||||
return;
|
||||
}
|
||||
await foo1();
|
||||
|
||||
// need a bit of wait to give other events to execute, so do a delay, which allows
|
||||
// relays to recieve and handle new events
|
||||
const int waitMilliSeconds = 200;
|
||||
Future.delayed(const Duration(milliseconds: waitMilliSeconds), () {
|
||||
Future.delayed(const Duration(milliseconds: waitMilliSeconds2 ), () {
|
||||
|
||||
Set<String> newEventIds = node.processIncomingEvent(getRecievedEvents());
|
||||
clearEvents();
|
||||
|
||||
Point numPrinted1 = Point(0,0);
|
||||
Point numPrinted1 = Point(0, 0);
|
||||
if( printNotifications) {
|
||||
numPrinted1 = node.printTreeNotifications(newEventIds);
|
||||
showAllNotifications(node, numPrinted1.x.toInt(), numPrinted1.y.toInt());
|
||||
}
|
||||
|
||||
showAllNotifications(node, numPrinted1.x.toInt(), numPrinted1.y.toInt());
|
||||
});
|
||||
|
||||
|
||||
Future<void> foo() async {
|
||||
await Future.delayed(Duration(milliseconds: waitMilliSeconds));
|
||||
await Future.delayed(Duration(milliseconds: waitMilliSeconds2));
|
||||
return;
|
||||
}
|
||||
await foo();
|
||||
@ -1087,7 +1095,6 @@ Future<void> PrivateMenuUI(Store node) async {
|
||||
int pageNum = 1;
|
||||
while(showChannelOption) {
|
||||
|
||||
|
||||
String fullChannelId = node.showDirectRoom(directRoomId, pageNum);
|
||||
if( fullChannelId == "") {
|
||||
printWarning("Could not find the given direct room.");
|
||||
@ -1114,18 +1121,16 @@ Future<void> PrivateMenuUI(Store node) async {
|
||||
// send message to the given room
|
||||
await sendDirectMessage(node, fullChannelId, messageToSend);
|
||||
await processAnyIncomingEvents(node, false); // get latest message
|
||||
//print("in privateMenuUI: sent message");
|
||||
|
||||
pageNum = 1; // reset it
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print("Refreshing...");
|
||||
}
|
||||
|
||||
await processAnyIncomingEvents(node, false);
|
||||
|
||||
clearScreen();
|
||||
|
||||
}
|
||||
clearScreen();
|
||||
justShowedChannels = false;
|
||||
break;
|
||||
|
||||
@ -1393,6 +1398,7 @@ Future<void> socialMenuUi(Store node) async {
|
||||
} // end socialMenuUi()
|
||||
|
||||
void showAllNotifications(Store node, [int x = 0, int y = 0]) {
|
||||
//print("In showAllNotifications. x = $x y = $y");
|
||||
|
||||
Point numPrinted = Point(x, y);
|
||||
|
||||
@ -1410,7 +1416,8 @@ void showAllNotifications(Store node, [int x = 0, int y = 0]) {
|
||||
if( totalNotifications > 0) {
|
||||
print("Showed $totalNotifications notifications.\n");
|
||||
}
|
||||
|
||||
|
||||
//print("printed $totalNotifications notifications") ;
|
||||
}
|
||||
|
||||
Future<void> mainMenuUi(Store node) async {
|
||||
@ -1426,8 +1433,8 @@ Future<void> mainMenuUi(Store node) async {
|
||||
|
||||
if( !firstTime) {
|
||||
await processAnyIncomingEvents(node); // this takes 300 ms
|
||||
firstTime = false;
|
||||
}
|
||||
firstTime = false;
|
||||
|
||||
// the main menu
|
||||
int option = showMenu(['Home Page', // 1
|
||||
|
@ -1259,7 +1259,6 @@ class Store {
|
||||
case 1:
|
||||
// only kind 1 events are added to the overall tree structure
|
||||
String parentId = newTree.event.eventData.getParent(allChildEventsMap);
|
||||
if( parentId == "471bb00f66212a594c1e875f708d01fc6aa4ed83d638c928d25e37dee28f8605") print("Found child of 471bb00f66212a594c1e875f708d01fc6aa4ed83d638c928d25e37dee28f8605 id = ${newTree.event.eventData.id}");
|
||||
if( parentId == "") {
|
||||
// if its a new parent event, then add it to the main top parents
|
||||
topPosts.add(newTree);
|
||||
@ -1437,11 +1436,8 @@ class Store {
|
||||
*/
|
||||
Point printTree(int depth, DateTime newerThan, fTreeSelector treeSelector) {
|
||||
|
||||
int numPrinted = 0;
|
||||
|
||||
topPosts.sort(sortTreeNewestReply); // sorting done only for top most threads. Lower threads aren't sorted so save cpu etc TODO improve top sorting
|
||||
|
||||
|
||||
// https://gist.github.com/dsample/79a97f38bf956f37a0f99ace9df367b9
|
||||
// bottom half ▄
|
||||
|
||||
|
@ -9,7 +9,7 @@ homepage: https://github.com/vishalxl/nostr_console
|
||||
# chmod in actions
|
||||
# improved channel display
|
||||
# /help in enc groups
|
||||
# still fixing notifications
|
||||
# still fixing notifications
|
||||
|
||||
|
||||
environment:
|
||||
|
Loading…
x
Reference in New Issue
Block a user