mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-04-25 07:50:54 +02:00
Merge pull request #47 from radixrat/sort_userprofile
add sort to userprofile, makes it easier to view
This commit is contained in:
commit
f924ede1ad
@ -345,6 +345,7 @@ void printProfile(Store node, String profilePubkey) {
|
||||
|
||||
// print follow list
|
||||
stdout.write("$pronoun follow ${profileContactEvent.eventData.contactList.length} accounts: ");
|
||||
profileContactEvent.eventData.contactList.sort();
|
||||
profileContactEvent.eventData.contactList.forEach((x) => stdout.write("${getAuthorName(x.id, 0)}, "));
|
||||
print("\n");
|
||||
}
|
||||
@ -352,6 +353,7 @@ void printProfile(Store node, String profilePubkey) {
|
||||
// print followers
|
||||
List<String> followers = node.getFollowers(profilePubkey);
|
||||
stdout.write("$pronoun have ${followers.length} followers: ");
|
||||
followers.sort((a, b) => getAuthorName(a).compareTo(getAuthorName(b)));
|
||||
followers.forEach((x) => stdout.write("${getAuthorName(x, 0)}, "));
|
||||
print("");
|
||||
print("");
|
||||
|
@ -1377,7 +1377,7 @@ List getLineWithMaxLen(String s, int startIndex, int lenPerLine, String spacesSt
|
||||
|
||||
|
||||
// The contact only stores id and relay of contact. The actual name is stored in a global variable/map
|
||||
class Contact {
|
||||
class Contact implements Comparable<Contact> {
|
||||
String id, relay;
|
||||
Contact(this.id, this.relay);
|
||||
|
||||
@ -1385,7 +1385,11 @@ class Contact {
|
||||
String toString() {
|
||||
return 'id: $id ( ${getAuthorName(id)}) relay: $relay';
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int compareTo(Contact other) {
|
||||
return getAuthorName(id).compareTo(getAuthorName(other.id));
|
||||
}
|
||||
}
|
||||
|
||||
String getShaId(String pubkey, String createdAt, String kind, String strTags, String content) {
|
||||
|
@ -2243,6 +2243,7 @@ class Store {
|
||||
|
||||
if( selfContactEvent != null) {
|
||||
List<Contact> selfContacts = selfContactEvent.eventData.contactList;
|
||||
selfContacts.sort();
|
||||
selfNumContacts = selfContacts.length;
|
||||
for(int i = 0; i < selfContacts.length; i ++) {
|
||||
// check if you follow the other account
|
||||
|
Loading…
x
Reference in New Issue
Block a user