mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-12-02 16:58:23 +01:00
printed notifications for channels too at start
so all three notifications get printed now at start
This commit is contained in:
@@ -501,7 +501,7 @@ Future<void> channelMenuUI(Store node) async {
|
|||||||
|
|
||||||
//await processNotifications(node); // this takes 300 ms
|
//await processNotifications(node); // this takes 300 ms
|
||||||
if( !justShowedChannels) {
|
if( !justShowedChannels) {
|
||||||
node.printAllChannelsInfo(20);
|
node.printAllChannelsInfo(20, selectorShowAllRooms);
|
||||||
justShowedChannels = true;
|
justShowedChannels = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,7 +512,7 @@ Future<void> channelMenuUI(Store node) async {
|
|||||||
print('You picked: $option');
|
print('You picked: $option');
|
||||||
switch(option) {
|
switch(option) {
|
||||||
case 1:
|
case 1:
|
||||||
node.printAllChannelsInfo(1000);
|
node.printAllChannelsInfo(1000, selectorShowAllRooms);
|
||||||
justShowedChannels = true;
|
justShowedChannels = true;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
@@ -587,12 +587,13 @@ Future<void> PrivateMenuUI(Store node) async {
|
|||||||
// bool fromClient (Tree t) => t.fromClientSelector(clientName);
|
// bool fromClient (Tree t) => t.fromClientSelector(clientName);
|
||||||
// node.printTree(0, DateTime.now().subtract(Duration(days:gNumLastDays)), fromClient); // search for last gNumLastDays only
|
// node.printTree(0, DateTime.now().subtract(Duration(days:gNumLastDays)), fromClient); // search for last gNumLastDays only
|
||||||
|
|
||||||
bool showAllRooms (DirectMessageRoom room) => selectorShowAllDirectRooms(room);
|
bool showAllRooms (ScrollableMessages room) => selectorShowAllRooms(room);
|
||||||
node.printDirectRoomInfo(showAllRooms);
|
node.printDirectRoomInfo(showAllRooms);
|
||||||
|
|
||||||
|
|
||||||
int option = showMenu([
|
int option = showMenu([
|
||||||
'Reply or Send a direct message',
|
'Reply or Send a direct message',
|
||||||
|
'Create hub group chat',
|
||||||
'Go back to main menu'], // 3
|
'Go back to main menu'], // 3
|
||||||
"Private Message Menu"); // name of menu
|
"Private Message Menu"); // name of menu
|
||||||
print('You picked: $option');
|
print('You picked: $option');
|
||||||
@@ -654,6 +655,9 @@ Future<void> PrivateMenuUI(Store node) async {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
|
|
||||||
|
case 3:
|
||||||
continueChatMenu = false;
|
continueChatMenu = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -672,9 +676,11 @@ Future<void> mainMenuUi(Store node) async {
|
|||||||
bool hasRepliesAndLikes (Tree t) => t.hasRepliesAndLikes(userPublicKey);
|
bool hasRepliesAndLikes (Tree t) => t.hasRepliesAndLikes(userPublicKey);
|
||||||
node.printTree(0, DateTime.now().subtract(Duration(days:gNumLastDays)), hasRepliesAndLikes);
|
node.printTree(0, DateTime.now().subtract(Duration(days:gNumLastDays)), hasRepliesAndLikes);
|
||||||
|
|
||||||
bool showNotifications (DirectMessageRoom room) => room.selectorNotifications();
|
bool showNotifications (ScrollableMessages room) => room.selectorNotifications();
|
||||||
node.printDirectRoomInfo(showNotifications);
|
node.printDirectRoomInfo(showNotifications);
|
||||||
|
|
||||||
|
node.printAllChannelsInfo(20, showNotifications);
|
||||||
|
|
||||||
|
|
||||||
bool userContinue = true;
|
bool userContinue = true;
|
||||||
while(userContinue) {
|
while(userContinue) {
|
||||||
|
|||||||
@@ -214,6 +214,13 @@ class EventData {
|
|||||||
String? decrypted = decryptContent();
|
String? decrypted = decryptContent();
|
||||||
if( decrypted != null) {
|
if( decrypted != null) {
|
||||||
evaluatedContent = decrypted;
|
evaluatedContent = decrypted;
|
||||||
|
|
||||||
|
// hubgroup can have two types of messages
|
||||||
|
// 1. sent by self, declaring the pub/pri keys of the new group chat and its N members (not including user themselve). Its len is (64) * (2 + N) and spaces
|
||||||
|
// hub grp pubkey, hub grp prikey, participant1, participant2, .. participantN
|
||||||
|
// 2. Messages from users that are to be broadcast to others
|
||||||
|
// hub grp pubkey, <message>
|
||||||
|
//
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} // end switch
|
} // end switch
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import 'package:nostr_console/event_ds.dart';
|
|||||||
import 'package:nostr_console/settings.dart';
|
import 'package:nostr_console/settings.dart';
|
||||||
|
|
||||||
typedef fTreeSelector = bool Function(Tree a);
|
typedef fTreeSelector = bool Function(Tree a);
|
||||||
typedef fDirectRoomSelector = bool Function(DirectMessageRoom room);
|
typedef fRoomSelector = bool Function(ScrollableMessages room);
|
||||||
|
|
||||||
Store? gStore = null;
|
Store? gStore = null;
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ bool selectorShowAllTrees(Tree t) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool selectorShowAllDirectRooms(DirectMessageRoom room) {
|
bool selectorShowAllRooms(ScrollableMessages room) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -772,7 +772,7 @@ class Store {
|
|||||||
allChildEventsMap[parentId]?.children.add(newTree);
|
allChildEventsMap[parentId]?.children.add(newTree);
|
||||||
} else {
|
} else {
|
||||||
// create top unknown parent and then add it
|
// create top unknown parent and then add it
|
||||||
Event dummy = Event("","", EventData(parentId, gDummyAccountPubkey, newTree.event.eventData.createdAt, 1, "Unknown parent event", [], [], [], [[]], {}), [""], "[json]");
|
Event dummy = Event("","", EventData(parentId, gDummyAccountPubkey, newTree.event.eventData.createdAt, 1, "Event not loaded", [], [], [], [[]], {}), [""], "[json]");
|
||||||
Tree dummyTopNode = Tree.withoutStore(dummy, []);
|
Tree dummyTopNode = Tree.withoutStore(dummy, []);
|
||||||
dummyTopNode.children.add(newTree);
|
dummyTopNode.children.add(newTree);
|
||||||
topPosts.add(dummyTopNode);
|
topPosts.add(dummyTopNode);
|
||||||
@@ -970,7 +970,22 @@ class Store {
|
|||||||
/**
|
/**
|
||||||
* @printAllChennelsInfo Print one line information about all channels, which are type 40 events ( class ChatRoom)
|
* @printAllChennelsInfo Print one line information about all channels, which are type 40 events ( class ChatRoom)
|
||||||
*/
|
*/
|
||||||
void printAllChannelsInfo(int numToPrint) {
|
void printAllChannelsInfo(int numToPrint, fRoomSelector selector) {
|
||||||
|
|
||||||
|
int numRoomsSelected = 0;
|
||||||
|
for( int j = 0; j < channels.length; j++) {
|
||||||
|
if( selector(channels[j]))
|
||||||
|
numRoomsSelected++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( numRoomsSelected == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if selected rooms is less, then print only that
|
||||||
|
if( numRoomsSelected < numToPrint)
|
||||||
|
numToPrint = numRoomsSelected;
|
||||||
|
|
||||||
channels.sort(scrollableCompareTo);
|
channels.sort(scrollableCompareTo);
|
||||||
print("");
|
print("");
|
||||||
if( numToPrint < channels.length) {
|
if( numToPrint < channels.length) {
|
||||||
@@ -1066,7 +1081,7 @@ class Store {
|
|||||||
/**
|
/**
|
||||||
* @printDirectRoomInfo Print one line information about chat rooms
|
* @printDirectRoomInfo Print one line information about chat rooms
|
||||||
*/
|
*/
|
||||||
void printDirectRoomInfo(fDirectRoomSelector roomSelector) {
|
void printDirectRoomInfo(fRoomSelector roomSelector) {
|
||||||
directRooms.sort(scrollableCompareTo);
|
directRooms.sort(scrollableCompareTo);
|
||||||
|
|
||||||
int numNotificationRooms = 0;
|
int numNotificationRooms = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user