Skip to content

Commit

Permalink
Merge pull request Fernanda-Kipper#59 from Fernanda-Kipper/feature/ad…
Browse files Browse the repository at this point in the history
…d-adsense

Criando cache inicial
  • Loading branch information
Fernanda-Kipper authored Jul 16, 2024
2 parents d340a20 + 063a8c9 commit e46fccb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const appConfig: ApplicationConfig = {
provideClientHydration(
withHttpTransferCacheOptions({
filter(req) {
return !req.url.includes('/api/event?page');
return !req.url.includes('/api/event?page=0&size=10');
},
}),
),
Expand Down
12 changes: 10 additions & 2 deletions src/app/pages/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommonModule } from '@angular/common';
import { Component, OnInit, signal } from '@angular/core';
import { AfterViewInit, Component, OnInit, signal } from '@angular/core';
import {
FormControl,
FormGroup,
Expand Down Expand Up @@ -51,7 +51,7 @@ interface FilterForm {
],
templateUrl: './home.component.html',
})
export class HomeComponent implements OnInit {
export class HomeComponent implements OnInit, AfterViewInit {
isModalOpen = signal(false);
filterIsActive = false;
filterForm!: FormGroup<FilterForm>;
Expand Down Expand Up @@ -84,6 +84,14 @@ export class HomeComponent implements OnInit {
]).pipe(map(([term, events]) => this.getFilteredEvents(term, events)));
}

ngAfterViewInit(): void {
this.events$ = this.eventsService.getEvents(0, 20);
this.filteredEventList$ = combineLatest([
this.searchTerm.pipe(startWith('')),
this.events$,
]).pipe(map(([term, events]) => this.getFilteredEvents(term, events)));
}

loadLocalesFilter() {
this.filterService.loadLocales().subscribe({
next: (body: UF[]) => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/services/events.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export class EventsService {

constructor(private http: HttpClient) {}

getEvents(page: number = 0): Observable<EventItem[]> {
getEvents(page: number = 0, size: number = 10): Observable<EventItem[]> {
return this.http
.get<EventItem[]>(`${this.APIurl}/api/event?page=${page}&size=20`)
.get<EventItem[]>(`${this.APIurl}/api/event?page=${page}&size=${size}`)
.pipe(
catchError(() => {
return of([]);
Expand Down

0 comments on commit e46fccb

Please sign in to comment.