fix default broke material and topping route

This commit is contained in:
pakintada@gmail.com 2024-02-08 14:39:21 +07:00
parent fb046dadf8
commit d9a7961806
2 changed files with 17 additions and 2 deletions

View file

@ -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);

View file

@ -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)