mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
UI updates
This commit is contained in:
parent
9ef9811db3
commit
79698d9929
@ -465,6 +465,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-384910503] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionExportedInviteEdit($0) }
|
||||
dict[1048537159] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionParticipantVolume($0) }
|
||||
dict[1855199800] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeHistoryTTL($0) }
|
||||
dict[-26672755] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeTheme($0) }
|
||||
dict[-543777747] = { return Api.auth.ExportedAuthorization.parse_exportedAuthorization($0) }
|
||||
dict[2103482845] = { return Api.SecurePlainData.parse_securePlainPhone($0) }
|
||||
dict[569137759] = { return Api.SecurePlainData.parse_securePlainEmail($0) }
|
||||
@ -737,7 +738,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-1625153079] = { return Api.InputWebFileLocation.parse_inputWebFileGeoPointLocation($0) }
|
||||
dict[-1275374751] = { return Api.EmojiLanguage.parse_emojiLanguage($0) }
|
||||
dict[1601666510] = { return Api.MessageFwdHeader.parse_messageFwdHeader($0) }
|
||||
dict[-160304943] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
|
||||
dict[708589599] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
|
||||
dict[-1012849566] = { return Api.BaseTheme.parse_baseThemeClassic($0) }
|
||||
dict[-69724536] = { return Api.BaseTheme.parse_baseThemeDay($0) }
|
||||
dict[-1212997976] = { return Api.BaseTheme.parse_baseThemeNight($0) }
|
||||
|
@ -11320,6 +11320,7 @@ public extension Api {
|
||||
case channelAdminLogEventActionExportedInviteEdit(prevInvite: Api.ExportedChatInvite, newInvite: Api.ExportedChatInvite)
|
||||
case channelAdminLogEventActionParticipantVolume(participant: Api.GroupCallParticipant)
|
||||
case channelAdminLogEventActionChangeHistoryTTL(prevValue: Int32, newValue: Int32)
|
||||
case channelAdminLogEventActionChangeTheme(prevValue: String, newValue: String)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
@ -11529,6 +11530,13 @@ public extension Api {
|
||||
serializeInt32(prevValue, buffer: buffer, boxed: false)
|
||||
serializeInt32(newValue, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .channelAdminLogEventActionChangeTheme(let prevValue, let newValue):
|
||||
if boxed {
|
||||
buffer.appendInt32(-26672755)
|
||||
}
|
||||
serializeString(prevValue, buffer: buffer, boxed: false)
|
||||
serializeString(newValue, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -11598,6 +11606,8 @@ public extension Api {
|
||||
return ("channelAdminLogEventActionParticipantVolume", [("participant", participant)])
|
||||
case .channelAdminLogEventActionChangeHistoryTTL(let prevValue, let newValue):
|
||||
return ("channelAdminLogEventActionChangeHistoryTTL", [("prevValue", prevValue), ("newValue", newValue)])
|
||||
case .channelAdminLogEventActionChangeTheme(let prevValue, let newValue):
|
||||
return ("channelAdminLogEventActionChangeTheme", [("prevValue", prevValue), ("newValue", newValue)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -12043,6 +12053,20 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_channelAdminLogEventActionChangeTheme(_ reader: BufferReader) -> ChannelAdminLogEventAction? {
|
||||
var _1: String?
|
||||
_1 = parseString(reader)
|
||||
var _2: String?
|
||||
_2 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.ChannelAdminLogEventAction.channelAdminLogEventActionChangeTheme(prevValue: _1!, newValue: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public enum SecurePlainData: TypeConstructorDescription {
|
||||
@ -19218,20 +19242,19 @@ public extension Api {
|
||||
|
||||
}
|
||||
public enum SponsoredMessage: TypeConstructorDescription {
|
||||
case sponsoredMessage(flags: Int32, randomId: Buffer, peerId: Api.Peer, fromId: Api.Peer, message: String, media: Api.MessageMedia?, entities: [Api.MessageEntity]?)
|
||||
case sponsoredMessage(flags: Int32, randomId: Buffer, fromId: Api.Peer, startParam: String?, message: String, entities: [Api.MessageEntity]?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .sponsoredMessage(let flags, let randomId, let peerId, let fromId, let message, let media, let entities):
|
||||
case .sponsoredMessage(let flags, let randomId, let fromId, let startParam, let message, let entities):
|
||||
if boxed {
|
||||
buffer.appendInt32(-160304943)
|
||||
buffer.appendInt32(708589599)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeBytes(randomId, buffer: buffer, boxed: false)
|
||||
peerId.serialize(buffer, true)
|
||||
fromId.serialize(buffer, true)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeString(startParam!, buffer: buffer, boxed: false)}
|
||||
serializeString(message, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {media!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 1) != 0 {buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(entities!.count))
|
||||
for item in entities! {
|
||||
@ -19243,8 +19266,8 @@ public extension Api {
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .sponsoredMessage(let flags, let randomId, let peerId, let fromId, let message, let media, let entities):
|
||||
return ("sponsoredMessage", [("flags", flags), ("randomId", randomId), ("peerId", peerId), ("fromId", fromId), ("message", message), ("media", media), ("entities", entities)])
|
||||
case .sponsoredMessage(let flags, let randomId, let fromId, let startParam, let message, let entities):
|
||||
return ("sponsoredMessage", [("flags", flags), ("randomId", randomId), ("fromId", fromId), ("startParam", startParam), ("message", message), ("entities", entities)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -19257,29 +19280,22 @@ public extension Api {
|
||||
if let signature = reader.readInt32() {
|
||||
_3 = Api.parse(reader, signature: signature) as? Api.Peer
|
||||
}
|
||||
var _4: Api.Peer?
|
||||
if let signature = reader.readInt32() {
|
||||
_4 = Api.parse(reader, signature: signature) as? Api.Peer
|
||||
}
|
||||
var _4: String?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {_4 = parseString(reader) }
|
||||
var _5: String?
|
||||
_5 = parseString(reader)
|
||||
var _6: Api.MessageMedia?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
|
||||
_6 = Api.parse(reader, signature: signature) as? Api.MessageMedia
|
||||
} }
|
||||
var _7: [Api.MessageEntity]?
|
||||
var _6: [Api.MessageEntity]?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() {
|
||||
_7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self)
|
||||
_6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self)
|
||||
} }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
|
||||
let _c5 = _5 != nil
|
||||
let _c6 = (Int(_1!) & Int(1 << 0) == 0) || _6 != nil
|
||||
let _c7 = (Int(_1!) & Int(1 << 1) == 0) || _7 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
|
||||
return Api.SponsoredMessage.sponsoredMessage(flags: _1!, randomId: _2!, peerId: _3!, fromId: _4!, message: _5!, media: _6, entities: _7)
|
||||
let _c6 = (Int(_1!) & Int(1 << 1) == 0) || _6 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||
return Api.SponsoredMessage.sponsoredMessage(flags: _1!, randomId: _2!, fromId: _3!, startParam: _4, message: _5!, entities: _6)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
@ -3,9 +3,11 @@ import Postbox
|
||||
|
||||
public final class AdMessageAttribute: MessageAttribute {
|
||||
public let opaqueId: Data
|
||||
public let startParam: String?
|
||||
|
||||
public init(opaqueId: Data) {
|
||||
public init(opaqueId: Data, startParam: String?) {
|
||||
self.opaqueId = opaqueId
|
||||
self.startParam = startParam
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
|
@ -11,6 +11,7 @@ private class AdMessagesHistoryContextImpl {
|
||||
case textEntities
|
||||
case media
|
||||
case authorId
|
||||
case startParam
|
||||
}
|
||||
|
||||
public let opaqueId: Data
|
||||
@ -18,19 +19,22 @@ private class AdMessagesHistoryContextImpl {
|
||||
public let textEntities: [MessageTextEntity]
|
||||
public let media: [Media]
|
||||
public let authorId: PeerId
|
||||
public let startParam: String?
|
||||
|
||||
public init(
|
||||
opaqueId: Data,
|
||||
text: String,
|
||||
textEntities: [MessageTextEntity],
|
||||
media: [Media],
|
||||
authorId: PeerId
|
||||
authorId: PeerId,
|
||||
startParam: String?
|
||||
) {
|
||||
self.opaqueId = opaqueId
|
||||
self.text = text
|
||||
self.textEntities = textEntities
|
||||
self.media = media
|
||||
self.authorId = authorId
|
||||
self.startParam = startParam
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
@ -47,6 +51,8 @@ private class AdMessagesHistoryContextImpl {
|
||||
}
|
||||
|
||||
self.authorId = try container.decode(PeerId.self, forKey: .authorId)
|
||||
|
||||
self.startParam = try container.decodeIfPresent(String.self, forKey: .startParam)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -64,6 +70,7 @@ private class AdMessagesHistoryContextImpl {
|
||||
try container.encode(mediaData, forKey: .media)
|
||||
|
||||
try container.encode(self.authorId, forKey: .authorId)
|
||||
try container.encodeIfPresent(self.startParam, forKey: .startParam)
|
||||
}
|
||||
|
||||
public static func ==(lhs: CachedMessage, rhs: CachedMessage) -> Bool {
|
||||
@ -87,13 +94,16 @@ private class AdMessagesHistoryContextImpl {
|
||||
if lhs.authorId != rhs.authorId {
|
||||
return false
|
||||
}
|
||||
if lhs.startParam != rhs.startParam {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func toMessage(peerId: PeerId, transaction: Transaction) -> Message {
|
||||
var attributes: [MessageAttribute] = []
|
||||
|
||||
attributes.append(AdMessageAttribute(opaqueId: self.opaqueId))
|
||||
attributes.append(AdMessageAttribute(opaqueId: self.opaqueId, startParam: self.startParam))
|
||||
if !self.textEntities.isEmpty {
|
||||
let attribute = TextEntitiesMessageAttribute(entities: self.textEntities)
|
||||
attributes.append(attribute)
|
||||
@ -307,25 +317,27 @@ private class AdMessagesHistoryContextImpl {
|
||||
|
||||
for message in messages {
|
||||
switch message {
|
||||
case let .sponsoredMessage(_, randomId, _, fromId, message, media, entities):
|
||||
case let .sponsoredMessage(_, randomId, fromId, startParam, message, entities):
|
||||
var parsedEntities: [MessageTextEntity] = []
|
||||
if let entities = entities {
|
||||
parsedEntities = messageTextEntitiesFromApiEntities(entities)
|
||||
}
|
||||
|
||||
var parsedMedia: [Media] = []
|
||||
if let media = media {
|
||||
let parsedMedia: [Media] = []
|
||||
/*if let media = media {
|
||||
let (mediaValue, _) = textMediaAndExpirationTimerFromApiMedia(media, peerId)
|
||||
if let mediaValue = mediaValue {
|
||||
parsedMedia.append(mediaValue)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
parsedMessages.append(CachedMessage(
|
||||
opaqueId: randomId.makeData(),
|
||||
text: message,
|
||||
textEntities: parsedEntities,
|
||||
media: parsedMedia, authorId: fromId.peerId
|
||||
media: parsedMedia,
|
||||
authorId: fromId.peerId,
|
||||
startParam: startParam
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -249,6 +249,8 @@ func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: PeerId, m
|
||||
action = .groupCallUpdateParticipantVolume(peerId: parsedParticipant.peerId, volume: parsedParticipant.volume ?? 10000)
|
||||
case let .channelAdminLogEventActionChangeHistoryTTL(prevValue, newValue):
|
||||
action = .changeHistoryTTL(previousValue: prevValue, updatedValue: newValue)
|
||||
case .channelAdminLogEventActionChangeTheme:
|
||||
action = nil
|
||||
}
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))
|
||||
if let action = action {
|
||||
|
@ -3423,7 +3423,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
.updatedAutoremoveTimeout(autoremoveTimeout)
|
||||
})
|
||||
|
||||
if let channel = renderedPeer?.chatMainPeer as? TelegramChannel, case .broadcast = channel.info {
|
||||
if case .standard(previewing: false) = mode, let channel = renderedPeer?.chatMainPeer as? TelegramChannel, case .broadcast = channel.info {
|
||||
if strongSelf.nextChannelToReadDisposable == nil {
|
||||
strongSelf.nextChannelToReadDisposable = (combineLatest(queue: .mainQueue(),
|
||||
strongSelf.context.engine.peers.getNextUnreadChannel(peerId: channel.id, chatListFilterId: strongSelf.currentChatListFilter, getFilterPredicate: chatListFilterPredicate),
|
||||
|
@ -1035,9 +1035,47 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
|
||||
updatedScrollPosition = .index(index: .message(currentlyPlayingMessageId), position: .center(.bottom), directionHint: .Down, animated: true, highlight: true)
|
||||
scrollAnimationCurve = .Spring(duration: 0.4)
|
||||
}
|
||||
|
||||
var disableAnimations = false
|
||||
|
||||
if let strongSelf = self, updatedScrollPosition == nil, case .InteractiveChanges = reason, case let .known(offset) = strongSelf.visibleContentOffset(), abs(offset) <= 0.9, let previous = previous {
|
||||
var previousNumAds = 0
|
||||
for entry in previous.filteredEntries {
|
||||
if case let .MessageEntry(message, _, _, _, _, _) = entry {
|
||||
if message.adAttribute != nil {
|
||||
previousNumAds += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var updatedNumAds = 0
|
||||
var firstNonAdIndex: MessageIndex?
|
||||
for entry in processedView.filteredEntries.reversed() {
|
||||
if case let .MessageEntry(message, _, _, _, _, _) = entry {
|
||||
if message.adAttribute != nil {
|
||||
updatedNumAds += 1
|
||||
} else {
|
||||
if firstNonAdIndex == nil {
|
||||
firstNonAdIndex = message.index
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let firstNonAdIndex = firstNonAdIndex, previousNumAds == 0, updatedNumAds != 0 {
|
||||
updatedScrollPosition = .index(index: .message(firstNonAdIndex), position: .top(0.0), directionHint: .Up, animated: false, highlight: false)
|
||||
disableAnimations = true
|
||||
}
|
||||
}
|
||||
|
||||
let rawTransition = preparedChatHistoryViewTransition(from: previous, to: processedView, reason: reason, reverse: reverse, chatLocation: chatLocation, controllerInteraction: controllerInteraction, scrollPosition: updatedScrollPosition, scrollAnimationCurve: scrollAnimationCurve, initialData: initialData?.initialData, keyboardButtonsMessage: view.topTaggedMessages.first, cachedData: initialData?.cachedData, cachedDataMessages: initialData?.cachedDataMessages, readStateData: initialData?.readStateData, flashIndicators: flashIndicators, updatedMessageSelection: previousSelectedMessages != selectedMessages, messageTransitionNode: messageTransitionNode(), allUpdated: updateAllOnEachVersion)
|
||||
let mappedTransition = mappedChatHistoryViewListTransition(context: context, chatLocation: chatLocation, associatedData: associatedData, controllerInteraction: controllerInteraction, mode: mode, lastHeaderId: lastHeaderId, transition: rawTransition)
|
||||
var mappedTransition = mappedChatHistoryViewListTransition(context: context, chatLocation: chatLocation, associatedData: associatedData, controllerInteraction: controllerInteraction, mode: mode, lastHeaderId: lastHeaderId, transition: rawTransition)
|
||||
if disableAnimations {
|
||||
mappedTransition.options.remove(.AnimateInsertion)
|
||||
mappedTransition.options.remove(.AnimateAlpha)
|
||||
mappedTransition.options.remove(.AnimateTopItemPosition)
|
||||
mappedTransition.options.remove(.RequestItemInsertionAnimations)
|
||||
}
|
||||
Queue.mainQueue().async {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
@ -1276,7 +1314,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
|
||||
let previousType = self.currentOverscrollExpandProgress >= 1.0
|
||||
let currentType = expandProgress >= 1.0
|
||||
|
||||
if previousType != currentType {
|
||||
if previousType != currentType, currentType {
|
||||
if self.feedback == nil {
|
||||
self.feedback = HapticFeedback()
|
||||
}
|
||||
@ -2168,6 +2206,9 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
|
||||
loop: for entry in historyView.filteredEntries.reversed() {
|
||||
if index >= visibleRange.firstIndex && index <= visibleRange.lastIndex {
|
||||
if case let .MessageEntry(message, _, _, _, _, _) = entry {
|
||||
if message.adAttribute != nil {
|
||||
continue
|
||||
}
|
||||
if index != 0 || historyView.originalView.laterId != nil {
|
||||
currentMessage = message
|
||||
}
|
||||
|
@ -63,8 +63,14 @@ final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
}
|
||||
self.contentNode.activateAction = { [weak self] in
|
||||
if let strongSelf = self, let item = strongSelf.item {
|
||||
if let _ = item.message.adAttribute, let author = item.message.author {
|
||||
item.controllerInteraction.openPeer(author.id, .chat(textInputState: nil, subject: nil, peekData: nil), nil)
|
||||
if let adAttribute = item.message.adAttribute, let author = item.message.author {
|
||||
let navigationData: ChatControllerInteractionNavigateToPeer
|
||||
if let bot = author as? TelegramUser, bot.botInfo != nil, let startParam = adAttribute.startParam {
|
||||
navigationData = .withBotStartPayload(ChatControllerInitialBotStart(payload: startParam, behavior: .interactive))
|
||||
} else {
|
||||
navigationData = .chat(textInputState: nil, subject: nil, peekData: nil)
|
||||
}
|
||||
item.controllerInteraction.openPeer(author.id, navigationData, nil)
|
||||
} else {
|
||||
var webPageContent: TelegramMediaWebpageLoadedContent?
|
||||
for media in item.message.media {
|
||||
@ -321,7 +327,10 @@ final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
}
|
||||
}
|
||||
|
||||
if let author = item.message.author as? TelegramChannel, case .group = author.info {
|
||||
if let author = item.message.author as? TelegramUser, author.botInfo != nil {
|
||||
//TODO:localize
|
||||
actionTitle = "VIEW BOT"
|
||||
} else if let author = item.message.author as? TelegramChannel, case .group = author.info {
|
||||
actionTitle = item.presentationData.strings.Conversation_ViewGroup
|
||||
} else {
|
||||
actionTitle = item.presentationData.strings.Conversation_ViewChannel
|
||||
|
@ -216,6 +216,17 @@ func preparedChatHistoryViewTransition(from fromView: ChatHistoryView?, to toVie
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if case .Initial = reason, scrollToItem == nil {
|
||||
var index = toView.filteredEntries.count - 1
|
||||
for entry in toView.filteredEntries {
|
||||
if case let .MessageEntry(message, _, _, _, _, _) = entry {
|
||||
if let _ = message.adAttribute {
|
||||
scrollToItem = ListViewScrollToItem(index: index + 1, position: .top(0.0), animated: false, curve: curve, directionHint: .Down)
|
||||
break
|
||||
}
|
||||
}
|
||||
index -= 1
|
||||
}
|
||||
}
|
||||
|
||||
if updatedMessageSelection {
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit dc8c87e75bb88acb51dfdd781db2f8bcf1fb7433
|
||||
Subproject commit 081ef55ec85abcbcefd2c7ffb11975db9bfd9182
|
Loading…
x
Reference in New Issue
Block a user