improved notifications in menu 2->3

This commit is contained in:
Vishal 2022-12-26 12:12:50 +05:30
parent b2475dd9d0
commit a865b5c1c6
4 changed files with 19 additions and 3 deletions

View File

@ -48,8 +48,20 @@ Map<String, UserNameInfo> gKindONames = {};
// global reactions entry. Map of form <id of event reacted to, List of Reactors>
// 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<List<String>> > gReactions = {};
// for the given eventID returns the pubkeys of reactors
Set<String> getReactorPubkeys(String eventId) {
Set<String> reactorIds = {};
List<List<String>>? 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<List<String>> tags;
bool isNotification; // whether its to be highlighted using highlight color
String evaluatedContent; // content which has mentions expanded, and which has been translated
Set<String> newLikes; // used for notifications, are colored as notifications and then reset
Set<String> newLikes; // used for notifications, are colored as notifications and then reset ; set of pubkeys that are new likers
List<Contact> contactList = []; // used for kind:3 events, which is contact list event

View File

@ -177,6 +177,7 @@ int gMenuWidth = 36;
int gNameLenDisplayed = 12;
String gValidCheckMark = "✔️";
List<String> gCheckMarksToRemove = ["","✔️"];
bool gShowLnInvoicesAsQr = false;
const int gMinWidthForLnQr = 140;

View File

@ -483,8 +483,9 @@ class Tree {
List<List<String>>? 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<String> reactorPubkeys = getReactorPubkeys(event.eventData.id);
event.eventData.newLikes = reactorPubkeys;
}
}
}

View File

@ -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.