Skip to content

Commit

Permalink
Update database.go
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Sep 14, 2023
1 parent 34dce31 commit d0226ae
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions internal/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,31 +78,34 @@ func (lp *LaunchPad) GetMissing(apps *Apps, appType int) error {

// check all apps from config file exist on system
for idx, page := range apps.Pages {
tmp := []any{}
for iidx, item := range page.Items {
switch item.(type) {
case string:
if !slices.Contains(lp.dbApps, item.(string)) {
utils.DoubleIndent(log.WithField("app", item.(string)).Warn)("found app in config that are is not on system")
apps.Pages[idx].Items = append(apps.Pages[idx].Items[:iidx], apps.Pages[idx].Items[iidx+1:]...)
} else {
tmp = append(tmp, item)
}
default:
var folder AppFolder
if err := mapstructure.Decode(item, &folder); err != nil {
return fmt.Errorf("mapstructure unable to decode config folder: %w", err)
}
for fpIdx, fpage := range folder.Pages {
tmp := []any{}
ftmp := []any{}
for _, fitem := range fpage.Items {
if !slices.Contains(lp.dbApps, fitem) {
utils.DoubleIndent(log.WithField("app", fitem).Warn)("found app in config that are is not on system")
} else {
tmp = append(tmp, fitem)
ftmp = append(ftmp, fitem)
}
}
apps.Pages[idx].Items[iidx].(map[string]any)["pages"].([]any)[fpIdx].(map[string]any)["items"] = tmp
apps.Pages[idx].Items[iidx].(map[string]any)["pages"].([]any)[fpIdx].(map[string]any)["items"] = ftmp
}
}
}
apps.Pages[idx].Items = tmp
}

return nil
Expand Down

0 comments on commit d0226ae

Please sign in to comment.