mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
- small fixes
This commit is contained in:
parent
d8d442caad
commit
c378d634c5
@ -159,15 +159,18 @@ public final class BlockedPeersContext {
|
||||
}
|
||||
|> mapToSignal { _ -> Signal<Peer?, BlockedPeersContextAddError> in
|
||||
return postbox.transaction { transaction -> Peer? in
|
||||
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
||||
let previous: CachedUserData
|
||||
if let current = current as? CachedUserData {
|
||||
previous = current
|
||||
} else {
|
||||
previous = CachedUserData()
|
||||
}
|
||||
return previous.withUpdatedIsBlocked(true)
|
||||
})
|
||||
if peerId.namespace == Namespaces.Peer.CloudUser {
|
||||
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
||||
let previous: CachedUserData
|
||||
if let current = current as? CachedUserData {
|
||||
previous = current
|
||||
} else {
|
||||
previous = CachedUserData()
|
||||
}
|
||||
return previous.withUpdatedIsBlocked(true)
|
||||
})
|
||||
}
|
||||
|
||||
return transaction.getPeer(peerId)
|
||||
}
|
||||
|> castError(BlockedPeersContextAddError.self)
|
||||
|
@ -3,19 +3,9 @@ import Postbox
|
||||
import TelegramApi
|
||||
import SwiftSignalKit
|
||||
|
||||
public func exportMessageLink(account: Account, peerId: PeerId, messageId: MessageId, threadMessageId: MessageId? = nil) -> Signal<String?, NoError> {
|
||||
public func exportMessageLink(account: Account, peerId: PeerId, messageId: MessageId, isThread: Bool = false) -> Signal<String?, NoError> {
|
||||
return account.postbox.transaction { transaction -> (Peer, MessageId)? in
|
||||
var peer: Peer?
|
||||
var messageId = messageId
|
||||
if let threadMessageId = threadMessageId {
|
||||
messageId = threadMessageId
|
||||
if let message = transaction.getMessage(threadMessageId), let sourceReference = message.sourceReference {
|
||||
peer = transaction.getPeer(sourceReference.messageId.peerId)
|
||||
messageId = sourceReference.messageId
|
||||
}
|
||||
} else {
|
||||
peer = transaction.getPeer(messageId.peerId)
|
||||
}
|
||||
var peer: Peer? = transaction.getPeer(messageId.peerId)
|
||||
if let peer = peer {
|
||||
return (peer, messageId)
|
||||
} else {
|
||||
@ -27,16 +17,15 @@ public func exportMessageLink(account: Account, peerId: PeerId, messageId: Messa
|
||||
return .single(nil)
|
||||
}
|
||||
if let input = apiInputChannel(peer) {
|
||||
//channels.exportMessageLink flags:# grouped:flags.0?true thread:flags.1?true channel:InputChannel id:int = ExportedMessageLink;
|
||||
var flags: Int32 = 0
|
||||
flags |= 1 << 0
|
||||
if isThread {
|
||||
flags |= 1 << 1
|
||||
}
|
||||
return account.network.request(Api.functions.channels.exportMessageLink(flags: flags, channel: input, id: sourceMessageId.id)) |> mapError { _ in return }
|
||||
|> map { res in
|
||||
switch res {
|
||||
case let .exportedMessageLink(link, _):
|
||||
if let _ = threadMessageId {
|
||||
return "\(link)?comment=\(messageId.id)"
|
||||
}
|
||||
return link
|
||||
}
|
||||
} |> `catch` { _ -> Signal<String?, NoError> in
|
||||
|
Loading…
x
Reference in New Issue
Block a user