package shelves
|
|
|
|
import "git.brettb.xyz/goinv/client/internal/types"
|
|
|
|
func (a *Shelves) UpdateData() {
|
|
a.UpdateShelfData()
|
|
a.UpdateBuildingData()
|
|
}
|
|
|
|
func (a *Shelves) UpdateShelfData() {
|
|
shelves, err := a.shelfListFunc()
|
|
a.shelfList.mu.Lock()
|
|
defer a.shelfList.mu.Unlock()
|
|
if err != nil {
|
|
a.displayError("could not retrieve shelves", err)
|
|
a.shelfList.dirty = true
|
|
return
|
|
}
|
|
a.shelfList.dirty = false
|
|
a.shelfList.report = shelves
|
|
}
|
|
|
|
func (a *Shelves) UpdateBuildingData() {
|
|
buildings, err := a.buildingListFunc()
|
|
if err != nil {
|
|
a.displayError("could not retrieve buildings", err)
|
|
return
|
|
}
|
|
a.buildingCache.mu.Lock()
|
|
a.buildingCache.report = buildings
|
|
a.buildingCache.mu.Unlock()
|
|
}
|
|
|
|
func (a *Shelves) getShelfData() []types.ShelfLocation {
|
|
a.shelfList.mu.Lock()
|
|
shelfReport := a.shelfList.report
|
|
defer a.shelfList.mu.Unlock()
|
|
|
|
return shelfReport
|
|
}
|
|
|
|
func (a *Shelves) getBuildingData() map[uint64]types.Building {
|
|
a.buildingCache.mu.Lock()
|
|
buildingReport := a.buildingCache.report
|
|
defer a.buildingCache.mu.Unlock()
|
|
|
|
return buildingReport
|
|
}
|