package assets
|
|
|
|
import "git.brettb.xyz/goinv/client/internal/types"
|
|
|
|
func (a *Assets) UpdateData() {
|
|
a.UpdateShelfData()
|
|
a.UpdateAssetData()
|
|
}
|
|
|
|
func (a *Assets) UpdateAssetData() {
|
|
assets, err := a.assetListFunc()
|
|
a.assetList.mu.Lock()
|
|
defer a.assetList.mu.Unlock()
|
|
if err != nil {
|
|
a.displayError("could not retrieve assets", err)
|
|
a.assetList.dirty = true
|
|
return
|
|
}
|
|
a.assetList.dirty = false
|
|
a.assetList.report = assets
|
|
}
|
|
|
|
func (a *Assets) UpdateShelfData() {
|
|
shelves, err := a.shelfListFunc()
|
|
if err != nil {
|
|
a.displayError("could not retrieve shelves", err)
|
|
return
|
|
}
|
|
a.shelfLocationCache.mu.Lock()
|
|
a.shelfLocationCache.report = shelves
|
|
a.shelfLocationCache.mu.Unlock()
|
|
}
|
|
|
|
func (a *Assets) getAssetData() []types.Asset {
|
|
a.assetList.mu.Lock()
|
|
assetReport := a.assetList.report
|
|
defer a.assetList.mu.Unlock()
|
|
|
|
return assetReport
|
|
}
|
|
|
|
func (a *Assets) getShelfData() map[uint64]types.ShelfLocation {
|
|
a.shelfLocationCache.mu.Lock()
|
|
shelfReport := a.shelfLocationCache.report
|
|
defer a.shelfLocationCache.mu.Unlock()
|
|
|
|
return shelfReport
|
|
}
|