Recommended channel fixes

This commit is contained in:
Isaac
2024-04-26 19:15:21 +04:00
parent 53f37cd043
commit 3f90ca65eb
3 changed files with 27 additions and 19 deletions

View File

@@ -171,9 +171,16 @@ func _internal_recommendedChannels(account: Account, peerId: EnginePeer.Id?) ->
let key = PostboxViewKey.cachedItem(entryId(peerId: peerId))
return account.postbox.combinedView(keys: [key])
|> mapToSignal { views -> Signal<RecommendedChannels?, NoError> in
guard let cachedChannels = (views.views[key] as? CachedItemView)?.value?.get(CachedRecommendedChannels.self), !cachedChannels.peerIds.isEmpty else {
guard let cachedChannels = (views.views[key] as? CachedItemView)?.value?.get(CachedRecommendedChannels.self) else {
return .single(nil)
}
if cachedChannels.peerIds.isEmpty {
if peerId != nil {
return .single(nil)
} else {
return .single(RecommendedChannels(channels: [], count: 0, isHidden: false))
}
}
return account.postbox.multiplePeersView(cachedChannels.peerIds)
|> mapToSignal { view in
return account.postbox.transaction { transaction -> RecommendedChannels? in