forked from MapComplete/MapComplete
Merge branch 'master' into develop
This commit is contained in:
commit
3a30b26ee8
9 changed files with 240 additions and 87 deletions
|
@ -164,6 +164,7 @@ export default class FeatureReviews {
|
|||
fallbackName?: string
|
||||
uncertaintyRadius?: number
|
||||
}>
|
||||
private readonly _reportError: (msg: string, extra: string) => Promise<void>
|
||||
|
||||
private constructor(
|
||||
feature: Feature,
|
||||
|
@ -175,9 +176,11 @@ export default class FeatureReviews {
|
|||
uncertaintyRadius?: number
|
||||
}>,
|
||||
testmode?: Store<boolean>,
|
||||
loadingAllowed?: UIEventSource<boolean | null>
|
||||
loadingAllowed?: UIEventSource<boolean | null>,
|
||||
reportError?: (msg: string, extra: string) => Promise<void>
|
||||
) {
|
||||
this.loadingAllowed = loadingAllowed
|
||||
this._reportError = reportError
|
||||
const centerLonLat = GeoOperations.centerpointCoordinates(feature)
|
||||
;[this._lon, this._lat] = centerLonLat
|
||||
this._identity = mangroveIdentity
|
||||
|
@ -290,12 +293,8 @@ export default class FeatureReviews {
|
|||
feature: Feature,
|
||||
tagsSource: UIEventSource<Record<string, string>>,
|
||||
mangroveIdentity: MangroveIdentity,
|
||||
options: {
|
||||
nameKey?: "name" | string
|
||||
fallbackName?: string
|
||||
uncertaintyRadius?: number
|
||||
},
|
||||
state?: SpecialVisualizationState
|
||||
options: { nameKey: string; fallbackName: string; reportError: (msg) => Promise<void> },
|
||||
state?: SpecialVisualizationState,
|
||||
): FeatureReviews {
|
||||
const key =
|
||||
feature.properties.id +
|
||||
|
@ -334,7 +333,8 @@ export default class FeatureReviews {
|
|||
mangroveIdentity,
|
||||
options,
|
||||
state?.featureSwitchIsTesting,
|
||||
loadingAllowed
|
||||
loadingAllowed,
|
||||
(msg, extra) => state?.reportError(msg, extra)
|
||||
)
|
||||
FeatureReviews._featureReviewsCache[key] = featureReviews
|
||||
return featureReviews
|
||||
|
@ -362,7 +362,12 @@ export default class FeatureReviews {
|
|||
const jwt = await MangroveReviews.signReview(keypair, r)
|
||||
const kid = await MangroveReviews.publicToPem(keypair.publicKey)
|
||||
if (!this._testmode.data) {
|
||||
await MangroveReviews.submitReview(jwt)
|
||||
try{
|
||||
await MangroveReviews.submitReview(jwt)
|
||||
}catch (e) {
|
||||
await this._reportError(e, "Could not save a review. The text is:"+review.rating+", "+review.opinion)
|
||||
throw e
|
||||
}
|
||||
} else {
|
||||
console.log("Testmode enabled - not uploading review")
|
||||
await Utils.waitFor(1000)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue