refactor(geomap): avoid parsing XML twice

This commit is contained in:
Elian Doran
2025-06-01 14:18:27 +03:00
parent c5d64c182b
commit 365fd37be5
2 changed files with 18 additions and 7 deletions

View File

@@ -224,13 +224,12 @@ export default class GeoMapTypeWidget extends TypeWidget {
this.gpxLoaded = true;
}
const xmlResponse = await server.get<XMLDocument | Uint8Array>(`notes/${note.noteId}/open`);
const xmlResponse = await server.get<string | Uint8Array>(`notes/${note.noteId}/open`, undefined, true);
let stringResponse: string;
if (xmlResponse instanceof Uint8Array) {
stringResponse = new TextDecoder().decode(xmlResponse);
} else {
// TODO: This is not very efficient as it's probably a string response that is parsed and then converted back to string and parsed again.
stringResponse = new XMLSerializer().serializeToString(xmlResponse)
stringResponse = xmlResponse;
}
const track = new this.L.GPX(stringResponse, {});