loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[UI] Hide consecutive additions and removals of the same label (#13315)

authored by

Pedro Alves and committed by
GitHub
8e368e70 afe9d791

+25 -2
+25 -2
routers/repo/issue.go
··· 2418 2418 c.AddedLabels[0] = c.Label 2419 2419 } 2420 2420 } else { 2421 + // Remove duplicated "added" and "removed" labels 2422 + // This way, adding and immediately removing a label won't generate a comment. 2423 + var appendingTo *[]*models.Label 2424 + var other *[]*models.Label 2425 + 2421 2426 if removingCur { 2422 - prev.RemovedLabels = append(prev.RemovedLabels, c.Label) 2427 + appendingTo = &prev.RemovedLabels 2428 + other = &prev.AddedLabels 2423 2429 } else { 2424 - prev.AddedLabels = append(prev.AddedLabels, c.Label) 2430 + appendingTo = &prev.AddedLabels 2431 + other = &prev.RemovedLabels 2432 + } 2433 + 2434 + appending := true 2435 + 2436 + for i := 0; i < len(*other); i++ { 2437 + l := (*other)[i] 2438 + if l.ID == c.Label.ID { 2439 + *other = append((*other)[:i], (*other)[i+1:]...) 2440 + appending = false 2441 + break 2442 + } 2425 2443 } 2444 + 2445 + if appending { 2446 + *appendingTo = append(*appendingTo, c.Label) 2447 + } 2448 + 2426 2449 prev.CreatedUnix = c.CreatedUnix 2427 2450 issue.Comments = append(issue.Comments[:i], issue.Comments[i+1:]...) 2428 2451 continue