Skip to content

Commit

Permalink
Harden Cordova applicability checks
Browse files Browse the repository at this point in the history
  • Loading branch information
NoelLH committed Mar 27, 2021
1 parent 0b2411a commit 77953e8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 0 additions & 3 deletions src/app/home/home.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import * as CordovaSQLiteDriver from 'localforage-cordovasqlitedriver';
import { HomePage } from './home.page';

declare global {
// tslint:disable-next-line: no-empty-interface
interface Cordova {}
interface Window {
cordova: Cordova;
clearTimeout: (handle?: number) => void;
setTimeout: (callback: () => any, interval: number) => any;
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/home/home.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class HomePage implements OnInit {
) {}

ngOnInit() {
if (window.cordova) {
if (window.hasOwnProperty('cordova')) {
// For now, no clipboard in-browser - API support not wide + no plugin support
if (this.clipboard) {
this.clipboard_available = true;
Expand Down Expand Up @@ -117,7 +117,7 @@ export class HomePage implements OnInit {
* the keyboard to see the password and Copy button.
*/
hideKeyboard() {
if (window.cordova) {
if (window.hasOwnProperty('cordova')) {
this.keyboard.hide();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class SettingsService {
// Tell listening pages (e.g. Home) that the settings changed
savePromise.then(() => {
this.saveSubject.next();
if (window.cordova) { // No cloud settings without a device
if (window.hasOwnProperty('cordova')) { // No cloud settings without a device
this.cloudSettings.save(settings, true);
}
});
Expand Down Expand Up @@ -148,7 +148,7 @@ export class SettingsService {
this.currentPromise = this.storage.get(SettingsService.storageKey).then(settings => {
if (settings === null) {
return new Promise(resolve => {
if (!window.cordova) { // No cloud settings without a device
if (!window.hasOwnProperty('cordova')) { // No cloud settings without a device
return resolve(this.loadDefaults());
}

Expand Down

0 comments on commit 77953e8

Please sign in to comment.