mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-07-26 03:52:14 +02:00
improved channel and DM display and added menu info
This commit is contained in:
@@ -120,6 +120,12 @@ Future<void> sendDirectMessage(Store node, String otherPubkey, String messageToS
|
|||||||
String eventStrToSend = '["EVENT",{"id":"$id","pubkey":"$userPublicKey","created_at":$createdAt,"kind":$replyKind,"tags":[$strTags],"content":"$encryptedMessageToSend","sig":"$sig"}]';
|
String eventStrToSend = '["EVENT",{"id":"$id","pubkey":"$userPublicKey","created_at":$createdAt,"kind":$replyKind,"tags":[$strTags],"content":"$encryptedMessageToSend","sig":"$sig"}]';
|
||||||
|
|
||||||
sendRequest( gListRelayUrls1, eventStrToSend);
|
sendRequest( gListRelayUrls1, eventStrToSend);
|
||||||
|
|
||||||
|
Future<void> foo() async {
|
||||||
|
await Future.delayed(Duration(milliseconds: 300));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await foo();
|
||||||
}
|
}
|
||||||
|
|
||||||
// sends event e; used to send kind 3 event; can send other kinds too like channel create kind 40
|
// sends event e; used to send kind 3 event; can send other kinds too like channel create kind 40
|
||||||
@@ -294,7 +300,12 @@ void printProfile(Store node, String profilePubkey) {
|
|||||||
print("");
|
print("");
|
||||||
}
|
}
|
||||||
|
|
||||||
int showMenu(List<String> menuOptions, String menuName) {
|
int showMenu(List<String> menuOptions, String menuName, [String menuInfo = ""]) {
|
||||||
|
|
||||||
|
if(menuInfo.length > 0) {
|
||||||
|
print("\n$menuInfo\n");
|
||||||
|
}
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
print("\n$menuName\n${getNumDashes(menuName.length)}");
|
print("\n$menuName\n${getNumDashes(menuName.length)}");
|
||||||
print('Pick an option:');
|
print('Pick an option:');
|
||||||
@@ -329,7 +340,7 @@ int showMenu(List<String> menuOptions, String menuName) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> otherMenuUi(Store node) async {
|
Future<void> otherOptionsMenuUi(Store node) async {
|
||||||
bool continueOtherMenu = true;
|
bool continueOtherMenu = true;
|
||||||
while(continueOtherMenu) {
|
while(continueOtherMenu) {
|
||||||
|
|
||||||
@@ -347,7 +358,7 @@ Future<void> otherMenuUi(Store node) async {
|
|||||||
'E(x)it to main menu'], // 10
|
'E(x)it to main menu'], // 10
|
||||||
|
|
||||||
|
|
||||||
"Other Menu"); // menu name
|
"Other Options Menu"); // menu name
|
||||||
print('You picked: $option');
|
print('You picked: $option');
|
||||||
switch(option) {
|
switch(option) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -589,15 +600,18 @@ Future<void> channelMenuUI(Store node) async {
|
|||||||
|
|
||||||
//await processNotifications(node); // this takes 300 ms
|
//await processNotifications(node); // this takes 300 ms
|
||||||
if( !justShowedChannels) {
|
if( !justShowedChannels) {
|
||||||
|
printInColor(" Public Channels ", gCommentColor);
|
||||||
node.printChannelsOverview(node.channels, 20, selectorShowAllRooms);
|
node.printChannelsOverview(node.channels, 20, selectorShowAllRooms);
|
||||||
justShowedChannels = true;
|
justShowedChannels = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String menuInfo = "Public channel howto: To enter a channel, enter first few letters of its name or the channel identifier. When in a channel, press 'x' to exit.";
|
||||||
int option = showMenu([ 'Enter a public channel', // 1
|
int option = showMenu([ 'Enter a public channel', // 1
|
||||||
'Show all public channels', // 2
|
'Show all public channels', // 2
|
||||||
'Create channel', // 3
|
'Create channel', // 3
|
||||||
'E(x)it to main menu'], // 4
|
'E(x)it to main menu'], // 4
|
||||||
"Public Channels Menu"); // name of menu
|
"Public Channels Menu", // name of menu
|
||||||
|
menuInfo);
|
||||||
print('You picked: $option');
|
print('You picked: $option');
|
||||||
switch(option) {
|
switch(option) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -653,6 +667,7 @@ Future<void> channelMenuUI(Store node) async {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
printInColor(" All Public Channels ", gCommentColor);
|
||||||
node.printChannelsOverview(node.channels, node.channels.length, selectorShowAllRooms);
|
node.printChannelsOverview(node.channels, node.channels.length, selectorShowAllRooms);
|
||||||
justShowedChannels = true;
|
justShowedChannels = true;
|
||||||
break;
|
break;
|
||||||
@@ -815,19 +830,22 @@ Future<void> encryptedChannelMenuUI(Store node) async {
|
|||||||
|
|
||||||
bool justShowedChannels = false;
|
bool justShowedChannels = false;
|
||||||
while(continueChatMenu) {
|
while(continueChatMenu) {
|
||||||
await processAnyIncomingEvents(node); // this takes 300 ms
|
await processAnyIncomingEvents(node, false); // this takes 300 ms
|
||||||
|
|
||||||
if( !justShowedChannels) {
|
if( !justShowedChannels) {
|
||||||
|
printInColor(" Encrypted Channels ", gCommentColor);
|
||||||
node.printChannelsOverview(node.encryptedChannels, 20, selectorShowAllRooms);
|
node.printChannelsOverview(node.encryptedChannels, 20, selectorShowAllRooms);
|
||||||
justShowedChannels = true;
|
justShowedChannels = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
print("\nEncrypted Channel howto in short: Create a channel, and then enter the channel, and then add new participants by typing '/add <64 byte hex public key of new participant>' and then pressing enter. This will add them to the group.\n");
|
String menuInfo = "Encrypted Channel howto: Create a channel, and then enter the channel, and then add new participants by typing '/add <64 byte hex public key of new participant>' and then pressing enter. This will add them to the group. When you have been invited to a channel, it will be shown in list, and you can enter that channel by typing its first few letters of name or identifier.";
|
||||||
int option = showMenu([ 'Enter a encrypted channel', // 1
|
|
||||||
|
int option = showMenu([ 'Enter an encrypted channel', // 1
|
||||||
'Show all encrypted channels', // 2
|
'Show all encrypted channels', // 2
|
||||||
'Create encrypted channel', // 3
|
'Create encrypted channel', // 3
|
||||||
'E(x)it to main menu'], // 4
|
'E(x)it to main menu'], // 4
|
||||||
"Encrypted Channels Menu"); // name of menu
|
"Encrypted Channels Menu", // name of menu
|
||||||
|
menuInfo);
|
||||||
print('You picked: $option');
|
print('You picked: $option');
|
||||||
switch(option) {
|
switch(option) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -898,6 +916,7 @@ Future<void> encryptedChannelMenuUI(Store node) async {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
printInColor(" All Encrypted Channels ", gCommentColor);
|
||||||
node.printChannelsOverview(node.encryptedChannels, node.encryptedChannels.length, selectorShowAllRooms);
|
node.printChannelsOverview(node.encryptedChannels, node.encryptedChannels.length, selectorShowAllRooms);
|
||||||
justShowedChannels = true;
|
justShowedChannels = true;
|
||||||
break;
|
break;
|
||||||
@@ -922,15 +941,17 @@ Future<void> encryptedChannelMenuUI(Store node) async {
|
|||||||
Future<void> PrivateMenuUI(Store node) async {
|
Future<void> PrivateMenuUI(Store node) async {
|
||||||
bool continueChatMenu = true;
|
bool continueChatMenu = true;
|
||||||
while(continueChatMenu) {
|
while(continueChatMenu) {
|
||||||
|
|
||||||
await processAnyIncomingEvents(node, true); // this takes 300 ms
|
await processAnyIncomingEvents(node, true); // this takes 300 ms
|
||||||
|
|
||||||
|
printInColor(" Direct Messages", gCommentColor);
|
||||||
node.printDirectRoomInfo(showAllRooms);
|
node.printDirectRoomInfo(showAllRooms);
|
||||||
|
|
||||||
|
String menuInfo = "Direct Message howto: To send a DM to someone for the first time, enter their 64 byte hex pubkey. To enter conversation seen in overview, enter the first few letters of the other person's name, or their pubkey";
|
||||||
int option = showMenu([
|
int option = showMenu([
|
||||||
'Reply or Send a direct message',
|
'Reply or Send a direct message',
|
||||||
'E(x)it to main menu'], // 3
|
'E(x)it to main menu'], // 3
|
||||||
"Private Message Menu"); // name of menu
|
"Direct Message Menu", // name of menu
|
||||||
|
menuInfo);
|
||||||
print('You picked: $option');
|
print('You picked: $option');
|
||||||
switch(option) {
|
switch(option) {
|
||||||
|
|
||||||
@@ -1086,7 +1107,7 @@ Future<void> mainMenuUi(Store node) async {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
await otherMenuUi(node);
|
await otherOptionsMenuUi(node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
|
@@ -1335,6 +1335,7 @@ class Store {
|
|||||||
channelstoPrint.sort(scrollableCompareTo);
|
channelstoPrint.sort(scrollableCompareTo);
|
||||||
int numChannelsActuallyPrinted = 0;
|
int numChannelsActuallyPrinted = 0;
|
||||||
|
|
||||||
|
print("\n\n");
|
||||||
printUnderlined(" Channel Name Num of Messages Latest Message ");
|
printUnderlined(" Channel Name Num of Messages Latest Message ");
|
||||||
for(int j = 0; j < numRoomsOverview; j++) {
|
for(int j = 0; j < numRoomsOverview; j++) {
|
||||||
|
|
||||||
@@ -1497,7 +1498,7 @@ class Store {
|
|||||||
|
|
||||||
int numRoomsActuallyPrinted = 0;
|
int numRoomsActuallyPrinted = 0;
|
||||||
stdout.write("\n");
|
stdout.write("\n");
|
||||||
stdout.write("Direct messages inbox:\n");
|
//stdout.write("Direct messages inbox:\n");
|
||||||
stdout.write("\n\n");
|
stdout.write("\n\n");
|
||||||
|
|
||||||
printUnderlined(" From Num of Messages Latest Message ");
|
printUnderlined(" From Num of Messages Latest Message ");
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
name: nostr_console
|
name: nostr_console
|
||||||
description: A multi-platform nostr client built for terminal/console.
|
description: A multi-platform nostr client built for terminal/console.
|
||||||
version: 0.0.9-beta
|
version: 0.1.0-beta
|
||||||
homepage: https://github.com/vishalxl/nostr_console
|
homepage: https://github.com/vishalxl/nostr_console
|
||||||
|
|
||||||
# Release 0.0.9 - encrypted channels; fixes
|
# Release 0.1.0-beta - encrypted channels; fixes
|
||||||
# improved fetching of events. and display for channels.
|
# improved fetching of events. and display for channels.
|
||||||
# damus reactions
|
# damus reactions
|
||||||
# random seed
|
# random seed
|
||||||
# printed info
|
# printed info
|
||||||
#improved
|
# added delay
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.17.3 <3.0.0'
|
sdk: '>=2.17.3 <3.0.0'
|
||||||
|
Reference in New Issue
Block a user