mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 01:32:25 -05:00
[bugfix] self-referencing collection pages for status replies (#2364)
This commit is contained in:
parent
efefdb1323
commit
16275853eb
24 changed files with 611 additions and 427 deletions
|
|
@ -131,3 +131,20 @@ func (b Boundary) Find(in []string) int {
|
|||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// Boundary_FindFunc is functionally equivalent to Boundary{}.Find() but for an arbitrary type with ID.
|
||||
// Note: this is not a Boundary{} method as Go generics are not supported in method receiver functions.
|
||||
func Boundary_FindFunc[T any](b Boundary, in []T, get func(T) string) int { //nolint:revive
|
||||
if get == nil {
|
||||
panic("nil function")
|
||||
}
|
||||
if b.Value == "" {
|
||||
return -1
|
||||
}
|
||||
for i := range in {
|
||||
if get(in[i]) == b.Value {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue