From dd1ae911e668fb41bb2d8de048f90019547dbaa3 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Wed, 15 Mar 2023 22:32:44 +0200 Subject: [PATCH] . --- src/js/components/SearchBox.tsx | 21 +++++++++------------ src/js/nostr/Events.ts | 1 - src/js/nostr/Session.ts | 2 +- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/js/components/SearchBox.tsx b/src/js/components/SearchBox.tsx index 17a5d1ab..339b6cf7 100644 --- a/src/js/components/SearchBox.tsx +++ b/src/js/components/SearchBox.tsx @@ -11,6 +11,7 @@ import { translate as t } from '../translations/Translation'; import Identicon from './Identicon'; import Name from './Name'; import SafeImg from './SafeImg'; +import SocialNetwork from '../nostr/SocialNetwork'; const RESULTS_MAX = 5; @@ -29,7 +30,6 @@ type Result = { type ResultItem = { key: string; - followers: Map; followDistance: number; name?: string; picture?: string; @@ -259,22 +259,19 @@ class SearchBox extends Component { {this.state.results.map((r, index) => { const i = r.item; let followText = ''; - if (i.followers) { - if (i.followDistance === 0) { - followText = t('you'); - } else if (i.followDistance === 1) { - followText = t('following'); - } else { - followText = `${i.followers.size} ${t('followers')}`; - } + if (i.followDistance === 0) { + followText = t('you'); + } else if (i.followDistance === 1) { + followText = t('following'); + } else { + followText = `${SocialNetwork.followerCount(Key.toNostrHexAddress(i.key))} ${t('followers')}`; } - const npub = Key.toNostrBech32Address(i.key, 'npub'); return ( this.onResultFocus(e, index)} tabIndex={2} className={'result ' + (index === this.state.selected ? 'selected' : '')} - href={`/${npub}`} + href={`/${i.key}`} onClick={(e) => this.onClick(e, i)} > {i.picture ? ( @@ -282,7 +279,7 @@ class SearchBox extends Component { ) : ( - + )}
diff --git a/src/js/nostr/Events.ts b/src/js/nostr/Events.ts index 69bb5cd9..402e2652 100644 --- a/src/js/nostr/Events.ts +++ b/src/js/nostr/Events.ts @@ -286,7 +286,6 @@ const Events = { key, name: profile.name, display_name: profile.display_name, - followers: SocialNetwork.followersByUser.get(event.pubkey) || new Set(), }); //} } catch (e) { diff --git a/src/js/nostr/Session.ts b/src/js/nostr/Session.ts index c3826d39..5f389543 100644 --- a/src/js/nostr/Session.ts +++ b/src/js/nostr/Session.ts @@ -112,7 +112,7 @@ const Session = { } }); const unsubFollowers = SocialNetwork.getFollowersByUser(myPub, (followers) => { - if (!followers.length) { + if (!followers.size) { localState.get('noFollowers').put(true); } else { localState.get('noFollowers').put(false);