Merge pull request #47 from radixrat/sort_userprofile

add sort to userprofile, makes it easier to view
This commit is contained in:
Vishal 2022-12-25 11:06:27 +05:30 committed by GitHub
commit f924ede1ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View File

@ -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("");

View File

@ -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) {

View File

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