|
@@ -1,5 +1,9 @@
|
|
|
import { Component } from "@angular/core";
|
|
|
-import { NavController, ToastController } from "ionic-angular";
|
|
|
+import {
|
|
|
+ NavController,
|
|
|
+ ToastController,
|
|
|
+ LoadingController
|
|
|
+} from "ionic-angular";
|
|
|
import { Storage } from "@ionic/storage";
|
|
|
import { CryptoProvider } from "../../providers/crypto/crypto";
|
|
|
|
|
@@ -16,7 +20,8 @@ export class SettingsPage {
|
|
|
public navCtrl: NavController,
|
|
|
public toastCtrl: ToastController,
|
|
|
private cryptoUtils: CryptoProvider,
|
|
|
- private storage: Storage
|
|
|
+ private storage: Storage,
|
|
|
+ private loadingCtrl: LoadingController
|
|
|
) {
|
|
|
this.loadValuesFromStorage();
|
|
|
}
|
|
@@ -39,15 +44,27 @@ export class SettingsPage {
|
|
|
this.storage.set("privateKey", this.privateKey);
|
|
|
this.storage.set("keywords", this.keywords);
|
|
|
|
|
|
+ this.showToast("Successfully saved!");
|
|
|
+ }
|
|
|
+
|
|
|
+ async publishPublicKey() {
|
|
|
+ if (this.publicKey.length) {
|
|
|
+ const loading = this.loadingCtrl.create();
|
|
|
+ loading.present();
|
|
|
+
|
|
|
+ await this.cryptoUtils.publishPublicKey(this.publicKey);
|
|
|
+
|
|
|
+ loading.dismiss();
|
|
|
+ this.showToast("Public key has been published!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private showToast(message: string) {
|
|
|
const toast = this.toastCtrl.create({
|
|
|
- message: "Successfully saved!",
|
|
|
+ message: message,
|
|
|
position: "bottom",
|
|
|
duration: 3000
|
|
|
});
|
|
|
toast.present();
|
|
|
}
|
|
|
-
|
|
|
- publishPublicKey() {
|
|
|
- this.cryptoUtils.publishPublicKey(this.publicKey);
|
|
|
- }
|
|
|
}
|