Small improvements

This commit is contained in:
Pieter Vander Vennet 2022-04-28 00:29:51 +02:00
parent c202ba606b
commit 861b9a3cdd
3 changed files with 7 additions and 7 deletions

View file

@ -1,4 +1,3 @@
// @ts-ignore
import osmAuth from "osm-auth";
import {UIEventSource} from "../UIEventSource";
import {OsmPreferences} from "./OsmPreferences";
@ -222,7 +221,7 @@ export class OsmConnection {
});
}
public closeNote(id: number | string, text?: string): Promise<any> {
public closeNote(id: number | string, text?: string): Promise<void> {
let textSuffix = ""
if ((text ?? "") !== "") {
textSuffix = "?text=" + encodeURIComponent(text)
@ -249,7 +248,7 @@ export class OsmConnection {
}
public reopenNote(id: number | string, text?: string): Promise<any> {
public reopenNote(id: number | string, text?: string): Promise<void> {
if (this._dryRun.data) {
console.warn("Dryrun enabled - not actually reopening note ", id, " with text ", text)
return new Promise((ok, error) => {
@ -313,7 +312,7 @@ export class OsmConnection {
}
public addCommentToNode(id: number | string, text: string): Promise<any> {
public addCommentToNode(id: number | string, text: string): Promise<void> {
if (this._dryRun.data) {
console.warn("Dryrun enabled - not actually adding comment ", text, "to note ", id)
return new Promise((ok, error) => {

View file

@ -69,7 +69,7 @@ export abstract class OsmObject {
return rawData.elements[0].tags
}
static async DownloadObjectAsync(id: string): Promise<OsmObject> {
static async DownloadObjectAsync(id: string): Promise<OsmObject | undefined> {
const splitted = id.split("/");
const type = splitted[0];
const idN = Number(splitted[1]);
@ -80,6 +80,9 @@ export abstract class OsmObject {
const full = (id.startsWith("way")) ? "/full" : "";
const url = `${OsmObject.backendURL}api/0.6/${id}${full}`;
const rawData = await Utils.downloadJsonCached(url, 1000)
if(rawData === undefined){
return undefined
}
// A full query might contain more then just the requested object (e.g. nodes that are part of a way, where we only want the way)
const parsed = OsmObject.ParseObjects(rawData.elements);
// Lets fetch the object we need

View file

@ -4,8 +4,6 @@ import {Utils} from "../../Utils";
import {UIEventSource} from "../UIEventSource";
import {BBox} from "../BBox";
import * as osmtogeojson from "osmtogeojson";
// @ts-ignore
import {Tag} from "../Tags/Tag"; // used in doctest
/**
* Interfaces overpass to get all the latest data