From a865b5c1c628b21206619a9ef9a8ef5f1f90435f Mon Sep 17 00:00:00 2001 From: Vishal <64505169+vishalxl@users.noreply.github.com> Date: Mon, 26 Dec 2022 12:12:50 +0530 Subject: [PATCH] improved notifications in menu 2->3 --- lib/event_ds.dart | 14 +++++++++++++- lib/settings.dart | 1 + lib/tree_ds.dart | 5 +++-- pubspec.yaml | 2 ++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/event_ds.dart b/lib/event_ds.dart index 9c537d6..4460192 100644 --- a/lib/event_ds.dart +++ b/lib/event_ds.dart @@ -48,8 +48,20 @@ Map gKindONames = {}; // global reactions entry. Map of form // reach Reactor is a list of 2-elements ( first is pubkey of reactor event, second is comment) +// each eventID -> multiple [ pubkey, comment ] Map< String, List> > gReactions = {}; +// for the given eventID returns the pubkeys of reactors +Set getReactorPubkeys(String eventId) { + Set reactorIds = {}; + List>? reactions = gReactions[eventId]; + + if( reactions != null) { + reactions.forEach((reaction) { reactorIds.add(reaction[0]);}); + } + + return reactorIds; +} // global contact list of each user, including of the logged in user. // maps from pubkey of a user, to the latest contact list of that user, which is the latest kind 3 message // is updated as kind 3 events are received @@ -103,7 +115,7 @@ class EventData { List> tags; bool isNotification; // whether its to be highlighted using highlight color String evaluatedContent; // content which has mentions expanded, and which has been translated - Set newLikes; // used for notifications, are colored as notifications and then reset + Set newLikes; // used for notifications, are colored as notifications and then reset ; set of pubkeys that are new likers List contactList = []; // used for kind:3 events, which is contact list event diff --git a/lib/settings.dart b/lib/settings.dart index 38a5be4..2c8f855 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -177,6 +177,7 @@ int gMenuWidth = 36; int gNameLenDisplayed = 12; String gValidCheckMark = "✔️"; +List gCheckMarksToRemove = ["✅","✔️"]; bool gShowLnInvoicesAsQr = false; const int gMinWidthForLnQr = 140; diff --git a/lib/tree_ds.dart b/lib/tree_ds.dart index dd3cbe3..c6d2f61 100644 --- a/lib/tree_ds.dart +++ b/lib/tree_ds.dart @@ -483,8 +483,9 @@ class Tree { List>? reactions = gReactions[event.eventData.id]; if( reactions != null) { if( reactions.length > 0) { - event.eventData.isNotification = true; - return true; + // set every reaction as a new like so they all get highlighted; these are all later reset after first printing + Set reactorPubkeys = getReactorPubkeys(event.eventData.id); + event.eventData.newLikes = reactorPubkeys; } } } diff --git a/pubspec.yaml b/pubspec.yaml index 2f1579b..926313e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,6 +3,8 @@ description: A multi-platform nostr client built for terminal/console version: 0.3.0-beta homepage: https://github.com/vishalxl/nostr_console +# improved user notifications , menu 2 -> 3, now likes are shown as notifications and less informative + # 0.3.0 # added check marks; added more default users # changed fetch logic: after fetching all friends contacts etc, then reset the relays, and fetched ALL the events in last 2 hours. but not closing connection right now of old relays.