mirror of
https://github.com/block-core/blockcore-notes.git
synced 2024-09-29 06:20:42 +00:00
Fix ability to download profile and do a follow
This commit is contained in:
parent
fe9bf39ad8
commit
0062110001
@ -181,6 +181,10 @@ export class HomeComponent {
|
||||
|
||||
const observable = this.profileService.getProfile(array[0]).subscribe((profile) => {
|
||||
console.log('GOT CACHED PROFILE:', profile);
|
||||
|
||||
debugger;
|
||||
this.profileService.follow(profile.pubkey);
|
||||
|
||||
});
|
||||
|
||||
// this.profileService.getProfile(array[1]).subscribe((profile) => {
|
||||
|
@ -1,7 +1,5 @@
|
||||
<!-- <mat-progress-bar *ngIf="!events || events.length == 0" mode="indeterminate"></mat-progress-bar> -->
|
||||
||
|
||||
<div *ngFor="let profile of profileService.items$ | async">|||{{ profile.pubkey }} | {{ profile.name }}</div>
|
||||
||
|
||||
|
||||
<div class="feed-page" *ngIf="profileService.items$ | async as profiles">
|
||||
<!-- <p class="search">
|
||||
<mat-form-field appearance="fill" class="input-full-width">
|
||||
|
@ -7,7 +7,7 @@ import { RelayService } from './relay.service';
|
||||
import { Filter, Relay } from 'nostr-tools';
|
||||
import { DataValidation } from './data-validation.service';
|
||||
import { ApplicationState } from './applicationstate.service';
|
||||
import { timeout, map, merge, Observable, Observer, race, take, switchMap, mergeMap, tap, finalize, concatMap, mergeAll, exhaustMap, catchError, of } from 'rxjs';
|
||||
import { timeout, map, merge, Observable, Observer, race, take, switchMap, mergeMap, tap, finalize, concatMap, mergeAll, exhaustMap, catchError, of, combineAll, combineLatestAll } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@ -106,20 +106,28 @@ export class DataService {
|
||||
// catchError((error) => of(`The query timed out before it could complete: ${JSON.stringify(query)}.`))
|
||||
// );
|
||||
|
||||
return this.connected$
|
||||
.pipe(take(1))
|
||||
.pipe(
|
||||
tap(() => {
|
||||
debugger;
|
||||
console.log('YEEEEEEEEEEEEEE');
|
||||
})
|
||||
)
|
||||
.pipe(mergeMap(() => this.relayService.connectedRelays()))
|
||||
.pipe(mergeMap((relay) => this.downloadFromRelay(query, relay)))
|
||||
.pipe(
|
||||
timeout(requestTimeout),
|
||||
catchError((error) => of(`The query timed out before it could complete: ${JSON.stringify(query)}.`))
|
||||
);
|
||||
return (
|
||||
this.connected$
|
||||
.pipe(take(1))
|
||||
.pipe(
|
||||
tap(() => {
|
||||
debugger;
|
||||
})
|
||||
)
|
||||
.pipe(mergeMap(() => this.relayService.connectedRelays())) // TODO: Time this, it appears to take a lot of time??
|
||||
// .pipe(
|
||||
// mergeMap(() => {
|
||||
// const observables = this.relayService.connectedRelays().map((relay) => this.downloadFromRelay(query, relay));
|
||||
// return merge([...observables]);
|
||||
// })
|
||||
// )
|
||||
// .pipe(combineLatestAll())
|
||||
.pipe(mergeMap((relay) => this.downloadFromRelay(query, relay)))
|
||||
.pipe(
|
||||
timeout(requestTimeout),
|
||||
catchError((error) => of(`The query timed out before it could complete: ${JSON.stringify(query)}.`))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
subscribeLatestEvents(kinds: number[], pubkeys: string[], limit: number) {
|
||||
|
@ -100,6 +100,8 @@ export class FetchService {
|
||||
// TODO: Tune the timeout. There is no point waiting for too long if the relay is overwhelmed with requests as we will simply build up massive backpressure in the client.
|
||||
const query = [{ kinds: [0], authors: pubkeys }];
|
||||
|
||||
debugger;
|
||||
|
||||
return (
|
||||
this.connected$
|
||||
.pipe(
|
||||
|
@ -131,24 +131,24 @@ export class ProfileService {
|
||||
this.#profileRequested.next(pubkey);
|
||||
}
|
||||
|
||||
// #getProfile(pubkey: string) {
|
||||
// return new Observable((observer) => {
|
||||
// this.table.get(pubkey).then((profile) => {
|
||||
// if (profile) {
|
||||
// debugger;
|
||||
// observer.next(profile);
|
||||
// observer.complete();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// debugger;
|
||||
|
||||
// return this.dataService.downloadNewestProfiles([pubkey]);
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
|
||||
#getProfile(pubkey: string) {
|
||||
return new Observable((observer) => {
|
||||
this.table.get(pubkey).then((profile) => {
|
||||
if (profile) {
|
||||
debugger;
|
||||
observer.next(profile);
|
||||
observer.complete();
|
||||
return;
|
||||
}
|
||||
|
||||
debugger;
|
||||
|
||||
return this.dataService.downloadNewestProfiles([pubkey]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#getProfile2(pubkey: string) {
|
||||
return new Observable((observer) => {
|
||||
this.table
|
||||
.get(pubkey)
|
||||
@ -161,18 +161,26 @@ export class ProfileService {
|
||||
|
||||
debugger;
|
||||
|
||||
return this.dataService.downloadNewestProfiles([pubkey]).pipe(
|
||||
map(async (event: any) => {
|
||||
debugger;
|
||||
// const p = profile as NostrEventDocument;
|
||||
const profile = this.utilities.mapProfileEvent(event);
|
||||
this.dataService
|
||||
.downloadNewestProfiles([pubkey])
|
||||
.pipe(
|
||||
map(async (event: any) => {
|
||||
debugger;
|
||||
// const p = profile as NostrEventDocument;
|
||||
const profile = this.utilities.mapProfileEvent(event);
|
||||
|
||||
// Whenever we get here, also persist this profile to database.
|
||||
await this.table.put(profile);
|
||||
// Whenever we get here, also persist this profile to database.
|
||||
await this.table.put(profile);
|
||||
|
||||
return profile;
|
||||
})
|
||||
);
|
||||
observer.next(profile);
|
||||
observer.complete();
|
||||
|
||||
return profile;
|
||||
})
|
||||
)
|
||||
.subscribe((data) => {
|
||||
console.log('WE MUST OF COURSE SUB TO THIS OBSERVABLE!', data);
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
debugger;
|
||||
|
Loading…
Reference in New Issue
Block a user