forked from MapComplete/MapComplete
Small refactoring, fix logic which possibly caused #659 (to be confirmed)
This commit is contained in:
parent
776387a640
commit
f447854834
6 changed files with 16 additions and 23 deletions
|
@ -104,7 +104,7 @@ export class Changes {
|
|||
* Uploads all the pending changes in one go.
|
||||
* Triggered by the 'PendingChangeUploader'-actor in Actors
|
||||
*/
|
||||
public async flushChanges(flushreason: string = undefined, openChangeset?: UIEventSource<number>): Promise<void> {
|
||||
public async flushChanges(flushreason: string = undefined): Promise<void> {
|
||||
if (this.pendingChanges.data.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ export class Changes {
|
|||
console.log("Uploading changes due to: ", flushreason)
|
||||
this.isUploading.setData(true)
|
||||
try {
|
||||
const csNumber = await this.flushChangesAsync(openChangeset)
|
||||
const csNumber = await this.flushChangesAsync()
|
||||
this.isUploading.setData(false)
|
||||
console.log("Changes flushed. Your changeset is " + csNumber);
|
||||
} catch (e) {
|
||||
|
@ -213,7 +213,7 @@ export class Changes {
|
|||
|
||||
const osmObjects = Utils.NoNull(await Promise.all(neededIds.map(async id =>
|
||||
OsmObject.DownloadObjectAsync(id).catch(e => {
|
||||
console.error("Could not download OSM-object", id, " dropping it from the changes")
|
||||
console.error("Could not download OSM-object", id, " dropping it from the changes ("+e+")")
|
||||
pending = pending.filter(ch => ch.type + "/" + ch.id !== id)
|
||||
return undefined;
|
||||
}))));
|
||||
|
@ -309,7 +309,7 @@ export class Changes {
|
|||
return true;
|
||||
}
|
||||
|
||||
private async flushChangesAsync(openChangeset?: UIEventSource<number>): Promise<void> {
|
||||
private async flushChangesAsync(): Promise<void> {
|
||||
const self = this;
|
||||
try {
|
||||
// At last, we build the changeset and upload
|
||||
|
@ -327,8 +327,7 @@ export class Changes {
|
|||
const successes = await Promise.all(Array.from(pendingPerTheme,
|
||||
async ([theme, pendingChanges]) => {
|
||||
try {
|
||||
if (openChangeset === undefined) {
|
||||
openChangeset = this.state.osmConnection.GetPreference("current-open-changeset-" + theme).map(
|
||||
const openChangeset = this.state.osmConnection.GetPreference("current-open-changeset-" + theme).map(
|
||||
str => {
|
||||
const n = Number(str);
|
||||
if (isNaN(n)) {
|
||||
|
@ -338,7 +337,6 @@ export class Changes {
|
|||
}, [], n => "" + n
|
||||
);
|
||||
console.log("Using current-open-changeset-" + theme + " from the preferences, got " + openChangeset.data)
|
||||
}
|
||||
|
||||
return await self.flushSelectChanges(pendingChanges, openChangeset);
|
||||
} catch (e) {
|
||||
|
|
|
@ -23,8 +23,7 @@ export class ChangesetHandler {
|
|||
private readonly auth: any;
|
||||
private readonly backend: string;
|
||||
|
||||
constructor(layoutName: string,
|
||||
dryRun: UIEventSource<boolean>,
|
||||
constructor(dryRun: UIEventSource<boolean>,
|
||||
osmConnection: OsmConnection,
|
||||
allElements: ElementStorage,
|
||||
changes: Changes,
|
||||
|
|
|
@ -67,7 +67,6 @@ export class OsmConnection {
|
|||
changes: Changes,
|
||||
oauth_token?: UIEventSource<string>,
|
||||
// Used to keep multiple changesets open and to write to the correct changeset
|
||||
layoutName: string,
|
||||
singlePage?: boolean,
|
||||
osmConfiguration?: "osm" | "osm-test",
|
||||
attemptLogin?: true | boolean
|
||||
|
@ -103,7 +102,7 @@ export class OsmConnection {
|
|||
|
||||
this.preferencesHandler = new OsmPreferences(this.auth, this);
|
||||
|
||||
this.changesetHandler = new ChangesetHandler(options.layoutName, this._dryRun, this, options.allElements, options.changes, this.auth);
|
||||
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;
|
||||
|
|
|
@ -42,7 +42,6 @@ export default class UserRelatedState extends ElementsState {
|
|||
undefined,
|
||||
"Used to complete the login"
|
||||
),
|
||||
layoutName: layoutToUse?.id,
|
||||
osmConfiguration: <'osm' | 'osm-test'>this.featureSwitchApiURL.data,
|
||||
attemptLogin: options?.attemptLogin
|
||||
})
|
||||
|
|
|
@ -226,7 +226,6 @@ class AutomatonGui {
|
|||
const osmConnection = new OsmConnection({
|
||||
allElements: undefined,
|
||||
changes: undefined,
|
||||
layoutName: "automaton",
|
||||
singlePage: false,
|
||||
oauth_token: QueryParameters.GetQueryParameter("oauth_token", "OAuth token")
|
||||
});
|
||||
|
|
|
@ -19,7 +19,6 @@ export default class OsmConnectionSpec extends T {
|
|||
() => {
|
||||
const osmConn = new OsmConnection({
|
||||
osmConfiguration: "osm-test",
|
||||
layoutName: "Unit test",
|
||||
allElements: new ElementStorage(),
|
||||
changes: new Changes(),
|
||||
oauth_token: new UIEventSource<string>(OsmConnectionSpec._osm_token)
|
||||
|
|
Loading…
Reference in a new issue