mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
refactor: isolate network toast and login redirect to separate services (#1412)
* refactor: isolate network toast and login redirect to separate services * chore: remove accidentally committed sketch of a service * chore: tidying things up * feat: add `GlobalModule` encapsulating all global subscription services * remove angular build cache when building deps * chore: fix more issues found while testing * chore: fix issues reported by testing * chore: fix template error * chore: fix server-info * chore: fix server-info * fix: switch to Observable to fix race conditions * fix embassy name display on load * update patchdb * clean up patch data watch Co-authored-by: Lucy Cifferello <12953208+elvece@users.noreply.github.com>
This commit is contained in:
@@ -29,7 +29,7 @@ export class AppComponent {
|
||||
this.stateService.isMigrating = false
|
||||
await this.navCtrl.navigateForward(`/recover`)
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
this.errorToastService.present(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ export class EmbassyPage {
|
||||
})
|
||||
await alert.present()
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
this.errorToastService.present(e)
|
||||
} finally {
|
||||
this.loading = false
|
||||
@@ -141,7 +141,7 @@ export class EmbassyPage {
|
||||
} else {
|
||||
await this.navCtrl.navigateForward(`/success`)
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
this.errorToastService.present({
|
||||
message: `${e.message}\n\nRestart Embassy to try again.`,
|
||||
})
|
||||
|
||||
@@ -119,7 +119,7 @@ export class RecoverPage {
|
||||
await alert.present()
|
||||
this.hasShownGuidAlert = true
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
this.errorToastService.present(e)
|
||||
} finally {
|
||||
this.loading = false
|
||||
@@ -205,7 +205,7 @@ export class RecoverPage {
|
||||
try {
|
||||
await this.stateService.importDrive(guid)
|
||||
await this.navCtrl.navigateForward(`/success`)
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
this.errorToastService.present(e)
|
||||
} finally {
|
||||
loader.dismiss()
|
||||
|
||||
@@ -30,7 +30,7 @@ export class SuccessPage {
|
||||
encodeURIComponent(this.stateService.cert),
|
||||
)
|
||||
this.download()
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
await this.errCtrl.present(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
import { Observable } from 'rxjs'
|
||||
import * as aesjs from 'aes-js'
|
||||
import * as pbkdf2 from 'pbkdf2'
|
||||
import { HttpError, RpcError } from '@start9labs/shared'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -80,7 +81,7 @@ export class HttpService {
|
||||
.then(res => JSON.parse(res))
|
||||
.catch(e => {
|
||||
if (!e.status && !e.statusText) {
|
||||
throw new EncryptionError(e)
|
||||
throw new EncryptionError()
|
||||
} else {
|
||||
throw new HttpError(e)
|
||||
}
|
||||
@@ -120,34 +121,10 @@ export class HttpService {
|
||||
}
|
||||
}
|
||||
|
||||
function RpcError(e: RPCError['error']): void {
|
||||
const { code, message, data } = e
|
||||
|
||||
this.code = code
|
||||
|
||||
if (typeof data === 'string') {
|
||||
this.message = `${message}\n\n${data}`
|
||||
} else {
|
||||
if (data.details) {
|
||||
this.message = `${message}\n\n${data.details}`
|
||||
} else {
|
||||
this.message = message
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function HttpError(e: HttpErrorResponse): void {
|
||||
const { status, statusText } = e
|
||||
|
||||
this.code = status
|
||||
this.message = statusText
|
||||
this.details = null
|
||||
}
|
||||
|
||||
function EncryptionError(e: HttpErrorResponse): void {
|
||||
this.code = null
|
||||
this.message = 'Invalid Key'
|
||||
this.details = null
|
||||
class EncryptionError {
|
||||
readonly code = null
|
||||
readonly message = 'Invalid Key'
|
||||
readonly details = null
|
||||
}
|
||||
|
||||
function isRpcError<Error, Result>(
|
||||
@@ -205,10 +182,6 @@ export interface RPCError extends RPCBase {
|
||||
|
||||
export type RPCResponse<T> = RPCSuccess<T> | RPCError
|
||||
|
||||
type HttpError = HttpErrorResponse & {
|
||||
error: { code: string; message: string }
|
||||
}
|
||||
|
||||
export interface HttpOptions {
|
||||
method: Method
|
||||
url: string
|
||||
|
||||
@@ -49,7 +49,7 @@ export class StateService {
|
||||
let progress
|
||||
try {
|
||||
progress = await this.apiService.getRecoveryStatus()
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
this.errorToastService.present({
|
||||
message: `${e.message}\n\nRestart Embassy to try again.`,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user