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 292 type LabelState struct { 293 inner map[string]set 294 } 295 296 func NewLabelState() LabelState { 297 return LabelState{ 298 inner: make(map[string]set), 299 } 300 } 301 302 func (s LabelState) Inner() map[string]set { 303 return s.inner 304 } 305 306 func (s LabelState) ContainsLabel(l string) bool { ··· 347 // this def was deleted, but an op exists, so we just skip over the op 348 return nil 349 } 350 351 switch op.Operation { 352 case LabelOperationAdd:
··· 291 292 type LabelState struct { 293 inner map[string]set 294 + names map[string]string 295 } 296 297 func NewLabelState() LabelState { 298 return LabelState{ 299 inner: make(map[string]set), 300 + names: make(map[string]string), 301 } 302 } 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 + 317 func (s LabelState) Inner() map[string]set { 318 return s.inner 319 + } 320 + 321 + func (s LabelState) SetName(key, name string) { 322 + s.names[key] = name 323 } 324 325 func (s LabelState) ContainsLabel(l string) bool { ··· 366 // this def was deleted, but an op exists, so we just skip over the op 367 return nil 368 } 369 + 370 + state.names[op.OperandKey] = def.Name 371 372 switch op.Operation { 373 case LabelOperationAdd: