group label changes witch are only 1-2sec away from each other ...
:point_up: as gh does it too :) - save space
Mind if I take this? It'd be good if I can get some pointers too, but I think I can figure it out on my own
I've gone into the translation and added issues.add_labels_at
, but I assume I will need some sort of macro for the label badge in order to loop them, since AFAIK the translations aren't static. should I add another option to comments.tmpl
for the multiple badges in-line?
You should probably figure out the overal design/plan first if you have questions as "some sort of macro" would be the entire problem to solve here -- golang template loops are super limited to just range unfortunately and our design currently is based on ranging one entry at a time inside template which makes this problem more annoying than it should be : (
I'm thinking having the loop over the labels on the function that actually calls the template, then this way we avoid looping inside the template.
The template loops over ever single "comment" entry for an issue, some of which will be "xx added y label" type comments" and they are all stored as individual comment entries in the db. there is no individual label loop
Oh no that isn't what I meant, I meant that before we pass the comments along to the template, we find the labels that were added at the same time and group them together into one "comment". Seems like the most feasible option to me.
Heres something sort of similar for reference that filters comments before page load:
https://github.com/go-gitea/gitea/blob/d2ad4dec63cb3ee94b5ba997aa2e2514abc53096/routers/repo/issue.go#L1075
https://github.com/go-gitea/gitea/blob/d2ad4dec63cb3ee94b5ba997aa2e2514abc53096/routers/repo/issue.go#L2279
Okay, so here's what I'm doing:
What do you think?
Also, I think this might mess with the translations, should I add a new translation string? Since non-up-to-date translations will have the HTML for the label, which will now be inserted with a function.
@pta2002 Yes, please.
Should I add a "Labels" field to the Comment model?
So something like:
type Comment struct {
...
Labels []*Label
...
}
I think you can add a function like GetGroupedLabels() for the Comment type witch return []*Label ... this way the struct dont get more overloaded and you still be able to use it in the template
How'd this work? Something like this wouldn't filter out the other label comments from getting passed into the view.
I'm trying to check how the "removed" comments work, but as far as I can tell it checks for the Content
field in the Label
struct. What does this field contain? How should I check if a comment is for an added Label or for a removed Label?
it puts a 1 in the comment field if it was added, nothing if it was deleted so you could check with
if comment.Content {
/*added*/ } else {
/* deleted */
}
How'd this work? Something like this wouldn't filter out the other label comments from getting passed into the view.
Hmm in the end adding a Labels []*Labels `xorm:"-"`
field to Comment struct + new CommentType is the easyest way of doing so...
Closed since #13304 merged.
Most helpful comment
it puts a 1 in the comment field if it was added, nothing if it was deleted so you could check with