mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-12-02 08:46:55 +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
|
||||
if( !justShowedChannels) {
|
||||
node.printAllChannelsInfo(20);
|
||||
node.printAllChannelsInfo(20, selectorShowAllRooms);
|
||||
justShowedChannels = true;
|
||||
}
|
||||
|
||||
@@ -512,7 +512,7 @@ Future<void> channelMenuUI(Store node) async {
|
||||
print('You picked: $option');
|
||||
switch(option) {
|
||||
case 1:
|
||||
node.printAllChannelsInfo(1000);
|
||||
node.printAllChannelsInfo(1000, selectorShowAllRooms);
|
||||
justShowedChannels = true;
|
||||
break;
|
||||
case 2:
|
||||
@@ -587,12 +587,13 @@ Future<void> PrivateMenuUI(Store node) async {
|
||||
// bool fromClient (Tree t) => t.fromClientSelector(clientName);
|
||||
// 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);
|
||||
|
||||
|
||||
int option = showMenu([
|
||||
'Reply or Send a direct message',
|
||||
'Create hub group chat',
|
||||
'Go back to main menu'], // 3
|
||||
"Private Message Menu"); // name of menu
|
||||
print('You picked: $option');
|
||||
@@ -654,6 +655,9 @@ Future<void> PrivateMenuUI(Store node) async {
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
|
||||
case 3:
|
||||
continueChatMenu = false;
|
||||
break;
|
||||
|
||||
@@ -672,9 +676,11 @@ Future<void> mainMenuUi(Store node) async {
|
||||
bool hasRepliesAndLikes (Tree t) => t.hasRepliesAndLikes(userPublicKey);
|
||||
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.printAllChannelsInfo(20, showNotifications);
|
||||
|
||||
|
||||
bool userContinue = true;
|
||||
while(userContinue) {
|
||||
|
||||
@@ -214,6 +214,13 @@ class EventData {
|
||||
String? decrypted = decryptContent();
|
||||
if( decrypted != null) {
|
||||
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;
|
||||
} // end switch
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:nostr_console/event_ds.dart';
|
||||
import 'package:nostr_console/settings.dart';
|
||||
|
||||
typedef fTreeSelector = bool Function(Tree a);
|
||||
typedef fDirectRoomSelector = bool Function(DirectMessageRoom room);
|
||||
typedef fRoomSelector = bool Function(ScrollableMessages room);
|
||||
|
||||
Store? gStore = null;
|
||||
|
||||
@@ -13,7 +13,7 @@ bool selectorShowAllTrees(Tree t) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool selectorShowAllDirectRooms(DirectMessageRoom room) {
|
||||
bool selectorShowAllRooms(ScrollableMessages room) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -772,7 +772,7 @@ class Store {
|
||||
allChildEventsMap[parentId]?.children.add(newTree);
|
||||
} else {
|
||||
// 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, []);
|
||||
dummyTopNode.children.add(newTree);
|
||||
topPosts.add(dummyTopNode);
|
||||
@@ -970,7 +970,22 @@ class Store {
|
||||
/**
|
||||
* @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);
|
||||
print("");
|
||||
if( numToPrint < channels.length) {
|
||||
@@ -1066,7 +1081,7 @@ class Store {
|
||||
/**
|
||||
* @printDirectRoomInfo Print one line information about chat rooms
|
||||
*/
|
||||
void printDirectRoomInfo(fDirectRoomSelector roomSelector) {
|
||||
void printDirectRoomInfo(fRoomSelector roomSelector) {
|
||||
directRooms.sort(scrollableCompareTo);
|
||||
|
||||
int numNotificationRooms = 0;
|
||||
|
||||
Reference in New Issue
Block a user