Add rendering of 7 last items on home

This commit is contained in:
SondreB 2023-01-20 15:54:15 +01:00
parent f719e613f3
commit 7a97afc98d
No known key found for this signature in database
GPG Key ID: D6CC44C75005FDBF
3 changed files with 23 additions and 10 deletions

View File

@ -135,3 +135,7 @@
gap: 1em;
}
}
.view-more-container {
text-align: center;
}

View File

@ -112,7 +112,19 @@
</mat-card-content>
</mat-card>
<mat-card class="home-card">
<mat-card class="events clickable" (click)="navigation.openEvent($event, event)" *ngFor="let event of latestItems$ | async; trackBy: trackByFn">
<div class="events-header">
<app-event-header [pubkey]="event.pubkey"><span class="event-date" matTooltipPosition="below">{{ event.created_at | ago }}</span> <app-directory-icon [pubkey]="event.pubkey"></app-directory-icon></app-event-header>
<app-event-actions [event]="event"></app-event-actions>
</div>
<app-content [event]="event"></app-content>
</mat-card>
<p class="view-more-container">
<button mat-button routerLink="/feed">View more notes...</button>
</p>
<!-- <mat-card class="home-card">
<mat-card-header>
<img mat-card-avatar src="https://material.angular.io/assets/img/examples/shiba1.jpg" />
<mat-card-title>Shiba Inu</mat-card-title>
@ -126,7 +138,7 @@
<button mat-button>Like</button>
<button mat-button>Comments</button>
</mat-card-actions>
</mat-card>
</mat-card> -->
</div>
</div>

View File

@ -22,6 +22,8 @@ import { animate, style, transition, trigger } from '@angular/animations';
import { DataService } from '../services/data';
import { StorageService } from '../services/storage';
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { dexieToRx } from '../shared/utilities';
import { liveQuery } from 'dexie';
interface DefaultProfile {
pubkey: string;
@ -130,6 +132,7 @@ export class HomeComponent {
private cd: ChangeDetectorRef,
public options: OptionsService,
public dialog: MatDialog,
public navigation: NavigationService,
public profileService: ProfileService,
private validator: DataValidation,
public navigationService: NavigationService,
@ -311,12 +314,6 @@ export class HomeComponent {
// this.cd.detectChanges();
// }
optionsUpdated() {
// this.allComplete = this.task.subtasks != null && this.task.subtasks.every(t => t.completed);
// Parse existing content.
this.events = this.validator.filterEvents(this.events);
}
public trackByFn(index: number, item: NostrEvent) {
return item.id;
}
@ -329,11 +326,11 @@ export class HomeComponent {
return item.id;
}
events: NostrEvent[] = [];
latestItems$ = dexieToRx(liveQuery(() => this.db.events.orderBy('created_at').reverse().limit(7).toArray()));
sub: any;
relay?: Relay;
initialLoad = true;
details = false;
toggleDetails() {