mirror of
https://github.com/status-im/status-go.git
synced 2025-01-29 16:06:47 +00:00
chore(mentions)_: Add suggestion limit for mention recommendations (#5774)
- Introduce a constant `suggestionsLimit` set to 15 - Apply the suggestion limit when calculating mention suggestions - Replace unlimited suggestions (-1) with the new limit in relevant function calls - This change aims to improve performance and user experience by limiting the number of mention suggestions displayed
This commit is contained in:
parent
28e7a364c7
commit
82ba10ede7
@ -30,6 +30,8 @@ const (
|
|||||||
charCodeBlock = "`"
|
charCodeBlock = "`"
|
||||||
|
|
||||||
intUnknown = -1
|
intUnknown = -1
|
||||||
|
|
||||||
|
suggestionsLimit = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -370,7 +372,7 @@ func (m *MentionManager) calculateSuggestionsWithMentionableUsers(chatID string,
|
|||||||
searchedText := strings.ToLower(subs(fullText, atSignIdx+1, end))
|
searchedText := strings.ToLower(subs(fullText, atSignIdx+1, end))
|
||||||
m.logger.Debug("calculateSuggestionsWithMentionableUsers", zap.Int("atSignIdx", atSignIdx), zap.String("searchedText", searchedText), zap.String("fullText", fullText), zap.Any("state", state), zap.Int("end", end))
|
m.logger.Debug("calculateSuggestionsWithMentionableUsers", zap.Int("atSignIdx", atSignIdx), zap.String("searchedText", searchedText), zap.String("fullText", fullText), zap.Any("state", state), zap.Int("end", end))
|
||||||
if end-atSignIdx <= 100 {
|
if end-atSignIdx <= 100 {
|
||||||
suggestions = getUserSuggestions(mentionableUsers, searchedText, -1)
|
suggestions = getUserSuggestions(mentionableUsers, searchedText, suggestionsLimit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -729,7 +731,7 @@ func matchMention(text string, users map[string]*MentionableUser, mentionKeyIdx
|
|||||||
searchedText = string(tt[:lastChar])
|
searchedText = string(tt[:lastChar])
|
||||||
}
|
}
|
||||||
|
|
||||||
userSuggestions := getUserSuggestions(users, searchedText, -1)
|
userSuggestions := getUserSuggestions(users, searchedText, suggestionsLimit)
|
||||||
userSuggestionsCnt := len(userSuggestions)
|
userSuggestionsCnt := len(userSuggestions)
|
||||||
switch {
|
switch {
|
||||||
case userSuggestionsCnt == 0:
|
case userSuggestionsCnt == 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user