From d9a79618062bb8457a3fb5b900fa4b81c0fc32be Mon Sep 17 00:00:00 2001 From: "pakintada@gmail.com" Date: Thu, 8 Feb 2024 14:39:21 +0700 Subject: [PATCH] fix default broke material and topping route --- client/src/app/features/recipes/recipes.component.ts | 9 ++++++++- server/data/data.go | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/client/src/app/features/recipes/recipes.component.ts b/client/src/app/features/recipes/recipes.component.ts index f818a87..4c3121d 100644 --- a/client/src/app/features/recipes/recipes.component.ts +++ b/client/src/app/features/recipes/recipes.component.ts @@ -185,10 +185,17 @@ export class RecipesComponent implements OnInit, OnDestroy, AfterViewInit { // FIXME: Lag assigned - this.recipesDashboard$.subscribe((data) => { + this.recipesDashboard$.subscribe(async (data) => { this.currentVersion = data.configNumber; console.log('current version', this.currentVersion); console.log("data : ", data); + + // set default country and filename if was "default" + let currentFile = this._recipeService.getCurrentFile(); + if(currentFile == "default"){ + await AsyncStorage.setItem('currentRecipeCountry', await this._recipeService.getCurrentCountry(this.department!)); + await AsyncStorage.setItem('currentRecipeFile', data.filename); + } }); console.log('ngAfterViewInit::department', this.department); diff --git a/server/data/data.go b/server/data/data.go index b6810b8..945d92e 100644 --- a/server/data/data.go +++ b/server/data/data.go @@ -207,7 +207,12 @@ func (d *Data) GetRecipe(countryID, filename string) *models.Recipe { // do check if match the current pointer if d.CurrentFile[countryID] == filename { - d.taoLogger.Log.Debug("GetRecipe", zap.Any("FileMatchCurrent", "return from stored "+filename), zap.Any("CurrentFile", d.CurrentFile)) + d.taoLogger.Log.Debug("GetRecipe", + zap.Any("FileMatchCurrent", "return from stored "+filename), + zap.Any("CurrentFile", d.CurrentFile), + zap.Any("countryID", countryID)) + + d.taoLogger.Log.Debug("CurrentRecipeOK?", zap.Any("CurrentRecipe", d.CurrentRecipe[countryID] != nil)) // make sure recipe vesion is equal currentConfig := d.CurrentRecipe[countryID].MachineSetting.ConfigNumber @@ -259,6 +264,9 @@ func (d *Data) GetRecipe(countryID, filename string) *models.Recipe { if cached_recipe != nil { d.taoLogger.Log.Debug("GetRecipe", zap.Any("Check on cached recipe invalid", cached_recipe == nil), zap.Any("test config number", cached_recipe.MachineSetting.ConfigNumber)) + // set to current + d.CurrentRecipe[countryID] = cached_recipe + return cached_recipe } recipe, err := helpers.ReadRecipeFile(countryID, filename)