forked from MapComplete/MapComplete
UI(Reviews): move 'loading allowed' to FeatureReviews
This commit is contained in:
parent
ce3a049d9d
commit
d662bc2707
10 changed files with 105 additions and 63 deletions
|
|
@ -4,7 +4,7 @@ import { OsmConnection } from "../../Logic/Osm/OsmConnection"
|
|||
import UserRelatedState from "../../Logic/State/UserRelatedState"
|
||||
import { QueryParameters } from "../../Logic/Web/QueryParameters"
|
||||
import FeatureSwitchState from "../../Logic/State/FeatureSwitchState"
|
||||
import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
||||
import { ImmutableStore, Store, UIEventSource } from "../../Logic/UIEventSource"
|
||||
import LayerConfig from "../ThemeConfig/LayerConfig"
|
||||
import { LastClickFeatureSource } from "../../Logic/FeatureSource/Sources/LastClickFeatureSource"
|
||||
import { GeocodingUtils } from "../../Logic/Search/GeocodingProvider"
|
||||
|
|
@ -18,6 +18,9 @@ export class WithUserRelatedState {
|
|||
|
||||
readonly osmConnection: OsmConnection
|
||||
readonly userRelatedState: UserRelatedState
|
||||
readonly loadReviews: Store<boolean>
|
||||
|
||||
|
||||
readonly overlayLayerStates: ReadonlyMap<
|
||||
string,
|
||||
{ readonly isDisplayed: UIEventSource<boolean> }
|
||||
|
|
@ -62,6 +65,7 @@ export class WithUserRelatedState {
|
|||
this.featureSwitches,
|
||||
rasterLayer
|
||||
)
|
||||
this.loadReviews = this.constructIsLoadingReviewsAllowed()
|
||||
|
||||
if (!this.theme.official) {
|
||||
// Add custom themes to the "visited custom themes"
|
||||
|
|
@ -113,4 +117,31 @@ export class WithUserRelatedState {
|
|||
}
|
||||
return this.theme.getMatchingLayer(properties)
|
||||
}
|
||||
|
||||
private constructIsLoadingReviewsAllowed() : UIEventSource<boolean>{
|
||||
const loadingAllowed = new UIEventSource(false)
|
||||
|
||||
const themeIsSensitive = this.theme?.enableMorePrivacy ?? false
|
||||
const settings =
|
||||
this?.osmConnection?.getPreference<"always" | "yes" | "ask" | "hidden">(
|
||||
"reviews-allowed",
|
||||
) ?? new ImmutableStore("yes")
|
||||
settings.addCallbackAndRun((s) => {
|
||||
if (s === "hidden") {
|
||||
loadingAllowed.set(null)
|
||||
return
|
||||
}
|
||||
if (s === "always") {
|
||||
loadingAllowed.set(true)
|
||||
return
|
||||
}
|
||||
if (themeIsSensitive || s === "ask") {
|
||||
loadingAllowed.set(false)
|
||||
return
|
||||
}
|
||||
loadingAllowed.set(true)
|
||||
})
|
||||
return loadingAllowed
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue