forked from MapComplete/MapComplete
		
	Fix: fix error reporting
This commit is contained in:
		
							parent
							
								
									7f5544c1e5
								
							
						
					
					
						commit
						913add4295
					
				
					 5 changed files with 48 additions and 43 deletions
				
			
		|  | @ -54,7 +54,7 @@ export class Changes { | |||
|                 featureSwitchIsTesting?: Store<boolean> | ||||
|             } | ||||
|             osmConnection: OsmConnection | ||||
|             reportError?: (error: string) => void | ||||
|             reportError?: ((message: string | Error | XMLHttpRequest, extramessage?: string) => void), | ||||
|             featureProperties?: FeaturePropertiesStore | ||||
|             historicalUserLocations?: FeatureSource<Feature<Point, GeoLocationPointProperties>> | ||||
|             allElements?: IndexedFeatureSource | ||||
|  | @ -75,7 +75,7 @@ export class Changes { | |||
|         } | ||||
|         this.state = state | ||||
|         this.backend = state.osmConnection.Backend() | ||||
|         this._reportError = state.reportError | ||||
|         this._reportError = (msg, err) => state.reportError(msg, err) | ||||
|         this._changesetHandler = new ChangesetHandler( | ||||
|             state.featureSwitches?.featureSwitchIsTesting ?? new ImmutableStore(false), | ||||
|             state.osmConnection, | ||||
|  | @ -669,19 +669,24 @@ export class Changes { | |||
|         const createdIds = new Set( | ||||
|             pending.filter((cd) => cd.changes !== undefined).map((cd) => cd.id) | ||||
|         ) | ||||
|         pending.forEach((c) => { | ||||
|             if (c.id < 0) { | ||||
|                 if (createdIds.has(c.id)) { | ||||
|         for (const c of pending) { | ||||
|             let id = c.id | ||||
|             const newId = this._changesetHandler._remappings.get(c.type + "/" + c.id) | ||||
|             if (newId) { | ||||
|                 id = Number(newId.split("/")[1]) | ||||
|             } | ||||
|             if (id < 0) { | ||||
|                 if (createdIds.has(id)) { | ||||
|                     toUpload.push(c) | ||||
|                 } else { | ||||
|                     this._reportError( | ||||
|                         `Got an orphaned change. The 'creation'-change description for ${c.type}/${c.id} got lost. Permanently dropping this change:` + | ||||
|                         `Got an orphaned change. The 'creation'-change description for ${c.type}/${id} got lost. Permanently dropping this change:` + | ||||
|                             JSON.stringify(c) | ||||
|                     ) | ||||
|                 } | ||||
|                 return | ||||
|                 continue | ||||
|             } | ||||
|             const matchFound = !!objects.find((o) => o.id === c.id && o.type === c.type) | ||||
|             const matchFound = !!objects.find((o) => o.id === id && o.type === c.type) | ||||
|             if (matchFound) { | ||||
|                 toUpload.push(c) | ||||
|             } else { | ||||
|  | @ -689,12 +694,12 @@ export class Changes { | |||
|                     "Refusing change about " + | ||||
|                         c.type + | ||||
|                         "/" + | ||||
|                         c.id + | ||||
|                     id + | ||||
|                         " as not in the objects. No internet?" | ||||
|                 ) | ||||
|                 refused.push(c) | ||||
|             } | ||||
|         }) | ||||
|         } | ||||
| 
 | ||||
|         return { refused, toUpload } | ||||
|     } | ||||
|  |  | |||
|  | @ -40,7 +40,8 @@ export class ChangesetHandler { | |||
|     private readonly backend: string | ||||
| 
 | ||||
|     /** | ||||
|      * Contains previously rewritten IDs | ||||
|      * Contains previously rewritten IDs, e.g. {"node/-1" --> "node/123456"} | ||||
|      * | ||||
|      * @private | ||||
|      */ | ||||
|     public readonly _remappings = new Map<string, string>() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue