mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-03-29 11:11:43 +01:00
improved channel list printing
This commit is contained in:
parent
c638e33b78
commit
418c3e6b7a
@ -293,7 +293,7 @@ Future<void> otherMenuUi(Tree node, var contactList) async {
|
||||
return;
|
||||
}
|
||||
|
||||
Future<void> chatMenuUi(Tree node, var contactList) async {
|
||||
Future<void> channelMenuUI(Tree node, var contactList) async {
|
||||
gDebug = 0;
|
||||
bool continueChatMenu = true;
|
||||
while(continueChatMenu) {
|
||||
@ -426,7 +426,7 @@ Future<void> mainMenuUi(Tree node, var contactList) async {
|
||||
break;
|
||||
|
||||
case 3:
|
||||
await chatMenuUi(node, contactList);
|
||||
await channelMenuUI(node, contactList);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
|
@ -332,6 +332,14 @@ class EventData {
|
||||
}
|
||||
}
|
||||
|
||||
String getAsLine({int len = 20}) {
|
||||
if( len == 0 || len > content.length) {
|
||||
len = content.length;
|
||||
}
|
||||
|
||||
return '"${content.substring(0, len)}..." - ${getAuthorName(pubkey)}';
|
||||
}
|
||||
|
||||
// looks up global map of reactions, if this event has any reactions, and then prints the reactions
|
||||
// in appropriate color( in case one is a notification, which is stored in member variable)
|
||||
void printReaction(int depth) {
|
||||
|
@ -391,33 +391,38 @@ class Tree {
|
||||
}
|
||||
|
||||
void printAllChannelsInfo() {
|
||||
print("\n\nChat Rooms:");
|
||||
print("\n\nChannels/Rooms:");
|
||||
|
||||
|
||||
printUnderlined(" Channel/Room Name Num of Messages Latest Message ");
|
||||
//print("");
|
||||
|
||||
chatRooms.forEach((key, value) {
|
||||
String name = "";
|
||||
if( value.name == "") {
|
||||
name = value.chatRoomId;
|
||||
name = value.chatRoomId.substring(0, 6);
|
||||
} else {
|
||||
name = value.name;
|
||||
name = "${value.name} ( ${value.chatRoomId.substring(0, 6)})";
|
||||
}
|
||||
|
||||
int numMessages = value.messageIds.length;
|
||||
|
||||
print("-----------$name---------");
|
||||
print("Total number of messages: $numMessages");
|
||||
stdout.write("${name} ${getNumSpaces(32-name.length)} $numMessages${getNumSpaces(12- numMessages.toString().length)}");
|
||||
|
||||
List<String> messageIds = value.messageIds;
|
||||
for( int i = messageIds.length - 1; i >= 0; i++) {
|
||||
if( allChildEventsMap.containsKey(messageIds[i])) {
|
||||
Event? e = allChildEventsMap[messageIds[i]]?.e;
|
||||
if( e!= null) {
|
||||
e.printEvent(0);
|
||||
print("");
|
||||
//e.printEvent(0);
|
||||
stdout.write("${e.eventData.getAsLine()}");
|
||||
break; // print only one event, the latest one
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
print("\n\n");
|
||||
print("");
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user