error flattening, remain to details, and delete old config stuff

This commit is contained in:
Matt Hill
2021-08-09 13:39:30 -06:00
committed by Aiden McClelland
parent ae09f5a4f2
commit 6a9ec0ea05
26 changed files with 42 additions and 754 deletions

View File

@@ -2,6 +2,7 @@ import { Subject, Observable } from 'rxjs'
import { Http, Update, Operation, Revision, Source, Store } from 'patch-db-client'
import { RR } from '../api.types'
import { DataModel } from 'src/app/services/patch-db/data-model'
import { RequestError, RPCError } from '../../http.service'
export abstract class ApiService implements Source<DataModel>, Http<DataModel> {
protected readonly sync = new Subject<Update<DataModel>>()
@@ -189,10 +190,15 @@ export abstract class ApiService implements Source<DataModel>, Http<DataModel> {
// this.sync.next({ patch: [temp], expiredBy: expireId })
// }
return f(a).then(({ response, revision }) => {
if (revision) this.sync.next(revision)
return response
}) as any
return f(a)
.catch((e: RequestError) => {
if (e.revision) this.sync.next(e.revision)
throw e
})
.then(({ response, revision }) => {
if (revision) this.sync.next(revision)
return response
})
}
}
}