From dd6c36152691bc44e101ba5aff4735587b75b186 Mon Sep 17 00:00:00 2001 From: Vishal <64505169+vishalxl@users.noreply.github.com> Date: Mon, 14 Nov 2022 01:08:13 +0530 Subject: [PATCH] added clear screen to encrypted group menu --- lib/console_ui.dart | 28 ++++++++++++++++++++++------ pubspec.yaml | 1 + 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/console_ui.dart b/lib/console_ui.dart index e80694c..4111ed3 100644 --- a/lib/console_ui.dart +++ b/lib/console_ui.dart @@ -793,6 +793,7 @@ Future channelMenuUI(Store node) async { break; case 2: + clearScreen(); printInColor(" All Public Channels ", gCommentColor); node.printChannelsOverview(node.channels, node.channels.length, selectorShowAllRooms); justShowedChannels = true; @@ -840,7 +841,8 @@ Future createEncryptedChannel(Store node) async { EventData eventData = EventData('id', userPublicKey, createdAt, 140, content, [], [], [], [], {}, ); Event encryptedChannelCreateEvent = Event("EVENT", "id", eventData, [], ""); String newEncryptedChannelId = await sendEventWithTags(node, encryptedChannelCreateEvent, pTags); // takes 400 ms - print("Created new encrypted channel with id: $newEncryptedChannelId"); + clearScreen(); + print("Created new encrypted channel with id: $newEncryptedChannelId\n"); String newPriKey = getRandomPrivKey(); @@ -990,9 +992,16 @@ Future encryptedChannelMenuUI(Store node) async { if( channelId == "x") { showChannelOption = false; } + bool firstIteration = true; int pageNum = 1; while(showChannelOption) { reAdjustAlignment(); + + if( firstIteration) { + clearScreen(); + firstIteration = false; + } + String fullChannelId = node.showChannel(node.encryptedChannels, channelId, pageNum); if( fullChannelId == "") { //print("Could not find the given channel."); @@ -1000,6 +1009,8 @@ Future encryptedChannelMenuUI(Store node) async { break; } + + stdout.write("\nType message; or type 'x' to exit, or press to refresh: "); $tempUserInput = stdin.readLineSync(encoding: utf8); String messageToSend = $tempUserInput??""; @@ -1041,18 +1052,21 @@ Future encryptedChannelMenuUI(Store node) async { } else { print("Refreshing..."); } - + clearScreen(); await processAnyIncomingEvents(node, false); - } + } // end while showChennelOption ( showing each page) break; case 2: + clearScreen(); printInColor(" All Encrypted Channels ", gCommentColor); node.printChannelsOverview(node.encryptedChannels, node.encryptedChannels.length, selectorShowAllRooms); justShowedChannels = true; break; case 3: + clearScreen(); + print("Creating new encrypted channel. Kindly enter info about channel: \n"); await createEncryptedChannel(node); justShowedChannels = false; break; @@ -1170,11 +1184,13 @@ void showInitialNotifications(Store node) { Future mainMenuUi(Store node) async { + clearScreen(); + //Show only notifications showInitialNotifications(node); - bool userContinue = true; - while(userContinue) { + bool mainMenuContinue = true; + while(mainMenuContinue) { await processAnyIncomingEvents(node); // this takes 300 ms @@ -1252,7 +1268,7 @@ Future mainMenuUi(Store node) async { case 7: default: - userContinue = false; + mainMenuContinue = false; String authorName = getAuthorName(userPublicKey); print("\nFinished Nostr session for user with name and public key: ${authorName} ($userPublicKey)"); if( gEventsFilename != "") { diff --git a/pubspec.yaml b/pubspec.yaml index d15f164..8484ede 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,6 +10,7 @@ homepage: https://github.com/vishalxl/nostr_console # clear screen for public channels + # improved howto messages # removed red error for default invokation related to invalid old encrypted group keys +# more clear screen environment: sdk: '>=2.17.3 <3.0.0'