Revert "Add filter support to mentions view"

This reverts commit a08e70cb92.
main
James Mills 3 days ago
parent a08e70cb92
commit 2d7cc39245
Signed by: prologic
GPG Key ID: AC4C014F1440EBD6
  1. 34
      internal/cache.go
  2. 12
      internal/view_handlers.go

@ -1755,19 +1755,17 @@ func (cache *Cache) GroupBy(g GroupFunc) (res map[string]types.Twts) {
return GroupTwtsBy(cache.GetAll(false), g)
}
func (cache *Cache) getMentions(u *User, refresh bool, fffs ...FilterFuncFactory) types.Twts {
// GetMentions ...
// XXX: To be removed once FeatureFilterAndLists is promoted
// TODO: Remove my when FeatureFilterAndLists is the default
func (cache *Cache) GetMentions(u *User, refresh bool) types.Twts {
key := fmt.Sprintf("mentions:%s", u.Username)
cache.mu.RLock()
cached, ok := cache.Views[key]
cache.mu.RUnlock()
if ok && !refresh {
if cache.conf.Features.IsEnabled(FeatureFilterAndLists) {
var ffs []FilterFunc
for _, fff := range fffs {
ffs = append(ffs, fff(cache, u))
}
return FilterTwtsBy(cached.GetTwts(), ffs...)
}
return cached.GetTwts()
}
@ -1775,29 +1773,13 @@ func (cache *Cache) getMentions(u *User, refresh bool, fffs ...FilterFuncFactory
twts := cache.filterTwts(u, mentions)
sort.Sort(twts)
cache.mu.Lock()
cache.Views[key] = NewCachedTwts(twts, "")
if cache.conf.Features.IsEnabled(FeatureFilterAndLists) {
var ffs []FilterFunc
for _, fff := range fffs {
ffs = append(ffs, fff(cache, u))
}
return FilterTwtsBy(cached.GetTwts(), ffs...)
}
cache.mu.Unlock()
return twts
}
// GetMentions ...
// XXX: To be removed once FeatureFilterAndLists is promoted
// TODO: Remove my when FeatureFilterAndLists is the default
func (cache *Cache) GetMentions(u *User, refresh bool, fffs ...FilterFuncFactory) types.Twts {
cache.mu.Lock()
defer cache.mu.Unlock()
return cache.getMentions(u, refresh, fffs...)
}
// IsCached ...
func (cache *Cache) IsCached(url string) bool {
cache.mu.RLock()

@ -209,17 +209,7 @@ func (s *Server) MentionsHandler() httprouter.Handle {
ctx := NewContext(s, r)
ctx.Translate(s.translator)
ctx.Filters = r.URL.Query()["f"]
fffs := GetFilterFuncFactories(ctx.Filters)
var twts types.Twts
if s.config.Features.IsEnabled(FeatureFilterAndLists) {
twts = s.cache.GetMentions(ctx.User, false, fffs...)
} else {
twts = s.getMentionedTwts(ctx.User)
}
twts := s.getMentionedTwts(ctx.User)
var pagedTwts types.Twts
page := SafeParseInt(r.FormValue("p"), 1)

Loading…
Cancel
Save