mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-04-17 08:11:50 +02:00
improved channel display and count shown
This commit is contained in:
parent
1a885daad8
commit
6b856eccd0
@ -653,7 +653,7 @@ Future<void> channelMenuUI(Store node) async {
|
||||
break;
|
||||
|
||||
case 2:
|
||||
node.printChannelsOverview(node.channels, 1000, selectorShowAllRooms);
|
||||
node.printChannelsOverview(node.channels, node.channels.length, selectorShowAllRooms);
|
||||
justShowedChannels = true;
|
||||
break;
|
||||
|
||||
@ -898,7 +898,7 @@ Future<void> encryptedChannelMenuUI(Store node) async {
|
||||
break;
|
||||
|
||||
case 2:
|
||||
node.printChannelsOverview(node.encryptedChannels, 1000, selectorShowAllRooms);
|
||||
node.printChannelsOverview(node.encryptedChannels, node.encryptedChannels.length, selectorShowAllRooms);
|
||||
justShowedChannels = true;
|
||||
break;
|
||||
|
||||
|
@ -1329,45 +1329,24 @@ class Store {
|
||||
/**
|
||||
* @printAllChennelsInfo Print one line information about all channels, which are type 40 events ( class ChatRoom)
|
||||
*/
|
||||
int printChannelsOverview(List<Channel> channelstoPrint, int numToPrint, fRoomSelector selector) {
|
||||
int printChannelsOverview(List<Channel> channelstoPrint, int numRoomsOverview, fRoomSelector selector) {
|
||||
|
||||
|
||||
int numRoomsSelected = 0;
|
||||
for( int j = 0; j < channelstoPrint.length; j++) {
|
||||
//print(channelstoPrint[j].participants);
|
||||
if( channelstoPrint[j].participants.length == 0 || (channelstoPrint[j].participants.length > 0 && channelstoPrint[j].participants.contains(userPublicKey))) {
|
||||
if( selector(channelstoPrint[j]) ) {
|
||||
numRoomsSelected++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//print(numRoomsSelected);
|
||||
|
||||
if( numRoomsSelected == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// if selected rooms is less, then print only that
|
||||
//if( numRoomsSelected < numToPrint) numToPrint = numRoomsSelected;
|
||||
|
||||
int numChannelsActuallyPrinted = 0;
|
||||
channelstoPrint.sort(scrollableCompareTo);
|
||||
print("");
|
||||
if( numToPrint < channelstoPrint.length) {
|
||||
print("Showing only $numToPrint/${channelstoPrint.length} total channels\n");
|
||||
} else {
|
||||
print("Showing all ${channelstoPrint.length} channels\n");
|
||||
numToPrint = channelstoPrint.length;
|
||||
}
|
||||
int numChannelsActuallyPrinted = 0;
|
||||
|
||||
printUnderlined(" Channel Name Num of Messages Latest Message ");
|
||||
for(int j = 0; j < numToPrint; j++) {
|
||||
for(int j = 0; j < numRoomsOverview; j++) {
|
||||
|
||||
if( channelstoPrint[j].participants.length > 0 && !channelstoPrint[j].participants.contains(userPublicKey)) {
|
||||
//print(channelstoPrint[j].participants);
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !selector(channelstoPrint[j]) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = "";
|
||||
if( channelstoPrint[j].chatRoomName == "") {
|
||||
//print("channel has no name");
|
||||
@ -1378,7 +1357,7 @@ class Store {
|
||||
|
||||
int numMessages = channelstoPrint[j].getNumValidMessages();
|
||||
stdout.write("${name} ${getNumSpaces(32-name.length)} $numMessages${getNumSpaces(12- numMessages.toString().length)}");
|
||||
numChannelsActuallyPrinted ++;
|
||||
numChannelsActuallyPrinted++;
|
||||
List<String> messageIds = channelstoPrint[j].messageIds;
|
||||
for( int i = messageIds.length - 1; i >= 0; i--) {
|
||||
if( allChildEventsMap.containsKey(messageIds[i])) {
|
||||
@ -1393,6 +1372,10 @@ class Store {
|
||||
}
|
||||
print("");
|
||||
}
|
||||
|
||||
print("");
|
||||
print("Showing $numChannelsActuallyPrinted channels\n");
|
||||
|
||||
return numChannelsActuallyPrinted;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ homepage: https://github.com/vishalxl/nostr_console
|
||||
# damus reactions
|
||||
# random seed
|
||||
# printed info
|
||||
#improved
|
||||
|
||||
environment:
|
||||
sdk: '>=2.17.3 <3.0.0'
|
||||
|
Loading…
x
Reference in New Issue
Block a user