Fix dependency injection of refactoring
This commit is contained in:
parent
f0675a026b
commit
39e6cdfda4
4 changed files with 25 additions and 15 deletions
|
@ -27,8 +27,10 @@ export class Changes {
|
|||
public features = new UIEventSource<{ feature: any, freshness: Date }[]>([]);
|
||||
public readonly pendingChanges: UIEventSource<ChangeDescription[]> = LocalStorageSource.GetParsed<ChangeDescription[]>("pending-changes", [])
|
||||
public readonly allChanges = new UIEventSource<ChangeDescription[]>(undefined)
|
||||
public readonly state: { allElements: ElementStorage; historicalUserLocations: FeatureSource; osmConnection: OsmConnection }
|
||||
public readonly state: { allElements: ElementStorage; osmConnection: OsmConnection }
|
||||
public readonly extraComment: UIEventSource<string> = new UIEventSource(undefined)
|
||||
|
||||
private historicalUserLocations: FeatureSource
|
||||
private _nextId: number = -1; // Newly assigned ID's are negative
|
||||
private readonly isUploading = new UIEventSource(false);
|
||||
private readonly previouslyCreated: OsmObject[] = []
|
||||
|
@ -38,7 +40,6 @@ export class Changes {
|
|||
constructor(
|
||||
state?: {
|
||||
allElements: ElementStorage,
|
||||
historicalUserLocations: FeatureSource,
|
||||
osmConnection: OsmConnection
|
||||
},
|
||||
leftRightSensitive: boolean = false) {
|
||||
|
@ -148,7 +149,7 @@ export class Changes {
|
|||
|
||||
private calculateDistanceToChanges(change: OsmChangeAction, changeDescriptions: ChangeDescription[]) {
|
||||
|
||||
const locations = this.state?.historicalUserLocations?.features?.data
|
||||
const locations = this.historicalUserLocations?.features?.data
|
||||
if (locations === undefined) {
|
||||
// No state loaded or no locations -> we can't calculate...
|
||||
return;
|
||||
|
@ -520,4 +521,8 @@ export class Changes {
|
|||
console.debug("Calculated the pending changes: ", result.newObjects.length, "new; ", result.modifiedObjects.length, "modified;", result.deletedObjects, "deleted")
|
||||
return result
|
||||
}
|
||||
|
||||
public setHistoricalUserLocations(locations: FeatureSource ){
|
||||
this.historicalUserLocations = locations
|
||||
}
|
||||
}
|
|
@ -20,11 +20,7 @@ export default class ElementsState extends FeatureSwitchState {
|
|||
The mapping from id -> UIEventSource<properties>
|
||||
*/
|
||||
public allElements: ElementStorage = new ElementStorage();
|
||||
/**
|
||||
THe change handler
|
||||
*/
|
||||
public changes: Changes;
|
||||
|
||||
|
||||
/**
|
||||
The latest element that was selected
|
||||
*/
|
||||
|
@ -48,9 +44,6 @@ export default class ElementsState extends FeatureSwitchState {
|
|||
constructor(layoutToUse: LayoutConfig) {
|
||||
super(layoutToUse);
|
||||
|
||||
// @ts-ignore
|
||||
this.changes = new Changes(this, layoutToUse?.isLeftRightSensitive() ?? false)
|
||||
{
|
||||
// -- Location control initialization
|
||||
const zoom = UIEventSource.asFloat(
|
||||
QueryParameters.GetQueryParameter(
|
||||
|
@ -85,10 +78,7 @@ export default class ElementsState extends FeatureSwitchState {
|
|||
lat.setData(latlonz.lat);
|
||||
lon.setData(latlonz.lon);
|
||||
});
|
||||
}
|
||||
|
||||
new ChangeToElementsActor(this.changes, this.allElements)
|
||||
new PendingChangesUploader(this.changes, this.selectedElement);
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -271,6 +271,7 @@ export default class MapState extends UserRelatedState {
|
|||
let gpsLayerDef: FilteredLayer = this.filteredLayers.data.filter(l => l.layerDef.id === "gps_location_history")[0]
|
||||
if (gpsLayerDef !== undefined) {
|
||||
this.historicalUserLocations = new SimpleFeatureSource(gpsLayerDef, Tiles.tile_index(0, 0, 0), features);
|
||||
this.changes.setHistoricalUserLocations(this.historicalUserLocations)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@ import {Utils} from "../../Utils";
|
|||
import Locale from "../../UI/i18n/Locale";
|
||||
import ElementsState from "./ElementsState";
|
||||
import SelectedElementTagsUpdater from "../Actors/SelectedElementTagsUpdater";
|
||||
import {Changes} from "../Osm/Changes";
|
||||
import ChangeToElementsActor from "../Actors/ChangeToElementsActor";
|
||||
import PendingChangesUploader from "../Actors/PendingChangesUploader";
|
||||
|
||||
/**
|
||||
* The part of the state which keeps track of user-related stuff, e.g. the OSM-connection,
|
||||
|
@ -20,6 +23,10 @@ export default class UserRelatedState extends ElementsState {
|
|||
The user credentials
|
||||
*/
|
||||
public osmConnection: OsmConnection;
|
||||
/**
|
||||
THe change handler
|
||||
*/
|
||||
public changes: Changes;
|
||||
/**
|
||||
* The key for mangrove
|
||||
*/
|
||||
|
@ -44,6 +51,13 @@ export default class UserRelatedState extends ElementsState {
|
|||
attemptLogin: options?.attemptLogin
|
||||
})
|
||||
|
||||
|
||||
this.changes = new Changes(this, layoutToUse?.isLeftRightSensitive() ?? false)
|
||||
|
||||
|
||||
new ChangeToElementsActor(this.changes, this.allElements)
|
||||
new PendingChangesUploader(this.changes, this.selectedElement);
|
||||
|
||||
this.mangroveIdentity = new MangroveIdentity(
|
||||
this.osmConnection.GetLongPreference("identity", "mangrove")
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue