Merge branch 'develop' of github.com:pietervdvn/MapComplete into develop
This commit is contained in:
commit
2ed6e04a7a
7 changed files with 17 additions and 15 deletions
|
@ -11,7 +11,7 @@ import FeatureSource from "../FeatureSource/FeatureSource";
|
|||
import {ElementStorage} from "../ElementStorage";
|
||||
import {GeoLocationPointProperties} from "../Actors/GeoLocationHandler";
|
||||
import {GeoOperations} from "../GeoOperations";
|
||||
import {ChangesetTag} from "./ChangesetHandler";
|
||||
import {ChangesetHandler, ChangesetTag} from "./ChangesetHandler";
|
||||
import {OsmConnection} from "./OsmConnection";
|
||||
|
||||
/**
|
||||
|
@ -33,6 +33,7 @@ export class Changes {
|
|||
private readonly isUploading = new UIEventSource(false);
|
||||
private readonly previouslyCreated: OsmObject[] = []
|
||||
private readonly _leftRightSensitive: boolean;
|
||||
private _changesetHandler: ChangesetHandler;
|
||||
|
||||
constructor(
|
||||
state?: {
|
||||
|
@ -47,6 +48,7 @@ export class Changes {
|
|||
// If a pending change contains a negative ID, we save that
|
||||
this._nextId = Math.min(-1, ...this.pendingChanges.data?.map(pch => pch.id) ?? [])
|
||||
this.state = state;
|
||||
this._changesetHandler = state?.osmConnection?.CreateChangesetHandler(state.allElements, this)
|
||||
|
||||
// Note: a changeset might be reused which was opened just before and might have already used some ids
|
||||
// This doesn't matter however, as the '-1' is per piecewise upload, not global per changeset
|
||||
|
@ -299,7 +301,7 @@ export class Changes {
|
|||
...perBinMessage
|
||||
]
|
||||
|
||||
await this.state.osmConnection.changesetHandler.UploadChangeset(
|
||||
await this._changesetHandler.UploadChangeset(
|
||||
(csId) => Changes.createChangesetFor("" + csId, changes),
|
||||
metatags,
|
||||
openChangeset
|
||||
|
|
|
@ -23,6 +23,14 @@ export class ChangesetHandler {
|
|||
private readonly auth: any;
|
||||
private readonly backend: string;
|
||||
|
||||
/**
|
||||
* Use 'osmConnection.CreateChangesetHandler' instead
|
||||
* @param dryRun
|
||||
* @param osmConnection
|
||||
* @param allElements
|
||||
* @param changes
|
||||
* @param auth
|
||||
*/
|
||||
constructor(dryRun: UIEventSource<boolean>,
|
||||
osmConnection: OsmConnection,
|
||||
allElements: ElementStorage,
|
||||
|
|
|
@ -48,7 +48,6 @@ export class OsmConnection {
|
|||
public isLoggedIn: UIEventSource<boolean>
|
||||
public loadingStatus = new UIEventSource<"not-attempted" | "loading" | "error" | "logged-in">("not-attempted")
|
||||
public preferencesHandler: OsmPreferences;
|
||||
public changesetHandler: ChangesetHandler;
|
||||
public readonly _oauth_config: {
|
||||
oauth_consumer_key: string,
|
||||
oauth_secret: string,
|
||||
|
@ -64,8 +63,6 @@ export class OsmConnection {
|
|||
constructor(options: {
|
||||
dryRun?: UIEventSource<boolean>,
|
||||
fakeUser?: false | boolean,
|
||||
allElements: ElementStorage,
|
||||
changes: Changes,
|
||||
oauth_token?: UIEventSource<string>,
|
||||
// Used to keep multiple changesets open and to write to the correct changeset
|
||||
singlePage?: boolean,
|
||||
|
@ -103,7 +100,6 @@ export class OsmConnection {
|
|||
|
||||
this.preferencesHandler = new OsmPreferences(this.auth, this);
|
||||
|
||||
this.changesetHandler = new ChangesetHandler(this._dryRun, this, options.allElements, options.changes, this.auth);
|
||||
if (options.oauth_token?.data !== undefined) {
|
||||
console.log(options.oauth_token.data)
|
||||
const self = this;
|
||||
|
@ -122,6 +118,10 @@ export class OsmConnection {
|
|||
console.log("Not authenticated");
|
||||
}
|
||||
}
|
||||
|
||||
public CreateChangesetHandler(allElements: ElementStorage, changes: Changes){
|
||||
return new ChangesetHandler(this._dryRun, this, allElements, changes, this.auth);
|
||||
}
|
||||
|
||||
public GetPreference(key: string, prefix: string = "mapcomplete-"): UIEventSource<string> {
|
||||
return this.preferencesHandler.GetPreference(key, prefix);
|
||||
|
|
|
@ -375,7 +375,7 @@ export default class MapState extends UserRelatedState {
|
|||
} else if (layer.syncSelection === "global") {
|
||||
isDisplayed = this.getPref("layer-" + layer.id + "-enabled", layer)
|
||||
} else {
|
||||
isDisplayed = QueryParameters.GetBooleanQueryParameter("layer-" + layer.id + "-enabled",layer.shownByDefault, "Wether or not layer "+layer.id+" is shown")
|
||||
isDisplayed = QueryParameters.GetBooleanQueryParameter("layer-" + layer.id, layer.shownByDefault, "Wether or not layer "+layer.id+" is shown")
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -33,10 +33,8 @@ export default class UserRelatedState extends ElementsState {
|
|||
super(layoutToUse);
|
||||
|
||||
this.osmConnection = new OsmConnection({
|
||||
changes: this.changes,
|
||||
dryRun: this.featureSwitchIsTesting,
|
||||
fakeUser: this.featureSwitchFakeUser.data,
|
||||
allElements: this.allElements,
|
||||
oauth_token: QueryParameters.GetQueryParameter(
|
||||
"oauth_token",
|
||||
undefined,
|
||||
|
|
|
@ -224,8 +224,6 @@ class AutomatonGui {
|
|||
constructor() {
|
||||
|
||||
const osmConnection = new OsmConnection({
|
||||
allElements: undefined,
|
||||
changes: undefined,
|
||||
singlePage: false,
|
||||
oauth_token: QueryParameters.GetQueryParameter("oauth_token", "OAuth token")
|
||||
});
|
||||
|
|
|
@ -2,8 +2,6 @@ import T from "./TestHelper";
|
|||
import UserDetails, {OsmConnection} from "../Logic/Osm/OsmConnection";
|
||||
import {UIEventSource} from "../Logic/UIEventSource";
|
||||
import ScriptUtils from "../scripts/ScriptUtils";
|
||||
import {ElementStorage} from "../Logic/ElementStorage";
|
||||
import {Changes} from "../Logic/Osm/Changes";
|
||||
|
||||
|
||||
export default class OsmConnectionSpec extends T {
|
||||
|
@ -19,8 +17,6 @@ export default class OsmConnectionSpec extends T {
|
|||
() => {
|
||||
const osmConn = new OsmConnection({
|
||||
osmConfiguration: "osm-test",
|
||||
allElements: new ElementStorage(),
|
||||
changes: new Changes(),
|
||||
oauth_token: new UIEventSource<string>(OsmConnectionSpec._osm_token)
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue