forked from MapComplete/MapComplete
commit
a2a4071022
18 changed files with 276 additions and 134 deletions
|
@ -45,20 +45,6 @@ export default class SelectedFeatureHandler {
|
|||
|
||||
const self = this
|
||||
hash.addCallback(() => self.setSelectedElementFromHash())
|
||||
|
||||
state.featurePipeline?.newDataLoadedSignal?.addCallbackAndRunD((_) => {
|
||||
// New data was loaded. In initial startup, the hash might be set (via the URL) but might not be selected yet
|
||||
if (hash.data === undefined || SelectedFeatureHandler._no_trigger_on.has(hash.data)) {
|
||||
// This is an invalid hash anyway
|
||||
return
|
||||
}
|
||||
if (state.selectedElement.data !== undefined) {
|
||||
// We already have something selected
|
||||
return
|
||||
}
|
||||
self.setSelectedElementFromHash()
|
||||
})
|
||||
|
||||
this.initialLoad()
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ export class OsmConnection {
|
|||
private readonly _singlePage: boolean
|
||||
private isChecking = false
|
||||
|
||||
constructor(options: {
|
||||
constructor(options?: {
|
||||
dryRun?: UIEventSource<boolean>
|
||||
fakeUser?: false | boolean
|
||||
oauth_token?: UIEventSource<string>
|
||||
|
@ -71,6 +71,7 @@ export class OsmConnection {
|
|||
osmConfiguration?: "osm" | "osm-test"
|
||||
attemptLogin?: true | boolean
|
||||
}) {
|
||||
options = options ?? {}
|
||||
this.fakeUser = options.fakeUser ?? false
|
||||
this._singlePage = options.singlePage ?? true
|
||||
this._oauth_config =
|
||||
|
|
|
@ -230,10 +230,12 @@ export abstract class Store<T> {
|
|||
|
||||
const newSource = new UIEventSource<T>(this.data)
|
||||
|
||||
const self = this
|
||||
this.addCallback((latestData) => {
|
||||
window.setTimeout(() => {
|
||||
if (this.data == latestData) {
|
||||
// compare by reference
|
||||
if (self.data == latestData) {
|
||||
// compare by reference.
|
||||
// Note that 'latestData' and 'self.data' are both from the same UIEVentSource, but both are dereferenced at a different time
|
||||
newSource.setData(latestData)
|
||||
}
|
||||
}, millisToStabilize)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue