From 2d070cc8ceb67d685fe131a3c1e7e7ec5d1f0ca2 Mon Sep 17 00:00:00 2001 From: Vishal <64505169+vishalxl@users.noreply.github.com> Date: Sat, 3 Sep 2022 21:18:50 +0530 Subject: [PATCH] support for delete and hiding, fixed and new code --- README.md | 6 +- lib/console_ui.dart | 3 + lib/event_ds.dart | 69 ++++++++++------- lib/tree_ds.dart | 175 +++++++++++++++++++++++++------------------- 4 files changed, 150 insertions(+), 103 deletions(-) diff --git a/README.md b/README.md index 8dfbc24..0dd26dc 100644 --- a/README.md +++ b/README.md @@ -81,8 +81,8 @@ nostr_console.exe --file=eventsFile.txt --prikey=K ![Showing Tree with re-shifting to left](https://pbs.twimg.com/media/Fao3E1bUUAAIti1?format=png&name=4096x4096) showing re-alignment of threads for easier reading. +# Contact + +[Nostr Telegram Channel](https://t.me/nostr_protocol) or at Nostr Pulic Channel 52cab2e3e504ad6447d284b85b5cc601ca0613b151641e77facfec851c2ca816 - - - diff --git a/lib/console_ui.dart b/lib/console_ui.dart index 5e3a5ef..fe9545f 100644 --- a/lib/console_ui.dart +++ b/lib/console_ui.dart @@ -673,6 +673,9 @@ Future mainMenuUi(Store node) async { if( content == "+") { print("Sending a like to given post."); replyKind = "7"; + } else if( content == "!") { + print("Hiding the given post."); + replyKind = "7"; } await sendReplyPostLike(node, replyToId, replyKind, content); diff --git a/lib/event_ds.dart b/lib/event_ds.dart index 14265bc..6848153 100644 --- a/lib/event_ds.dart +++ b/lib/event_ds.dart @@ -50,7 +50,7 @@ class EventData { int createdAt; int kind; String content; - List eTagsRest;// rest of e tags + List eTags;// rest of e tags List pTags;// list of p tags for kind:1 List> tags; bool isNotification; // whether its to be highlighted using highlight color @@ -63,13 +63,13 @@ class EventData { bool isDeleted; // deleted by kind 5 event String getParent() { - if( eTagsRest.isNotEmpty) { - return eTagsRest[eTagsRest.length - 1]; + if( eTags.isNotEmpty) { + return eTags[eTags.length - 1]; } return ""; } - EventData(this.id, this.pubkey, this.createdAt, this.kind, this.content, this.eTagsRest, this.pTags, + EventData(this.id, this.pubkey, this.createdAt, this.kind, this.content, this.eTags, this.pTags, this.contactList, this.tags, this.newLikes, {this.isNotification = false, this.evaluatedContent = "", this.isHidden = false, this.isDeleted = false}); factory EventData.fromJson(dynamic json) { @@ -205,19 +205,15 @@ class EventData { if(!isUserDirectMessage(this)) { break; } - //print("in translateAndExpandMentions() for a dm \npubkey = $pubkey \ncontent = $content"); - //print("tags = $tags\n"); int ivIndex = content.indexOf("?iv="); var enc_str = content.substring(0, ivIndex); var iv = content.substring( ivIndex + 4, content.length); - //print("enc_str = $enc_str ; iv = $iv"); String userKey = userPrivateKey ; String otherUserPubKey = "02" + pubkey; if( pubkey == userPublicKey) { userKey = userPrivateKey; otherUserPubKey = "02" + pubkey; - //iv = ""; } var decryptd = myPrivateDecrypt( userKey, otherUserPubKey, enc_str, iv); // use bob's privatekey and alic's publickey means bob can read message from alic evaluatedContent = decryptd; @@ -236,28 +232,41 @@ class EventData { // prints event data in the format that allows it to be shown in tree form by the Tree class void printEventData(int depth) { - if( id == gCheckEventId) { - if(gDebug > 0) { - print("In Event printEventData: got message: $gCheckEventId"); - isNotification = true; - } + if( !(kind == 1 || kind == 4 || kind == 42)) { + return; // only print kind 1 and 42 and 4 } int n = 4; String maxN(String v) => v.length > n? v.substring(0,n) : v.substring(0, v.length); void printInColor(String s, String commentColor) => stdout.supportsAnsiEscapes ?stdout.write("$commentColor$s$gColorEndMarker"):stdout.write(s); - + + String name = getAuthorName(pubkey); String strDate = getPrintableDate(createdAt); + String tempEvaluatedContent = evaluatedContent; + String tempContent = content; + + if( isHidden) { + name = ""; + strDate = ""; + tempEvaluatedContent = tempContent = "