From 400a985c1180d8b5d4f092d436fb9c11d5773191 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Tue, 16 Mar 2021 13:35:18 -0500 Subject: [PATCH] Exclude version query params if no version specified --- src/app/service/api.service.ts | 65 +++++++++++++++++----------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/src/app/service/api.service.ts b/src/app/service/api.service.ts index 9a804ec..7874eb4 100644 --- a/src/app/service/api.service.ts +++ b/src/app/service/api.service.ts @@ -826,7 +826,7 @@ export class ApiService { } // If online, fetch the codium and store/update it locally - this.get(`/code/${PageId}/${NodeId}/get/${CodiumId}?version=${version}`).subscribe({ + this.get(`/code/${PageId}/${NodeId}/get/${CodiumId}${version ? '?version=' + version : ''}`).subscribe({ next: async result => { if ( version ) { return res(result.data); @@ -931,38 +931,39 @@ export class ApiService { } // If online, fetch the columns and sync the local database - this.get(`/db/${PageId}/${NodeId}/get/${DatabaseId}/columns?database_version=${databaseVersion}`).subscribe({ - next: async results => { - // Resolve this first, so the UI doesn't need to wait for the db sync to render - res(results.data); - - if ( databaseVersion ) { - return; - } - - for ( const def of results.data ) { - const existingColumnDef = await this.db.databaseColumns.where({ - DatabaseId, UUID: def.UUID, - }).first() as DatabaseColumn; - - if ( existingColumnDef ) { - existingColumnDef.fillFromRecord(def); - await existingColumnDef.save(); - } else { - const newColumnDef = new DatabaseColumn( - def.headerName, - def.field, - def.DatabaseId, - def.UUID, - def.Type, - def.additionalData, - ); + this.get(`/db/${PageId}/${NodeId}/get/${DatabaseId}/columns${databaseVersion ? '?database_version=' + databaseVersion : ''}`) + .subscribe({ + next: async results => { + // Resolve this first, so the UI doesn't need to wait for the db sync to render + res(results.data); + + if ( databaseVersion ) { + return; + } - await newColumnDef.save(); + for ( const def of results.data ) { + const existingColumnDef = await this.db.databaseColumns.where({ + DatabaseId, UUID: def.UUID, + }).first() as DatabaseColumn; + + if ( existingColumnDef ) { + existingColumnDef.fillFromRecord(def); + await existingColumnDef.save(); + } else { + const newColumnDef = new DatabaseColumn( + def.headerName, + def.field, + def.DatabaseId, + def.UUID, + def.Type, + def.additionalData, + ); + + await newColumnDef.save(); + } } - } - }, - error: rej, + }, + error: rej, }); }); } @@ -1016,7 +1017,7 @@ export class ApiService { } } - this.get(`/db/${PageId}/${NodeId}/get/${DatabaseId}?version=${version}`).subscribe({ + this.get(`/db/${PageId}/${NodeId}/get/${DatabaseId}${version ? '?version=' + version : ''}`).subscribe({ next: async result => { if ( version ) { return res(result.data);