mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-07 05:25:12 +00:00
Improve sticker and emoji search
This commit is contained in:
@@ -69,21 +69,16 @@ public final class EmojiSuggestionsComponent: Component {
|
||||
|
||||
var existingIds = Set<EngineMedia.Id>()
|
||||
for entry in view.entries {
|
||||
guard let item = entry.item as? StickerPackItem else {
|
||||
guard let item = entry.item as? StickerPackItem, !item.file.isPremiumEmoji || hasPremium else {
|
||||
continue
|
||||
}
|
||||
for attribute in item.file.attributes {
|
||||
switch attribute {
|
||||
case let .CustomEmoji(_, _, alt, _):
|
||||
if alt == query || (!normalizedQuery.isEmpty && alt == normalizedQuery) {
|
||||
if !item.file.isPremiumEmoji || hasPremium {
|
||||
if !existingIds.contains(item.file.fileId) {
|
||||
existingIds.insert(item.file.fileId)
|
||||
result.append(item.file)
|
||||
}
|
||||
}
|
||||
let stringRepresentations = item.getStringRepresentationsOfIndexKeys()
|
||||
for stringRepresentation in stringRepresentations {
|
||||
if stringRepresentation == query || (!normalizedQuery.isEmpty && stringRepresentation == normalizedQuery) {
|
||||
if !existingIds.contains(item.file.fileId) {
|
||||
existingIds.insert(item.file.fileId)
|
||||
result.append(item.file)
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,18 +257,13 @@ private func updatedContextQueryResultStateForQuery(context: AccountContext, cha
|
||||
var result: [(String, TelegramMediaFile?, String)] = []
|
||||
|
||||
for entry in view.entries {
|
||||
guard let item = entry.item as? StickerPackItem else {
|
||||
guard let item = entry.item as? StickerPackItem, !item.file.isPremiumEmoji || hasPremium else {
|
||||
continue
|
||||
}
|
||||
for attribute in item.file.attributes {
|
||||
switch attribute {
|
||||
case let .CustomEmoji(_, _, alt, _):
|
||||
if alt == query {
|
||||
if !item.file.isPremiumEmoji || hasPremium {
|
||||
result.append((alt, item.file, alt))
|
||||
}
|
||||
}
|
||||
default:
|
||||
let stringRepresentations = item.getStringRepresentationsOfIndexKeys()
|
||||
for stringRepresentation in stringRepresentations {
|
||||
if stringRepresentation == query {
|
||||
result.append((stringRepresentation, item.file, stringRepresentation))
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -312,18 +307,13 @@ private func updatedContextQueryResultStateForQuery(context: AccountContext, cha
|
||||
}
|
||||
|
||||
for entry in view.entries {
|
||||
guard let item = entry.item as? StickerPackItem else {
|
||||
guard let item = entry.item as? StickerPackItem, !item.file.isPremiumEmoji || hasPremium else {
|
||||
continue
|
||||
}
|
||||
for attribute in item.file.attributes {
|
||||
switch attribute {
|
||||
case let .CustomEmoji(_, _, alt, _):
|
||||
if !alt.isEmpty, let keyword = allEmoticons[alt] {
|
||||
if !item.file.isPremiumEmoji || hasPremium {
|
||||
result.append((alt, item.file, keyword))
|
||||
}
|
||||
}
|
||||
default:
|
||||
let stringRepresentations = item.getStringRepresentationsOfIndexKeys()
|
||||
for stringRepresentation in stringRepresentations {
|
||||
if let keyword = allEmoticons[stringRepresentation] {
|
||||
result.append((stringRepresentation, item.file, keyword))
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,18 +382,13 @@ private func updatedContextQueryResultStateForQuery(context: AccountContext, pee
|
||||
var result: [(String, TelegramMediaFile?, String)] = []
|
||||
|
||||
for entry in view.entries {
|
||||
guard let item = entry.item as? StickerPackItem else {
|
||||
guard let item = entry.item as? StickerPackItem, !item.file.isPremiumEmoji || hasPremium else {
|
||||
continue
|
||||
}
|
||||
for attribute in item.file.attributes {
|
||||
switch attribute {
|
||||
case let .CustomEmoji(_, _, alt, _):
|
||||
if alt == query {
|
||||
if !item.file.isPremiumEmoji || hasPremium {
|
||||
result.append((alt, item.file, alt))
|
||||
}
|
||||
}
|
||||
default:
|
||||
let stringRepresentations = item.getStringRepresentationsOfIndexKeys()
|
||||
for stringRepresentation in stringRepresentations {
|
||||
if stringRepresentation == query {
|
||||
result.append((stringRepresentation, item.file, stringRepresentation))
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -437,18 +432,13 @@ private func updatedContextQueryResultStateForQuery(context: AccountContext, pee
|
||||
}
|
||||
|
||||
for entry in view.entries {
|
||||
guard let item = entry.item as? StickerPackItem else {
|
||||
guard let item = entry.item as? StickerPackItem, !item.file.isPremiumEmoji || hasPremium else {
|
||||
continue
|
||||
}
|
||||
for attribute in item.file.attributes {
|
||||
switch attribute {
|
||||
case let .CustomEmoji(_, _, alt, _):
|
||||
if !alt.isEmpty, let keyword = allEmoticons[alt] {
|
||||
if !item.file.isPremiumEmoji || hasPremium {
|
||||
result.append((alt, item.file, keyword))
|
||||
}
|
||||
}
|
||||
default:
|
||||
let stringRepresentations = item.getStringRepresentationsOfIndexKeys()
|
||||
for stringRepresentation in stringRepresentations {
|
||||
if let keyword = allEmoticons[stringRepresentation] {
|
||||
result.append((stringRepresentation, item.file, keyword))
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user