diff --git a/android/app/build.gradle b/android/app/build.gradle index 53bb873..95dfc6b 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "com.silkwebhq.devvscapecode" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 2 - versionName "1.1.0" + versionCode 3 + versionName "1.1.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" aaptOptions { // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 5a532b0..b3830d8 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -20,8 +20,8 @@ export class AppComponent { async initializeApp() { this.platform.ready().then(async () => { - await SplashScreen.show({ - fadeOutDuration:2000 + await SplashScreen.hide({ + fadeOutDuration:1000 }); }) } diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index db530ad..d911fae 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -67,31 +67,11 @@ export class HomePage implements OnInit { }, 2000); } - getImages() { - this.data.getImages().subscribe((response: any) => { - if (response) { - - } - }, async (error: Error | HttpErrorResponse) => { - const toast = this.toastCtrl.create({ - message: `${error}`, - duration: 10000, - position: 'bottom', - color: 'danger' - }); - (await toast).present(); - setTimeout(async () => { - (await toast).dismiss(); - }, 1000); - }) - } - - getImageById(id: number) { - this.data.getImageById(id).subscribe( - (response: any) => { + async getImages() { + try { + this.data.getImages().subscribe((response: any) => { if (response) { - // console.log(response); - //save the id + } }, async (error: Error | HttpErrorResponse) => { const toast = this.toastCtrl.create({ @@ -105,35 +85,111 @@ export class HomePage implements OnInit { (await toast).dismiss(); }, 1000); }) + } catch (error) { + const toast = this.toastCtrl.create({ + message: error, + duration: 10000, + position: 'bottom', + color: 'danger' + }); + (await toast).present(); + setTimeout(async () => { + (await toast).dismiss(); + }, 1000); + } } - public getPaginatedImages(isFirstLoad, event) { - this.data.getPaginatedImages(this.page).subscribe( - (response: any) => { - if (response) { - // console.log(response); - this.images$ = response; - } - if (isFirstLoad) { - event.target.complete(); - } - this.page++; - }, async (error: Error | HttpErrorResponse) => { - const toast = this.toastCtrl.create({ - message: `${error.message}`, - duration: 10000, - position: 'bottom', - color: 'danger', - icon: 'sad' - }); - (await toast).present(); - setTimeout(async () => { - (await toast).dismiss(); - }, 1000); + async getImageById(id: number) { + try { + this.data.getImageById(id).subscribe( + (response: any) => { + if (response) { + // console.log(response); + //save the id + } + }, async (error: Error | HttpErrorResponse) => { + const toast = this.toastCtrl.create({ + message: `${error}`, + duration: 10000, + position: 'bottom', + color: 'danger' + }); + (await toast).present(); + setTimeout(async () => { + (await toast).dismiss(); + }, 1000); + }) + } catch (error) { + const toast = this.toastCtrl.create({ + message: error, + duration: 10000, + position: 'bottom', + color: 'danger' + }); + (await toast).present(); + setTimeout(async () => { + (await toast).dismiss(); + }, 1000); + } + } - //redirect to login to update token - this.router.navigateByUrl('/login') - }) + public async getPaginatedImages(isFirstLoad, event) { + try { + this.data.getPaginatedImages(this.page).subscribe( + async (response: any) => { + if (response) { + // console.log(response); + this.images$ = response; + }else{ + const toast = this.toastCtrl.create({ + message: "Something went wrong! Try again", + duration: 10000, + position: 'bottom', + color: 'danger', + icon: 'sad' + }); + (await toast).present(); + setTimeout(async () => { + (await toast).dismiss(); + }, 1000); + } + + if (isFirstLoad) { + event.target.complete(); + } + this.page++; + }, async (error: Error | HttpErrorResponse) => { + const toast = this.toastCtrl.create({ + message: `${error.message}`, + duration: 10000, + position: 'bottom', + color: 'danger', + icon: 'sad' + }); + (await toast).present(); + setTimeout(async () => { + (await toast).dismiss(); + }, 1000); + + //redirect to login to update token + this.router.navigateByUrl('/login') + }) + } catch (error) { + const toast = this.toastCtrl.create({ + message: error, + duration: 10000, + position: 'bottom', + color: 'danger', + icon: 'sad' + }); + (await toast).present(); + setTimeout(async () => { + (await toast).dismiss(); + }, 1000); + + //redirect to login to update token + this.router.navigateByUrl('/login') + } } onSelect(image: Images) { @@ -189,6 +245,7 @@ export class HomePage implements OnInit { loading.present(); this.authService.logout(); this.router.navigateByUrl('/login'); + loading.dismiss(); } catch (error) { const toast = this.toastCtrl.create({ message: error,