mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-06-01 18:49:29 +02:00
made treeSelectorRepliesAndLikes more generic
which can be invoked with set of pubkeys. to be used with follows too.
This commit is contained in:
parent
fe131ecc89
commit
b6144c1bf4
@ -16,12 +16,12 @@ This is an experimental or pre-alpha software made to show or know what a Nostr
|
||||
* [ ] fix --help that's dated
|
||||
* [x] show lightning invoice as qr code
|
||||
* [ ] in mention expansion, if p tag is not found in user store, then its left as #[n], whereas it should be replaced by the pubkey
|
||||
* [ ] notifications should show mentions too ( it does not yet)
|
||||
* [x] notifications should show mentions too ( it does not yet)
|
||||
* [x] notifications , option 3, is shown only for one entry in whole thread
|
||||
* [ ] hashtag regexp should have underscore
|
||||
* [x] add more default users. improve who is fetched.
|
||||
* [ ] after going to a dm room, screen doesn't clear
|
||||
* [ ] when seeing a profile, if they have liked something, then likes after their name are shown white
|
||||
* [x] when seeing a profile, if they have liked something, then likes after their name are shown white
|
||||
* [ ] kind 7 tags are messed up. for example for reaction: 066cdb716e250069c4078565c9d9046af483c43bbd8497aad9c60d41ec462034 and 137289198ff1c57a14711d87b059e5fc5f9b11b257672503595ac31bad450a22
|
||||
* [ ] A F for friend or follow should be shown after each name that's a follow of the logged in user. F1 if the name is follow of a follow, and F2 if next level.
|
||||
* [ ] allow special character input, and 256 limit [info](https://www.reddit.com/r/dartlang/comments/xcdsyx/i_am_seeing_that_stdinreadlinesync_returns_only/)
|
||||
|
@ -1283,7 +1283,7 @@ Future<void> socialMenuUi(Store node) async {
|
||||
|
||||
case 3:
|
||||
clearScreen();
|
||||
bool selectorTrees_userNotifications (Tree t) => t.treeSelectorRepliesAndLikes(userPublicKey);
|
||||
bool selectorTrees_userNotifications (Tree t) => t.treeSelectorRepliesAndLikes({userPublicKey});
|
||||
int notificationHours = gHoursDefaultPrint>24? gHoursDefaultPrint: 24; // minimum 24
|
||||
Point numPrinted = node.printTree(0, DateTime.now().subtract(Duration(hours:notificationHours)), selectorTrees_userNotifications);
|
||||
if( numPrinted.y > 0) {
|
||||
|
@ -488,46 +488,48 @@ class Tree {
|
||||
}
|
||||
}
|
||||
|
||||
// returns true if the treee or its children has a reply or like for the user with public key pk; and notification flags are set for such events
|
||||
// returns true if the tree or its children has a reply or like for the user with public key pk; and notification flags are set for such events
|
||||
// only new controls whether replies/likes recieved are ignored if the user has already
|
||||
bool treeSelectorRepliesAndLikes(String pubkey, [bool onlyNew = false]) {
|
||||
bool treeSelectorRepliesAndLikes(Set<String> pubkeys, [bool onlyNew = false]) {
|
||||
bool hasReaction = false;
|
||||
bool childMatches = false;
|
||||
bool isMentioned = false;
|
||||
|
||||
// check if there are any likes to this event if its user's event
|
||||
if( event.eventData.pubkey == pubkey && gReactions.containsKey(event.eventData.id)) {
|
||||
if( pubkeys.contains(event.eventData.pubkey) && gReactions.containsKey(event.eventData.id)) {
|
||||
List<List<String>>? reactions = gReactions[event.eventData.id];
|
||||
if( reactions != null) {
|
||||
if( reactions.length > 0) {
|
||||
// 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;
|
||||
hasReaction = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if any of the users has been tagged in this event
|
||||
List<String> pTags = event.eventData.pTags;
|
||||
Set<String> pplTagged = pTags.toSet().intersection(pubkeys);
|
||||
|
||||
// check if user has been tagged in this event
|
||||
if( event.eventData.pubkey != pubkey) {
|
||||
List<String> pTags = event.eventData.pTags;
|
||||
if( pTags.contains(pubkey)) {
|
||||
isMentioned = true;
|
||||
}
|
||||
// 2nd condition: person making the event should not be on this list; they would already be considered in other test
|
||||
if( pplTagged.length > 0 && !pubkeys.contains(event.eventData.pubkey)) {
|
||||
event.eventData.isNotification = isMentioned = true;
|
||||
}
|
||||
|
||||
// check if there are any replies from other people to this event
|
||||
if( event.eventData.pubkey == pubkey && children.length > 0) {
|
||||
// check if there are any replies from other people to an event made by someone in list
|
||||
if( pubkeys.contains(event.eventData.pubkey) && children.length > 0) {
|
||||
for( int i = 0; i < children.length; i++ ) {
|
||||
children.forEach((child) {
|
||||
// if child is someone else then set notifications and flag, means there are replies to this event
|
||||
childMatches = child.event.eventData.isNotification = ((child.event.eventData.pubkey != pubkey)? true: false) ;
|
||||
if(child.event.eventData.pubkey != event.eventData.pubkey ) // tests reply is not from same user
|
||||
childMatches = child.event.eventData.isNotification = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for( int i = 0; i < children.length; i++ ) {
|
||||
if( children[i].treeSelectorRepliesAndLikes(pubkey)) {
|
||||
if( children[i].treeSelectorRepliesAndLikes(pubkeys)) {
|
||||
childMatches = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user