From 2edf5bb361c8b8e81ee4acf53fbefddcde910f6a Mon Sep 17 00:00:00 2001 From: Vishal <64505169+vishalxl@users.noreply.github.com> Date: Wed, 28 Dec 2022 21:18:49 +0530 Subject: [PATCH] added some unused code for isRelevant logic in writing to file --- lib/tree_ds.dart | 15 +++++++++++++++ lib/user.dart | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/lib/tree_ds.dart b/lib/tree_ds.dart index 72d4a26..c7a13e6 100644 --- a/lib/tree_ds.dart +++ b/lib/tree_ds.dart @@ -2046,6 +2046,16 @@ class Store { return room; } + + // TODO to be finished + bool isRelevant(Tree tree) { + //Set contacts = getContactList(userPublicKey); + //contacts = contacts.union(gDefaultFollows); + + + return true; + } + // Write the tree's events to file as one event's json per line Future writeEventsToFile(String filename) async { if( gDebug > 0) print("opening $filename to write to."); @@ -2083,6 +2093,11 @@ class Store { continue; } + if( !isRelevant(tree)) { + continue; + } + + String temp = tree.event.originalJson.trim(); String line = "${temp}\n"; nLinesStr += line; diff --git a/lib/user.dart b/lib/user.dart index 4de9567..80e9e84 100644 --- a/lib/user.dart +++ b/lib/user.dart @@ -92,4 +92,23 @@ Set getOnlyUserEvents(Set initialEvents, String userPubkey) { } }); return userEvents; +} + + +Set getContactList(String pubkey) { + Set contacts = {}; + + if( pubkey != "") { + // get the latest kind 3 event for the user, which has the 'follows' list + Event? contactEvent = getContactEvent(userPublicKey); + + // if contact list was found, get user's feed; also get some default contacts + if (contactEvent != null ) { + contactEvent.eventData.contactList.forEach((contact) { + contacts.add(contact.contactPubkey); + }); + } else { + } + } + return contacts; } \ No newline at end of file