Skip to content

Commit

Permalink
fix bug when no relay
Browse files Browse the repository at this point in the history
  • Loading branch information
vivganes committed Nov 13, 2023
1 parent 5c657d8 commit 8778e8e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
7 changes: 5 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/app/component/event-feed/event-feed.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ <h3>
<ng-template [ngIf]="(tag ===undefined && community === undefined) && !loadingCommunityDetails" #homefeedHeader>
<div class="clr-row clr-justify-content-center">
<div class="clr-col-12 clr-col-md-8">
<div class="clr-control-container">
<select id="select-full" title="{{'Feed type'|translate}}" clrSelect name="options" [(ngModel)]="feedType" (ngModelChange)="onChangeFeedType($event)" class="giant-text-in-select">
<clr-select-container>
<select id="select-full" title="{{'Feed type'|translate}}" clrSelect name="options" [(ngModel)]="feedType" (ngModelChange)="onChangeFeedType($event)" class="giant-text-in-select select-feed-type">
<option [value]="feedTypeOptions[0]">#️⃣ {{'Topics Feed'|translate}}</option>
<option [value]="feedTypeOptions[1]">🫂 {{'Communities Feed'|translate}} - BETA</option>
</select>
</div>
</clr-select-container>
<div class="clr-control-container ml-5">
<div class="clr-toggle-wrapper" *ngIf="feedType === feedTypeOptions[1]">
<input type="checkbox" id="toggle1" name="toggle-full" [(ngModel)]="showUnapprovedPosts" class="clr-toggle" />
Expand Down
30 changes: 20 additions & 10 deletions src/app/service/ndkprovider.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export class NdkproviderService {


private async startWithUnauthSession() {
this.loginCompleteEmitter.emit(false);
this.loggingIn = true;
this.canWriteToNostr = false;
this.isTryingZapddit = true;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
});
}

}
Expand Down Expand Up @@ -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<NDKEvent> {
let tags: NDKTag[] = [];
const ndkEvent = new NDKEvent(this.ndk);
Expand Down
6 changes: 5 additions & 1 deletion src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8778e8e

Please sign in to comment.