Skip to content

Commit 2b63506

Browse files
committed
Revert "home page search works to return both hubs and events"
This reverts commit 6ae121b.
1 parent 6ae121b commit 2b63506

2 files changed

Lines changed: 23 additions & 75 deletions

File tree

src/app/home/home.page.html

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,7 @@
2424

2525
<ion-content fullscreen="true">
2626

27-
<ion-searchbar (ionInput)="searchHubsAndEvents($event)" showCancelButton="focus"></ion-searchbar>
28-
29-
<ion-list *ngIf="filter !== ''">
30-
<ion-list-header>
31-
<ion-text>Results</ion-text>
32-
</ion-list-header>
33-
34-
<ion-item lines="none" *ngIf="!filteredSearchResults?.length">
35-
<ion-label>No matches.</ion-label>
36-
</ion-item>
37-
38-
<ng-container *ngFor="let item of filteredSearchResults;">
39-
<ng-container [ngSwitch]="item.kind">
40-
41-
<app-hub-card *ngSwitchCase="'hub'"
42-
[hub]="item.hub"
43-
[coords]="locationService.location"
44-
(click)="goToHubPage(item.id)">
45-
</app-hub-card>
46-
47-
<app-event-card *ngSwitchCase="'event'"
48-
[userEvent]="item.userEvent"
49-
[buttons]="false"
50-
(click)="navCtrl.navigateForward('tabs/event/' + item.id)">
51-
</app-event-card>
52-
53-
</ng-container>
54-
</ng-container>
55-
</ion-list>
56-
27+
<ion-searchbar (ionInput)="filterHubs($event)" showCancelButton="focus"></ion-searchbar>
5728

5829
<ion-card style="height:30%" (click)="goToMap()">
5930
<app-maplibre
@@ -69,7 +40,7 @@
6940

7041
<app-claim-your-account-dialog />
7142

72-
<ion-list>
43+
<ion-list *ngIf="filter === ''">
7344
<ion-list-header>
7445
<ion-text>Upcoming Events</ion-text>
7546
</ion-list-header>
@@ -86,7 +57,7 @@
8657

8758
<ion-grid class="ion-no-padding">
8859
<ion-row>
89-
<ion-col size="12" size-md="6" *ngFor="let userEvent of upcomingEvents;">
60+
<ion-col size="12" size-md="6" *ngFor="let userEvent of upcomingEvents; trackBy: trackByEvent">
9061
<app-event-card
9162
[userEvent]="userEvent"
9263
[buttons]="false"
@@ -108,7 +79,7 @@
10879
</div>
10980
</ion-list>
11081

111-
<ion-list>
82+
<ion-list *ngIf="filter === ''">
11283
<ion-list-header>
11384
<ion-text>Hubs</ion-text>
11485
</ion-list-header>
@@ -134,6 +105,21 @@
134105
</div>
135106
</ion-list>
136107

108+
<ion-list *ngIf="filter !== ''">
109+
<ion-list-header>
110+
<ion-text>Hubs</ion-text>
111+
</ion-list-header>
112+
<div *ngFor="let userHub of filteredUserHubs; trackBy: userTrackByHub">
113+
<app-hub-card
114+
[hub]="userHub.hub"
115+
[coords]="locationService.location"
116+
[starred]="userHub.starred"
117+
[muted]="userHub.muted"
118+
[isOwner]="userHub.isOwner"
119+
(click)="goToHubPage(userHub.hubId)"></app-hub-card>
120+
</div>
121+
</ion-list>
122+
137123
<ion-fab vertical="bottom" horizontal="end" slot="fixed">
138124
<ion-fab-button>
139125
<ion-icon name="add-outline"></ion-icon>

src/app/home/home.page.ts

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Config, MenuController, NavController } from '@ionic/angular';
33
import { QueryRef } from 'apollo-angular';
44
import { NGXLogger } from 'ngx-logger';
55
import { Subscription } from 'rxjs';
6-
import { Hub, InvitesByUserGQL, InvitesByUserQuery, JoinUserEvent, JoinUserHub, QuerySearchHubByNameArgs, User, UserEventsGQL, UserEventsQuery, UsersHubsGQL, UsersHubsQuery } from 'src/graphql/graphql';
6+
import { Hub, InvitesByUserGQL, InvitesByUserQuery, JoinUserHub, User, UserEventsGQL, UserEventsQuery, UsersHubsGQL, UsersHubsQuery } from 'src/graphql/graphql';
77
import { environment } from '../../environments/environment';
88
import { MaplibreComponent } from '../components/maplibre/maplibre.component';
99
import { AuthService } from '../services/auth/auth.service';
@@ -13,15 +13,6 @@ import { LocationService } from '../services/location/location.service';
1313
import { ThemeService } from '../services/theme/theme.service';
1414
import { ApolloQueryResult } from '@apollo/client/core';
1515

16-
type SearchHubItem = UsersHubsQuery['usersHubs'][number];
17-
type SearchEventItem = UserEventsQuery['usersEvents'][number];
18-
19-
type SearchResults =
20-
| { kind: 'hub'; id: number; name: string; raw: SearchHubItem; hub: Hub }
21-
| { kind: 'event'; id: number; name: string; raw: SearchEventItem; userEvent: SearchEventItem };
22-
23-
24-
2516
@Component({
2617
selector: 'app-home',
2718
templateUrl: 'home.page.html',
@@ -36,9 +27,6 @@ export class HomePage implements OnInit, OnDestroy {
3627
invites: InvitesByUserQuery['invitesByUser'];
3728
filter = '';
3829
filteredUserHubs: UsersHubsQuery['usersHubs'];
39-
40-
filteredSearchResults: SearchResults[] = [];
41-
4230
userHubs: UsersHubsQuery['usersHubs'];
4331
hubs: Hub[] = [];
4432
user: User;
@@ -167,41 +155,15 @@ export class HomePage implements OnInit, OnDestroy {
167155
this.navCtrl.navigateForward('settings');
168156
}
169157

170-
searchHubsAndEvents(ev: any) {
171-
this.filter = ev.target.value;
158+
filterHubs(ev: any) {
159+
this.filter = ev.target.value;
172160

173161
if (this.filter && this.filter.trim() !== '') {
174-
175162
this.filteredUserHubs = this.userHubs.filter(y => {
176163
const name = y.hub.name.trim().toLowerCase();
177164
return name.includes(this.filter.trim().toLowerCase());
178165
});
179-
180-
this.filteredEvents = this.sortedEvents?.filter(x => {
181-
const name = x?.event?.name?.trim()?.toLowerCase();
182-
return name?.includes(this.filter?.trim()?.toLowerCase());
183-
}).sort(
184-
(a, b) => new Date(b?.event?.startDateTime).valueOf() - new Date(a?.event?.startDateTime).valueOf()
185-
);
186-
187-
const hubResults: SearchResults[] = this.filteredUserHubs.map((uh) => ({
188-
kind: 'hub',
189-
id: Number(uh?.hub?.id),
190-
name: uh?.hub?.name ?? '',
191-
raw: uh,
192-
hub: uh?.hub as Hub,
193-
}));
194-
195-
const eventResults: SearchResults[] = this.filteredEvents.map((ue) => ({
196-
kind: 'event',
197-
id: Number(ue?.event?.id),
198-
name: ue?.event?.name ?? '',
199-
raw: ue,
200-
userEvent: ue,
201-
}));
202-
203-
this.filteredSearchResults = [...hubResults, ...eventResults];
204-
}
166+
}
205167
}
206168

207169
goToMap() {

0 commit comments

Comments
 (0)