Skip to content

Commit bf76b38

Browse files
committed
Remove deprecated ionic controllers
1 parent 5e40285 commit bf76b38

File tree

9 files changed

+25
-56
lines changed

9 files changed

+25
-56
lines changed

src/components/edit-popover.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, Prop, h } from '@stencil/core';
2+
import { popoverController } from '@ionic/core';
23

34
@Component({
45
tag: 'edit-popover'
@@ -9,7 +10,6 @@ export class EditPopover {
910
@Prop() rotateCallback: any;
1011

1112
async closePopover() {
12-
const popoverController = document.querySelector('ion-popover-controller');
1313
await popoverController.dismiss();
1414
}
1515

src/components/filter-popover.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { Component, Prop, h } from '@stencil/core';
2-
import { RangeChangeEventDetail, RangeValue } from '@ionic/core';
2+
3+
import {
4+
RangeChangeEventDetail,
5+
RangeValue,
6+
popoverController
7+
} from '@ionic/core';
38

49
declare var Caman;
510
// import PresentingService from '../services/presenting-service';
@@ -16,7 +21,6 @@ export class FilterPopover {
1621
private saturation: RangeValue = 0;
1722

1823
async closePopover() {
19-
const popoverController = document.querySelector('ion-popover-controller');
2024
popoverController.dismiss();
2125
this.selectedPhotos = null;
2226
}

src/components/select-album.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, Prop, State, h } from '@stencil/core';
2+
import { popoverController } from '@ionic/core';
23

34
import AlbumsService from '../services/albums-service';
45
import PresentingService from '../services/presenting-service';
@@ -80,7 +81,6 @@ export class SelectAlbum {
8081
}
8182

8283
async closePopover() {
83-
const popoverController = document.querySelector('ion-popover-controller');
8484
popoverController.dismiss();
8585
}
8686

src/pages/app-albums/app-albums.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, State, h } from '@stencil/core';
2+
import { actionSheetController, alertController } from '@ionic/core';
23

34
import AlbumsService from '../../services/albums-service';
45
import AnalyticsService from '../../services/analytics-service';
@@ -107,8 +108,6 @@ export class AppAlbums {
107108
}
108109

109110
async presentCreateAlbumPrompt() {
110-
const alertController: any = document.querySelector('ion-alert-controller');
111-
112111
const alert = await alertController.create({
113112
header: 'Create a new Album',
114113
inputs: [
@@ -179,10 +178,6 @@ export class AppAlbums {
179178
}
180179

181180
async deleteAlbum(albumId: string, albumName: string): Promise<void> {
182-
const actionSheetController: any = document.querySelector(
183-
'ion-action-sheet-controller'
184-
);
185-
186181
const actionSheet = await actionSheetController.create({
187182
header: 'Delete the album "' + albumName + '"?',
188183
buttons: [

src/pages/app-photo/app-photo.tsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, Prop, State, h } from '@stencil/core';
2+
import { modalController, popoverController } from '@ionic/core';
23
import loadImage from 'blueimp-load-image';
34
import Downloader from 'js-file-downloader';
45

@@ -19,7 +20,6 @@ declare var navigator;
1920
})
2021
export class AppPhoto {
2122
private present: PresentingService;
22-
private modalController: HTMLIonModalControllerElement;
2323
private slides: HTMLIonSlidesElement;
2424
private firstSlide = true;
2525
private slideToOne = false;
@@ -91,8 +91,6 @@ export class AppPhoto {
9191
this.updateFromSlide = true;
9292
await this.getPhoto(this.photoId, 1);
9393

94-
this.modalController = document.querySelector('ion-modal-controller');
95-
9694
document.addEventListener('keydown', this.keydownPressedListener);
9795

9896
AnalyticsService.logEvent('photo-page');
@@ -439,7 +437,7 @@ export class AppPhoto {
439437
// } else {
440438
setTimeout(() => {
441439
this.deleteInProgress = false;
442-
this.modalController.dismiss();
440+
modalController.dismiss();
443441
}, 1000);
444442
// }
445443

@@ -451,15 +449,11 @@ export class AppPhoto {
451449
}
452450

453451
async closeModal() {
454-
await this.modalController.dismiss();
452+
await modalController.dismiss();
455453
this.photoId = null;
456454
}
457455

458456
async presentAlbumSelector(event: any) {
459-
const popoverController: any = document.querySelector(
460-
'ion-popover-controller'
461-
);
462-
463457
const popover = await popoverController.create({
464458
component: 'select-album',
465459
componentProps: {
@@ -481,10 +475,6 @@ export class AppPhoto {
481475
}
482476

483477
async presentFilterSelector(event: any) {
484-
const popoverController: any = document.querySelector(
485-
'ion-popover-controller'
486-
);
487-
488478
const popover = await popoverController.create({
489479
component: 'filter-popover',
490480
componentProps: {
@@ -666,10 +656,6 @@ export class AppPhoto {
666656
}
667657

668658
async activateEditor() {
669-
const popoverController: any = document.querySelector(
670-
'ion-popover-controller'
671-
);
672-
673659
const componentProps = {
674660
selectedPhotos: [this.photoId],
675661
deleteCallback: this.delete.bind(this),

src/pages/app-photos/app-photos.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, Prop, State, h } from '@stencil/core';
2+
import { modalController, popoverController } from '@ionic/core';
23

34
// import * as JSZip from 'jszip';
45
import Downloader from 'js-file-downloader';
@@ -32,7 +33,6 @@ export class AppPhotos {
3233
private infiniteScroll: any;
3334
private refresherScroll: any;
3435
private photosListCached: any[] = [];
35-
private modalController: HTMLIonModalControllerElement;
3636
private appPhotoElement: HTMLAppPhotoElement;
3737
private album: any;
3838
private router: HTMLIonRouterElement;
@@ -108,8 +108,6 @@ export class AppPhotos {
108108
this.uploadService.addEventListeners(true);
109109
this.loadPhotosList(true);
110110

111-
this.modalController = document.querySelector('ion-modal-controller');
112-
113111
this.timestampChecker = setInterval(
114112
this.checkTimestampUpdate.bind(this),
115113
10000
@@ -383,7 +381,7 @@ export class AppPhotos {
383381
// create component to open
384382
this.appPhotoElement = document.createElement('app-photo');
385383

386-
const modal = await this.modalController.create({
384+
const modal = await modalController.create({
387385
component: this.appPhotoElement,
388386
componentProps: {
389387
photoId,
@@ -426,10 +424,6 @@ export class AppPhotos {
426424
}
427425

428426
async presentAlbumSelector(event: any) {
429-
const popoverController: any = document.querySelector(
430-
'ion-popover-controller'
431-
);
432-
433427
const popover = await popoverController.create({
434428
component: 'select-album',
435429
componentProps: {

src/pages/app-root/app-root.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, Listen, State, h } from '@stencil/core';
22
import { Plugins } from '@capacitor/core';
3+
import { toastController } from '@ionic/core';
34
import localForage from 'localforage';
45

56
import AnalyticsService from '../../services/analytics-service';
@@ -13,8 +14,6 @@ declare var blockstack;
1314
styleUrl: 'app-root.css'
1415
})
1516
export class AppRoot {
16-
private toastCtrl: any;
17-
1817
@State() isAuthenticated: boolean;
1918

2019
/**
@@ -28,8 +27,7 @@ export class AppRoot {
2827
*/
2928
@Listen('swUpdate', { target: 'window' })
3029
async onSWUpdate() {
31-
this.toastCtrl = document.querySelector('ion-toast-controller');
32-
const toast = await this.toastCtrl.create({
30+
const toast = await toastController.create({
3331
message: 'New version available',
3432
showCloseButton: true,
3533
closeButtonText: 'Reload'
@@ -166,12 +164,7 @@ export class AppRoot {
166164
</ion-menu>
167165
<ion-router-outlet animated={true} id="menu-content" />
168166
</ion-split-pane>
169-
<ion-alert-controller />
170167
<ion-action-sheet-controller />
171-
<ion-loading-controller />
172-
<ion-popover-controller />
173-
<ion-toast-controller />
174-
<ion-modal-controller />
175168
</ion-app>
176169
];
177170
}

src/pages/app-settings/app-settings.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { Component, h } from '@stencil/core';
2+
import { actionSheetController } from '@ionic/core';
3+
24
import PresentingService from '../../services/presenting-service';
35
import AnalyticsService from '../../services/analytics-service';
46
// import SettingsService from '../../services/settings-service';
@@ -112,9 +114,6 @@ export class AppSettings {
112114
if (event) {
113115
event.preventDefault();
114116
}
115-
const actionSheetController: any = document.querySelector(
116-
'ion-action-sheet-controller'
117-
);
118117

119118
const buttons = [
120119
{

src/services/presenting-service.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
import {
2+
actionSheetController,
3+
alertController,
4+
loadingController,
5+
toastController
6+
} from '@ionic/core';
7+
18
import PhotosService from './photos-service';
29
import isElectron from 'is-electron';
310

411
export default class PresentingService {
512
private loadingElement: HTMLIonLoadingElement;
613

714
async loading(message: string, duration?: number): Promise<void> {
8-
const loadingController = document.querySelector('ion-loading-controller');
9-
1015
this.loadingElement = await loadingController.create({
1116
message,
1217
spinner: 'circles',
@@ -52,8 +57,6 @@ export default class PresentingService {
5257
}
5358

5459
async toast(message: string): Promise<void> {
55-
const toastController = document.querySelector('ion-toast-controller');
56-
5760
const toast = await toastController.create({
5861
message,
5962
showCloseButton: true,
@@ -76,9 +79,6 @@ export default class PresentingService {
7679
if (ids.length === 1) {
7780
header = 'Delete ' + ids.length + ' photo?';
7881
}
79-
const actionSheetController = document.querySelector(
80-
'ion-action-sheet-controller'
81-
);
8282

8383
let buttons = [
8484
{
@@ -171,8 +171,6 @@ export default class PresentingService {
171171
}
172172

173173
async errorAlert(header: string, message: string): Promise<void> {
174-
const alertController = document.querySelector('ion-alert-controller');
175-
176174
const alert = await alertController.create({
177175
header,
178176
subHeader: '',

0 commit comments

Comments
 (0)