From 8778e8e1da9ea36c0a171d4bfcec6c8ffda51031 Mon Sep 17 00:00:00 2001 From: vivganes Date: Mon, 13 Nov 2023 17:49:55 +0530 Subject: [PATCH] fix bug when no relay --- src/app/app.component.ts | 7 +++-- .../event-feed/event-feed.component.html | 6 ++-- src/app/service/ndkprovider.service.ts | 30 ++++++++++++------- src/styles.scss | 6 +++- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 64311bb..e187f6f 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -141,9 +141,12 @@ export class AppComponent implements OnInit, OnDestroy{ else { this.setTheme(false); } - this.topicService.fetchFollowedTopics().then(res=>{ - this.setFollowedTopicsFromString(res.join(',')); + this.ndkProvider.loginCompleteEmitter.subscribe((loginComplete:boolean)=>{ + this.topicService.fetchFollowedTopics().then(res=>{ + this.setFollowedTopicsFromString(res.join(',')); + }) }) + this.followedTopicsEmitterSub = this.ndkProvider.followedTopicsEmitter.subscribe((followedTopics: string) => { this.setFollowedTopicsFromString(followedTopics); diff --git a/src/app/component/event-feed/event-feed.component.html b/src/app/component/event-feed/event-feed.component.html index 6d34d62..ffbe53c 100644 --- a/src/app/component/event-feed/event-feed.component.html +++ b/src/app/component/event-feed/event-feed.component.html @@ -69,12 +69,12 @@

-
- -
+
diff --git a/src/app/service/ndkprovider.service.ts b/src/app/service/ndkprovider.service.ts index 1b19af9..88f5e58 100644 --- a/src/app/service/ndkprovider.service.ts +++ b/src/app/service/ndkprovider.service.ts @@ -130,6 +130,7 @@ export class NdkproviderService { private async startWithUnauthSession() { + this.loginCompleteEmitter.emit(false); this.loggingIn = true; this.canWriteToNostr = false; this.isTryingZapddit = true; @@ -158,6 +159,7 @@ export class NdkproviderService { attemptLoginUsingPrivateOrPubKey(enteredKey: string) { try { + this.loginCompleteEmitter.emit(false); this.loggingIn = true; this.loginError = undefined; const hexPrivateKey = this.validateAndGetHexKey(enteredKey); @@ -417,22 +419,20 @@ export class NdkproviderService { this.ndk = newNDK; this.loggingIn = false; //once all setup is done, then only set loggedIn=true to start rendering - this.loggedIn = true; - this.loginCompleteEmitter.emit(true); - - this.fetchFollowersFromCache(); - this.fetchMutedUsersFromCache(); - this.checkIfNIP05Verified(this.currentUserProfile?.nip05, this.currentUser?.pubkey); - this.loadCommunitiesToCache(); - + this.startRendering(); }); - - }) .catch(e => console.log("come on.. ndk not loaded")); } catch (e) { console.log('Error in connecting NDK ' + e); } + } else { + this.refreshAppData().then(() => { + console.log('refreshed app data') + this.loggingIn = false; + //once all setup is done, then only set loggedIn=true to start rendering + this.startRendering(); + }); } } @@ -492,6 +492,16 @@ export class NdkproviderService { return ndkEvent; } + private startRendering() { + this.loggedIn = true; + this.loginCompleteEmitter.emit(true); + + this.fetchFollowersFromCache(); + this.fetchMutedUsersFromCache(); + this.checkIfNIP05Verified(this.currentUserProfile?.nip05, this.currentUser?.pubkey); + this.loadCommunitiesToCache(); + } + async updateRelays(relays: Relay[]): Promise { let tags: NDKTag[] = []; const ndkEvent = new NDKEvent(this.ndk); diff --git a/src/styles.scss b/src/styles.scss index 3f6515d..baafdf3 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -57,7 +57,11 @@ html{ } .giant-text-in-select{ - font-size:25px!important; + font-size: x-large!important; +} + +.select-feed-type { + background-color: transparent!important; } .note-image {