mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Various Fixes
This commit is contained in:
@@ -30,9 +30,41 @@ public func getServerProvidedSuggestions(postbox: Postbox) -> Signal<[ServerProv
|
||||
}
|
||||
|
||||
public func dismissServerProvidedSuggestion(account: Account, suggestion: ServerProvidedSuggestion) -> Signal<Never, NoError> {
|
||||
return account.network.request(Api.functions.help.dismissSuggestion(suggestion: suggestion.rawValue))
|
||||
return account.network.request(Api.functions.help.dismissSuggestion(peer: .inputPeerEmpty, suggestion: suggestion.rawValue))
|
||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||
return .single(.boolFalse)
|
||||
}
|
||||
|> ignoreValues
|
||||
}
|
||||
|
||||
|
||||
public enum PeerSpecificServerProvidedSuggestion: String {
|
||||
case convertToGigagroup = "CONVERT_TO_GIGAGROUP"
|
||||
}
|
||||
|
||||
public func getPeerSpecificServerProvidedSuggestions(postbox: Postbox, peerId: PeerId) -> Signal<[PeerSpecificServerProvidedSuggestion], NoError> {
|
||||
return postbox.peerView(id: peerId)
|
||||
|> map { view in
|
||||
if let cachedData = view.cachedData as? CachedChannelData {
|
||||
return cachedData.pendingSuggestions.compactMap { item -> PeerSpecificServerProvidedSuggestion? in
|
||||
return PeerSpecificServerProvidedSuggestion(rawValue: item)
|
||||
}
|
||||
}
|
||||
return []
|
||||
}
|
||||
|> distinctUntilChanged
|
||||
}
|
||||
|
||||
public func dismissPeerSpecificServerProvidedSuggestion(account: Account, peerId: PeerId, suggestion: PeerSpecificServerProvidedSuggestion) -> Signal<Never, NoError> {
|
||||
return account.postbox.loadedPeerWithId(peerId)
|
||||
|> mapToSignal { peer -> Signal<Never, NoError> in
|
||||
guard let inputPeer = apiInputPeer(peer) else {
|
||||
return .never()
|
||||
}
|
||||
return account.network.request(Api.functions.help.dismissSuggestion(peer: inputPeer, suggestion: suggestion.rawValue))
|
||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||
return .single(.boolFalse)
|
||||
}
|
||||
|> ignoreValues
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user