window supports websockets

This commit is contained in:
Drew Ansbacher
2021-09-16 12:20:21 -06:00
committed by Aiden McClelland
parent b04892f5f4
commit 2a7f1a6eb7
5 changed files with 9 additions and 9 deletions

View File

@@ -62,7 +62,7 @@ export class SSHKeysPage {
await loader.present()
try {
const key = await this.embassyApi.addSshKey({ pubkey })
const key = await this.embassyApi.addSshKey({ key: pubkey })
this.sshKeys = { ...this.sshKeys, ...key }
} catch (e) {
this.errToast.present(e)

View File

@@ -24,7 +24,7 @@ export module RR {
// server
export type SetShareStatsReq = WithExpire<{ value: boolean }> // server.config.share-stats
export type SetShareStatsReq = WithExpire<{ value: boolean }> // server.config.share_stats
export type SetShareStatsRes = WithRevision<null>
export type GetServerLogsReq = { cursor?: string, before_flag?: boolean, limit?: number }
@@ -110,7 +110,7 @@ export module RR {
export type GetSSHKeysReq = { } // ssh.list
export type GetSSHKeysRes = SSHKeys
export type AddSSHKeyReq = { pubkey: string } // ssh.add
export type AddSSHKeyReq = { key: string } // ssh.add
export type AddSSHKeyRes = SSHKeys
export type DeleteSSHKeyReq = { hash: string } // ssh.delete

View File

@@ -54,7 +54,7 @@ export class LiveApiService extends ApiService {
// server
async setShareStatsRaw (params: RR.SetShareStatsReq): Promise<RR.SetShareStatsRes> {
return this.http.rpcRequest( { method: 'server.config.share-stats', params })
return this.http.rpcRequest( { method: 'server.config.share_stats', params })
}
async getServerLogs (params: RR.GetServerLogsReq): Promise<RR.GetServerLogsRes> {

View File

@@ -35,7 +35,7 @@ export class ConfigService {
mocks = mocks
skipStartupAlerts = mocks.enabled && mocks.skipStartupAlerts
isConsulate = window['platform'] === 'ios'
supportsWebSockets = 'WebSocket' in window || 'MozWebSocket' in window
isTor (): boolean {
return (mocks.enabled && mocks.maskAs === 'tor') || this.origin.endsWith('.onion')
@@ -46,11 +46,11 @@ export class ConfigService {
}
usePoll (): boolean {
return this.isConsulate || (mocks.enabled && mocks.connection === 'poll')
return this.supportsWebSockets || (mocks.enabled && mocks.connection === 'poll')
}
isLaunchable (state: PackageState, status: PackageMainStatus, interfaces: { [id: string]: InterfaceDef }): boolean {
if (this.isConsulate || state !== PackageState.Installed) {
if (this.supportsWebSockets || state !== PackageState.Installed) {
return false
}

View File

@@ -11,7 +11,7 @@ export function PatchDbServiceFactory (
embassyApi: ApiService,
): PatchDbService {
const { mocks, patchDb: { poll }, isConsulate } = config
const { mocks, patchDb: { poll }, supportsWebSockets } = config
let source: Source<DataModel>
@@ -22,7 +22,7 @@ export function PatchDbServiceFactory (
source = new WebsocketSource(`ws://localhost:${config.mocks.wsPort}/db`)
}
} else {
if (isConsulate) {
if (supportsWebSockets) {
source = new PollSource({ ...poll }, embassyApi)
} else {
const protocol = window.location.protocol === 'http:' ? 'ws' : 'wss'