rework Embassy tab, fix error type in patch-db, fix response type for embassy updates

This commit is contained in:
Matt Hill
2021-10-14 10:00:16 -06:00
committed by Aiden McClelland
parent 2f865a1953
commit 933481cd7d
24 changed files with 126 additions and 191 deletions

View File

@@ -34,7 +34,7 @@ export module RR {
export type GetServerMetricsRes = Metrics
export type UpdateServerReq = WithExpire<{ }> // server.update
export type UpdateServerRes = WithRevision<null>
export type UpdateServerRes = WithRevision<'updating' | 'no-updates'>
export type RestartServerReq = { } // server.restart
export type RestartServerRes = null

View File

@@ -54,8 +54,15 @@ export abstract class ApiService implements Source<DataModel>, Http<DataModel> {
protected abstract updateServerRaw (params: RR.UpdateServerReq): Promise<RR.UpdateServerRes>
updateServer = (params: RR.UpdateServerReq) => this.syncResponse(
() => this.updateServerRaw(params),
() => this.updateServerWrapper(params),
)()
async updateServerWrapper (params: RR.UpdateServerReq) {
const res = await this.updateServerRaw(params)
if (res.response === 'no-updates') {
throw new Error('Could ont find a newer version of EmbassyOS')
}
return res
}
abstract restartServer (params: RR.UpdateServerReq): Promise<RR.RestartServerRes>

View File

@@ -118,9 +118,11 @@ export class MockApiService extends ApiService {
value: initialProgress,
},
]
const res = await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
const res = await this.http.rpcRequest<RR.UpdateServerRes>({ method: 'db.patch', params: { patch } })
res.response = 'updating'
this.updateOSProgress(initialProgress.size)
return res
}