Update the code to download the changeset metadata, this endpoint changed (!)

This commit is contained in:
Pieter Vander Vennet 2024-08-26 01:06:50 +02:00
parent 006941d21b
commit 407384cc23
2 changed files with 7 additions and 5 deletions

View file

@ -237,9 +237,9 @@ export class Changes {
console.log("Uploading changes due to: ", flushreason) console.log("Uploading changes due to: ", flushreason)
this.isUploading.setData(true) this.isUploading.setData(true)
try { try {
const csNumber = await this.flushChangesAsync() await this.flushChangesAsync()
this.isUploading.setData(false) this.isUploading.setData(false)
console.log("Changes flushed. Your changeset is " + csNumber) console.log("Changes flushed")
this.errors.setData([]) this.errors.setData([])
} catch (e) { } catch (e) {
this._reportError(e) this._reportError(e)

View file

@ -14,10 +14,10 @@ export interface ChangesetTag {
} }
export type ChangesetMetadata = { export type ChangesetMetadata = {
type: "changeset"
id: number id: number
created_at: string created_at: string
open: boolean open: boolean
closed_at?: string
uid: number uid: number
user: string user: string
changes_count: number changes_count: number
@ -164,10 +164,12 @@ export class ChangesetHandler {
return return
} }
console.log("Trying to reuse changeset", openChangeset.data)
if (openChangeset.data) { if (openChangeset.data) {
try { try {
const csId = openChangeset.data const csId = openChangeset.data
const oldChangesetMeta = await this.GetChangesetMeta(csId) const oldChangesetMeta = await this.GetChangesetMeta(csId)
console.log("Got metadata:", oldChangesetMeta, "isopen", oldChangesetMeta?.open)
if (oldChangesetMeta.open) { if (oldChangesetMeta.open) {
// We can hopefully reuse the changeset // We can hopefully reuse the changeset
@ -357,8 +359,8 @@ export class ChangesetHandler {
private async GetChangesetMeta(csId: number): Promise<ChangesetMetadata> { private async GetChangesetMeta(csId: number): Promise<ChangesetMetadata> {
const url = `${this.backend}/api/0.6/changeset/${csId}` const url = `${this.backend}/api/0.6/changeset/${csId}`
const csData = await Utils.downloadJson<{ elements: ChangesetMetadata[] }>(url) const csData = await Utils.downloadJson<{ changeset: ChangesetMetadata }>(url)
return csData.elements[0] return csData.changeset
} }
/** /**