alert after connecting to new wifi

This commit is contained in:
Matt Hill
2020-12-09 13:47:13 -07:00
committed by Aiden McClelland
parent 7b0f99881b
commit 7a3811235e
2 changed files with 16 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'
import { ToastController } from '@ionic/angular'
import { AlertController, ToastController } from '@ionic/angular'
import { ApiService } from 'src/app/services/api/api.service'
import { pauseFor } from 'src/app/util/misc.util'
import { ServerModel } from 'src/app/models/server-model'
@@ -12,6 +12,7 @@ export class WifiService {
constructor (
private readonly apiService: ApiService,
private readonly toastCtrl: ToastController,
private readonly alertCtrl: AlertController,
private readonly serverModel: ServerModel,
) { }
@@ -30,10 +31,13 @@ export class WifiService {
const maxAttempts = 5
let attempts = 0
let old: string | null
while (attempts < maxAttempts) {
try {
const start = new Date().valueOf()
const { current, ssids } = (await this.apiService.getServer(timeout)).wifi
old = current
const end = new Date().valueOf()
if (current === ssid) {
this.serverModel.update({ wifi: { current, ssids } })
@@ -53,7 +57,13 @@ export class WifiService {
}
if (this.serverModel.peek().wifi.current === ssid) {
return true
let message = 'Note. It may take a few minutes for your Embassy to reconnect over Tor. If it does not reconnect after 5 minutes, please unplug the device and plug it back in. You may also need to hard refresh your browser cache.'
const alert = await this.alertCtrl.create({
header: `Connected to "${ssid}"`,
message: old ? message : 'You may now unplug your Embassy from Ethernet.<br /></br />' + message,
buttons: ['OK'],
})
await alert.present()
} else {
const toast = await this.toastCtrl.create({
header: 'Failed to connect:',

View File

@@ -11,7 +11,10 @@ export interface ApiServer {
versionInstalled: string
alternativeRegistryUrl: string | null
specs: ServerSpecs
wifi: { ssids: string[]; current: string; }
wifi: {
ssids: string[]
current: string | null
}
ssh: SSHFingerprint[]
serverId: string
}