Monorepo for Tangled

appview: add label name resolution to LabelState

Signed-off-by: Thomas Karpiniec <tkarpiniec@icloud.com>

authored by

Thomas Karpiniec and committed by tangled.org 67c0e9bc ce74be2b

+21
+21
appview/models/label.go
··· 291 291 292 292 type LabelState struct { 293 293 inner map[string]set 294 + names map[string]string 294 295 } 295 296 296 297 func NewLabelState() LabelState { 297 298 return LabelState{ 298 299 inner: make(map[string]set), 300 + names: make(map[string]string), 299 301 } 300 302 } 301 303 304 + func (s LabelState) LabelNames() []string { 305 + var result []string 306 + for key, valset := range s.inner { 307 + if valset == nil { 308 + continue 309 + } 310 + if name, ok := s.names[key]; ok { 311 + result = append(result, name) 312 + } 313 + } 314 + return result 315 + } 316 + 302 317 func (s LabelState) Inner() map[string]set { 303 318 return s.inner 319 + } 320 + 321 + func (s LabelState) SetName(key, name string) { 322 + s.names[key] = name 304 323 } 305 324 306 325 func (s LabelState) ContainsLabel(l string) bool { ··· 347 366 // this def was deleted, but an op exists, so we just skip over the op 348 367 return nil 349 368 } 369 + 370 + state.names[op.OperandKey] = def.Name 350 371 351 372 switch op.Operation { 352 373 case LabelOperationAdd: