Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 57f81b4

Browse files
feat(#234): back to filter on photos and gifs modals
1 parent e4f79f7 commit 57f81b4

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

studio/src/app/modals/editor/app-gif/app-gif.tsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ export class AppGif {
3737

3838
private imageHistoryService: ImageHistoryService;
3939

40+
@State()
41+
private searching: boolean = false;
42+
4043
constructor() {
4144
this.gifService = GifService.getInstance();
4245
this.imageHistoryService = ImageHistoryService.getInstance();
@@ -78,8 +81,12 @@ export class AppGif {
7881

7982
private fetchCategories(): Promise<void> {
8083
return new Promise<void>(async (resolve) => {
84+
this.searching = true;
85+
8186
const categories: TenorCategory[] = await this.gifService.getCategories();
8287

88+
this.searching = false;
89+
8390
if (!categories || categories.length <= 0) {
8491
resolve();
8592
return;
@@ -104,8 +111,12 @@ export class AppGif {
104111
return;
105112
}
106113

114+
this.searching = true;
115+
107116
const tenorResponse: TenorSearchResponse = await this.gifService.getGifs(this.searchTerm, this.paginationNext);
108117

118+
this.searching = false;
119+
109120
if (!tenorResponse) {
110121
this.emptyGifs();
111122

@@ -174,6 +185,8 @@ export class AppGif {
174185

175186
private clear(): Promise<void> {
176187
return new Promise<void>((resolve) => {
188+
this.searchTerm = undefined;
189+
177190
this.gifsOdd = null;
178191
this.gifsEven = null;
179192

@@ -209,9 +222,7 @@ export class AppGif {
209222
<ion-header>
210223
<ion-toolbar color="secondary">
211224
<ion-buttons slot="start">
212-
<ion-button onClick={() => this.closeModal()}>
213-
<ion-icon name="close"></ion-icon>
214-
</ion-button>
225+
{this.renderCloseButton()}
215226
</ion-buttons>
216227
<ion-title class="ion-text-uppercase">Gif</ion-title>
217228
</ion-toolbar>
@@ -239,6 +250,18 @@ export class AppGif {
239250
];
240251
}
241252

253+
private renderCloseButton() {
254+
if ((this.gifsEven || this.gifsOdd) && !this.searching) {
255+
return <ion-button onClick={() => this.clear()}>
256+
<ion-icon name="arrow-back"></ion-icon>
257+
</ion-button>;
258+
} else {
259+
return <ion-button onClick={() => this.closeModal()}>
260+
<ion-icon name="close"></ion-icon>
261+
</ion-button>;
262+
}
263+
}
264+
242265
private renderCategories() {
243266
if (this.gifsEven || this.gifsOdd) {
244267
return undefined;

studio/src/app/modals/editor/app-photo/app-photo.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ export class AppPhoto {
7272

7373
private clear(): Promise<void> {
7474
return new Promise<void>((resolve) => {
75+
this.searchTerm = undefined;
76+
7577
this.photosOdd = null;
7678
this.photosEven = null;
7779

@@ -187,9 +189,7 @@ export class AppPhoto {
187189
<ion-header>
188190
<ion-toolbar color="primary">
189191
<ion-buttons slot="start">
190-
<ion-button onClick={() => this.closeModal()}>
191-
<ion-icon name="close"></ion-icon>
192-
</ion-button>
192+
{this.renderCloseButton()}
193193
</ion-buttons>
194194
<ion-title class="ion-text-uppercase">Stock photo</ion-title>
195195
</ion-toolbar>
@@ -221,6 +221,18 @@ export class AppPhoto {
221221
];
222222
}
223223

224+
private renderCloseButton() {
225+
if (!this.searchTerm || this.searchTerm.length <= 0 || this.searching) {
226+
return <ion-button onClick={() => this.closeModal()}>
227+
<ion-icon name="close"></ion-icon>
228+
</ion-button>;
229+
} else {
230+
return <ion-button onClick={() => this.clear()}>
231+
<ion-icon name="arrow-back"></ion-icon>
232+
</ion-button>;
233+
}
234+
}
235+
224236
private renderPhotosPlaceHolder() {
225237
if ((!this.photosOdd || this.photosOdd.length <= 0) && (!this.photosEven || this.photosEven.length <= 0)) {
226238
return <div class="photos-placeholder">

0 commit comments

Comments
 (0)