mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge commit 'b7e0c3718e90042b521f0c011bd663e7f735bc5f'
This commit is contained in:
commit
3236ce247d
@ -8,9 +8,10 @@ public final class PageControlNode: ASDisplayNode {
|
|||||||
public var dotColor: UIColor {
|
public var dotColor: UIColor {
|
||||||
didSet {
|
didSet {
|
||||||
if !oldValue.isEqual(self.dotColor) {
|
if !oldValue.isEqual(self.dotColor) {
|
||||||
|
let oldImage = self.normalDotImage
|
||||||
self.normalDotImage = generateFilledCircleImage(diameter: dotSize, color: self.dotColor)!
|
self.normalDotImage = generateFilledCircleImage(diameter: dotSize, color: self.dotColor)!
|
||||||
for dotNode in self.dotNodes {
|
for dotNode in self.dotNodes {
|
||||||
if dotNode === oldValue {
|
if dotNode.image === oldImage {
|
||||||
dotNode.image = self.normalDotImage
|
dotNode.image = self.normalDotImage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -20,9 +21,10 @@ public final class PageControlNode: ASDisplayNode {
|
|||||||
public var inactiveDotColor: UIColor {
|
public var inactiveDotColor: UIColor {
|
||||||
didSet {
|
didSet {
|
||||||
if !oldValue.isEqual(self.inactiveDotColor) {
|
if !oldValue.isEqual(self.inactiveDotColor) {
|
||||||
|
let oldImage = self.inactiveDotImage
|
||||||
self.inactiveDotImage = generateFilledCircleImage(diameter: dotSize, color: self.inactiveDotColor)!
|
self.inactiveDotImage = generateFilledCircleImage(diameter: dotSize, color: self.inactiveDotColor)!
|
||||||
for dotNode in self.dotNodes {
|
for dotNode in self.dotNodes {
|
||||||
if dotNode === oldValue {
|
if dotNode.image === oldImage {
|
||||||
dotNode.image = self.inactiveDotImage
|
dotNode.image = self.inactiveDotImage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,19 @@ public extension UIColor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lightness: CGFloat {
|
||||||
|
var red: CGFloat = 0.0
|
||||||
|
var green: CGFloat = 0.0
|
||||||
|
var blue: CGFloat = 0.0
|
||||||
|
if self.getRed(&red, green: &green, blue: &blue, alpha: nil) {
|
||||||
|
return 0.2126 * red + 0.7152 * green + 0.0722 * blue
|
||||||
|
} else if self.getWhite(&red, alpha: nil) {
|
||||||
|
return red
|
||||||
|
} else {
|
||||||
|
return 0.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func withMultipliedBrightnessBy(_ factor: CGFloat) -> UIColor {
|
func withMultipliedBrightnessBy(_ factor: CGFloat) -> UIColor {
|
||||||
var hue: CGFloat = 0.0
|
var hue: CGFloat = 0.0
|
||||||
var saturation: CGFloat = 0.0
|
var saturation: CGFloat = 0.0
|
||||||
|
@ -2765,7 +2765,7 @@ func replayFinalState(accountManager: AccountManager, postbox: Postbox, accountP
|
|||||||
if info.flags.contains(.slowModeEnabled), peer.adminRights == nil && !peer.flags.contains(.isCreator) {
|
if info.flags.contains(.slowModeEnabled), peer.adminRights == nil && !peer.flags.contains(.isCreator) {
|
||||||
var cachedData = transaction.getPeerCachedData(peerId: peerId) as? CachedChannelData ?? CachedChannelData()
|
var cachedData = transaction.getPeerCachedData(peerId: peerId) as? CachedChannelData ?? CachedChannelData()
|
||||||
if let slowModeTimeout = cachedData.slowModeTimeout {
|
if let slowModeTimeout = cachedData.slowModeTimeout {
|
||||||
cachedData = cachedData.withUpdatedSlowModeValidUntilTimestamp(slowModeValidUntilTimestamp: timeout + slowModeTimeout)
|
cachedData = cachedData.withUpdatedSlowModeValidUntilTimestamp(timeout + slowModeTimeout)
|
||||||
peerIds.insert(peerId)
|
peerIds.insert(peerId)
|
||||||
cachedDatas[peerId] = cachedData
|
cachedDatas[peerId] = cachedData
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, mes
|
|||||||
transaction.updatePeerCachedData(peerIds: [peerId], update: { peerId, current in
|
transaction.updatePeerCachedData(peerIds: [peerId], update: { peerId, current in
|
||||||
var cachedData = current as? CachedChannelData ?? CachedChannelData()
|
var cachedData = current as? CachedChannelData ?? CachedChannelData()
|
||||||
if let slowModeTimeout = cachedData.slowModeTimeout {
|
if let slowModeTimeout = cachedData.slowModeTimeout {
|
||||||
cachedData = cachedData.withUpdatedSlowModeValidUntilTimestamp(slowModeValidUntilTimestamp: currentMessage.timestamp + slowModeTimeout)
|
cachedData = cachedData.withUpdatedSlowModeValidUntilTimestamp(currentMessage.timestamp + slowModeTimeout)
|
||||||
return cachedData
|
return cachedData
|
||||||
} else {
|
} else {
|
||||||
return current
|
return current
|
||||||
|
@ -172,6 +172,7 @@ public final class CachedChannelData: CachedPeerData {
|
|||||||
public let peerGeoLocation: PeerGeoLocation?
|
public let peerGeoLocation: PeerGeoLocation?
|
||||||
public let slowModeTimeout: Int32?
|
public let slowModeTimeout: Int32?
|
||||||
public let slowModeValidUntilTimestamp: Int32?
|
public let slowModeValidUntilTimestamp: Int32?
|
||||||
|
public let hasScheduledMessages: Bool
|
||||||
|
|
||||||
public let peerIds: Set<PeerId>
|
public let peerIds: Set<PeerId>
|
||||||
public let messageIds: Set<MessageId>
|
public let messageIds: Set<MessageId>
|
||||||
@ -197,9 +198,10 @@ public final class CachedChannelData: CachedPeerData {
|
|||||||
self.peerGeoLocation = nil
|
self.peerGeoLocation = nil
|
||||||
self.slowModeTimeout = nil
|
self.slowModeTimeout = nil
|
||||||
self.slowModeValidUntilTimestamp = nil
|
self.slowModeValidUntilTimestamp = nil
|
||||||
|
self.hasScheduledMessages = false
|
||||||
}
|
}
|
||||||
|
|
||||||
init(isNotAccessible: Bool, flags: CachedChannelFlags, about: String?, participantsSummary: CachedChannelParticipantsSummary, exportedInvitation: ExportedInvitation?, botInfos: [CachedPeerBotInfo], peerStatusSettings: PeerStatusSettings?, pinnedMessageId: MessageId?, stickerPack: StickerPackCollectionInfo?, minAvailableMessageId: MessageId?, migrationReference: ChannelMigrationReference?, linkedDiscussionPeerId: PeerId?, peerGeoLocation: PeerGeoLocation?, slowModeTimeout: Int32?, slowModeValidUntilTimestamp: Int32?) {
|
init(isNotAccessible: Bool, flags: CachedChannelFlags, about: String?, participantsSummary: CachedChannelParticipantsSummary, exportedInvitation: ExportedInvitation?, botInfos: [CachedPeerBotInfo], peerStatusSettings: PeerStatusSettings?, pinnedMessageId: MessageId?, stickerPack: StickerPackCollectionInfo?, minAvailableMessageId: MessageId?, migrationReference: ChannelMigrationReference?, linkedDiscussionPeerId: PeerId?, peerGeoLocation: PeerGeoLocation?, slowModeTimeout: Int32?, slowModeValidUntilTimestamp: Int32?, hasScheduledMessages: Bool) {
|
||||||
self.isNotAccessible = isNotAccessible
|
self.isNotAccessible = isNotAccessible
|
||||||
self.flags = flags
|
self.flags = flags
|
||||||
self.about = about
|
self.about = about
|
||||||
@ -215,6 +217,7 @@ public final class CachedChannelData: CachedPeerData {
|
|||||||
self.peerGeoLocation = peerGeoLocation
|
self.peerGeoLocation = peerGeoLocation
|
||||||
self.slowModeTimeout = slowModeTimeout
|
self.slowModeTimeout = slowModeTimeout
|
||||||
self.slowModeValidUntilTimestamp = slowModeValidUntilTimestamp
|
self.slowModeValidUntilTimestamp = slowModeValidUntilTimestamp
|
||||||
|
self.hasScheduledMessages = hasScheduledMessages
|
||||||
|
|
||||||
var peerIds = Set<PeerId>()
|
var peerIds = Set<PeerId>()
|
||||||
for botInfo in botInfos {
|
for botInfo in botInfos {
|
||||||
@ -235,63 +238,67 @@ public final class CachedChannelData: CachedPeerData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedIsNotAccessible(_ isNotAccessible: Bool) -> CachedChannelData {
|
func withUpdatedIsNotAccessible(_ isNotAccessible: Bool) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp)
|
return CachedChannelData(isNotAccessible: isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedFlags(_ flags: CachedChannelFlags) -> CachedChannelData {
|
func withUpdatedFlags(_ flags: CachedChannelFlags) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedAbout(_ about: String?) -> CachedChannelData {
|
func withUpdatedAbout(_ about: String?) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedParticipantsSummary(_ participantsSummary: CachedChannelParticipantsSummary) -> CachedChannelData {
|
func withUpdatedParticipantsSummary(_ participantsSummary: CachedChannelParticipantsSummary) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedExportedInvitation(_ exportedInvitation: ExportedInvitation?) -> CachedChannelData {
|
func withUpdatedExportedInvitation(_ exportedInvitation: ExportedInvitation?) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedBotInfos(_ botInfos: [CachedPeerBotInfo]) -> CachedChannelData {
|
func withUpdatedBotInfos(_ botInfos: [CachedPeerBotInfo]) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedPeerStatusSettings(_ peerStatusSettings: PeerStatusSettings?) -> CachedChannelData {
|
func withUpdatedPeerStatusSettings(_ peerStatusSettings: PeerStatusSettings?) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedPinnedMessageId(_ pinnedMessageId: MessageId?) -> CachedChannelData {
|
func withUpdatedPinnedMessageId(_ pinnedMessageId: MessageId?) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedStickerPack(_ stickerPack: StickerPackCollectionInfo?) -> CachedChannelData {
|
func withUpdatedStickerPack(_ stickerPack: StickerPackCollectionInfo?) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedMinAvailableMessageId(_ minAvailableMessageId: MessageId?) -> CachedChannelData {
|
func withUpdatedMinAvailableMessageId(_ minAvailableMessageId: MessageId?) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedMigrationReference(_ migrationReference: ChannelMigrationReference?) -> CachedChannelData {
|
func withUpdatedMigrationReference(_ migrationReference: ChannelMigrationReference?) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedLinkedDiscussionPeerId(_ linkedDiscussionPeerId: PeerId?) -> CachedChannelData {
|
func withUpdatedLinkedDiscussionPeerId(_ linkedDiscussionPeerId: PeerId?) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedPeerGeoLocation(peerGeoLocation: PeerGeoLocation?) -> CachedChannelData {
|
func withUpdatedPeerGeoLocation(_ peerGeoLocation: PeerGeoLocation?) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedSlowModeTimeout(slowModeTimeout: Int32?) -> CachedChannelData {
|
func withUpdatedSlowModeTimeout(_ slowModeTimeout: Int32?) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedSlowModeValidUntilTimestamp(slowModeValidUntilTimestamp: Int32?) -> CachedChannelData {
|
func withUpdatedSlowModeValidUntilTimestamp(_ slowModeValidUntilTimestamp: Int32?) -> CachedChannelData {
|
||||||
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: slowModeValidUntilTimestamp)
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: slowModeValidUntilTimestamp, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
|
}
|
||||||
|
|
||||||
|
func withUpdatedHasScheduledMessages(_ hasScheduledMessages: Bool) -> CachedChannelData {
|
||||||
|
return CachedChannelData(isNotAccessible: self.isNotAccessible, flags: self.flags, about: self.about, participantsSummary: self.participantsSummary, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, stickerPack: self.stickerPack, minAvailableMessageId: self.minAvailableMessageId, migrationReference: self.migrationReference, linkedDiscussionPeerId: self.linkedDiscussionPeerId, peerGeoLocation: self.peerGeoLocation, slowModeTimeout: self.slowModeTimeout, slowModeValidUntilTimestamp: self.slowModeValidUntilTimestamp, hasScheduledMessages: hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(decoder: PostboxDecoder) {
|
public init(decoder: PostboxDecoder) {
|
||||||
@ -345,6 +352,7 @@ public final class CachedChannelData: CachedPeerData {
|
|||||||
|
|
||||||
self.slowModeTimeout = decoder.decodeOptionalInt32ForKey("smt")
|
self.slowModeTimeout = decoder.decodeOptionalInt32ForKey("smt")
|
||||||
self.slowModeValidUntilTimestamp = decoder.decodeOptionalInt32ForKey("smv")
|
self.slowModeValidUntilTimestamp = decoder.decodeOptionalInt32ForKey("smv")
|
||||||
|
self.hasScheduledMessages = decoder.decodeBoolForKey("hsm", orElse: false)
|
||||||
|
|
||||||
if let linkedDiscussionPeerId = self.linkedDiscussionPeerId {
|
if let linkedDiscussionPeerId = self.linkedDiscussionPeerId {
|
||||||
peerIds.insert(linkedDiscussionPeerId)
|
peerIds.insert(linkedDiscussionPeerId)
|
||||||
@ -428,6 +436,7 @@ public final class CachedChannelData: CachedPeerData {
|
|||||||
} else {
|
} else {
|
||||||
encoder.encodeNil(forKey: "smv")
|
encoder.encodeNil(forKey: "smv")
|
||||||
}
|
}
|
||||||
|
encoder.encodeBool(self.hasScheduledMessages, forKey: "hsm")
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isEqual(to: CachedPeerData) -> Bool {
|
public func isEqual(to: CachedPeerData) -> Bool {
|
||||||
|
@ -51,6 +51,7 @@ public final class CachedGroupData: CachedPeerData {
|
|||||||
public let pinnedMessageId: MessageId?
|
public let pinnedMessageId: MessageId?
|
||||||
public let about: String?
|
public let about: String?
|
||||||
public let flags: CachedGroupFlags
|
public let flags: CachedGroupFlags
|
||||||
|
public let hasScheduledMessages: Bool
|
||||||
|
|
||||||
public let peerIds: Set<PeerId>
|
public let peerIds: Set<PeerId>
|
||||||
public let messageIds: Set<MessageId>
|
public let messageIds: Set<MessageId>
|
||||||
@ -66,9 +67,10 @@ public final class CachedGroupData: CachedPeerData {
|
|||||||
self.peerIds = Set()
|
self.peerIds = Set()
|
||||||
self.about = nil
|
self.about = nil
|
||||||
self.flags = CachedGroupFlags()
|
self.flags = CachedGroupFlags()
|
||||||
|
self.hasScheduledMessages = false
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(participants: CachedGroupParticipants?, exportedInvitation: ExportedInvitation?, botInfos: [CachedPeerBotInfo], peerStatusSettings: PeerStatusSettings?, pinnedMessageId: MessageId?, about: String?, flags: CachedGroupFlags) {
|
public init(participants: CachedGroupParticipants?, exportedInvitation: ExportedInvitation?, botInfos: [CachedPeerBotInfo], peerStatusSettings: PeerStatusSettings?, pinnedMessageId: MessageId?, about: String?, flags: CachedGroupFlags, hasScheduledMessages: Bool) {
|
||||||
self.participants = participants
|
self.participants = participants
|
||||||
self.exportedInvitation = exportedInvitation
|
self.exportedInvitation = exportedInvitation
|
||||||
self.botInfos = botInfos
|
self.botInfos = botInfos
|
||||||
@ -76,6 +78,7 @@ public final class CachedGroupData: CachedPeerData {
|
|||||||
self.pinnedMessageId = pinnedMessageId
|
self.pinnedMessageId = pinnedMessageId
|
||||||
self.about = about
|
self.about = about
|
||||||
self.flags = flags
|
self.flags = flags
|
||||||
|
self.hasScheduledMessages = hasScheduledMessages
|
||||||
|
|
||||||
var messageIds = Set<MessageId>()
|
var messageIds = Set<MessageId>()
|
||||||
if let pinnedMessageId = self.pinnedMessageId {
|
if let pinnedMessageId = self.pinnedMessageId {
|
||||||
@ -112,6 +115,7 @@ public final class CachedGroupData: CachedPeerData {
|
|||||||
}
|
}
|
||||||
self.about = decoder.decodeOptionalStringForKey("ab")
|
self.about = decoder.decodeOptionalStringForKey("ab")
|
||||||
self.flags = CachedGroupFlags(rawValue: decoder.decodeInt32ForKey("fl", orElse: 0))
|
self.flags = CachedGroupFlags(rawValue: decoder.decodeInt32ForKey("fl", orElse: 0))
|
||||||
|
self.hasScheduledMessages = decoder.decodeBoolForKey("hsm", orElse: false)
|
||||||
|
|
||||||
var messageIds = Set<MessageId>()
|
var messageIds = Set<MessageId>()
|
||||||
if let pinnedMessageId = self.pinnedMessageId {
|
if let pinnedMessageId = self.pinnedMessageId {
|
||||||
@ -164,6 +168,7 @@ public final class CachedGroupData: CachedPeerData {
|
|||||||
encoder.encodeNil(forKey: "ab")
|
encoder.encodeNil(forKey: "ab")
|
||||||
}
|
}
|
||||||
encoder.encodeInt32(self.flags.rawValue, forKey: "fl")
|
encoder.encodeInt32(self.flags.rawValue, forKey: "fl")
|
||||||
|
encoder.encodeBool(self.hasScheduledMessages, forKey: "hsm")
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isEqual(to: CachedPeerData) -> Bool {
|
public func isEqual(to: CachedPeerData) -> Bool {
|
||||||
@ -171,34 +176,38 @@ public final class CachedGroupData: CachedPeerData {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.participants == other.participants && self.exportedInvitation == other.exportedInvitation && self.botInfos == other.botInfos && self.peerStatusSettings == other.peerStatusSettings && self.pinnedMessageId == other.pinnedMessageId && self.about == other.about && self.flags == other.flags
|
return self.participants == other.participants && self.exportedInvitation == other.exportedInvitation && self.botInfos == other.botInfos && self.peerStatusSettings == other.peerStatusSettings && self.pinnedMessageId == other.pinnedMessageId && self.about == other.about && self.flags == other.flags && self.hasScheduledMessages == other.hasScheduledMessages
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedParticipants(_ participants: CachedGroupParticipants?) -> CachedGroupData {
|
func withUpdatedParticipants(_ participants: CachedGroupParticipants?) -> CachedGroupData {
|
||||||
return CachedGroupData(participants: participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags)
|
return CachedGroupData(participants: participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedExportedInvitation(_ exportedInvitation: ExportedInvitation?) -> CachedGroupData {
|
func withUpdatedExportedInvitation(_ exportedInvitation: ExportedInvitation?) -> CachedGroupData {
|
||||||
return CachedGroupData(participants: self.participants, exportedInvitation: exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags)
|
return CachedGroupData(participants: self.participants, exportedInvitation: exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedBotInfos(_ botInfos: [CachedPeerBotInfo]) -> CachedGroupData {
|
func withUpdatedBotInfos(_ botInfos: [CachedPeerBotInfo]) -> CachedGroupData {
|
||||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags)
|
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedPeerStatusSettings(_ peerStatusSettings: PeerStatusSettings?) -> CachedGroupData {
|
func withUpdatedPeerStatusSettings(_ peerStatusSettings: PeerStatusSettings?) -> CachedGroupData {
|
||||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags)
|
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedPinnedMessageId(_ pinnedMessageId: MessageId?) -> CachedGroupData {
|
func withUpdatedPinnedMessageId(_ pinnedMessageId: MessageId?) -> CachedGroupData {
|
||||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: pinnedMessageId, about: self.about, flags: self.flags)
|
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: pinnedMessageId, about: self.about, flags: self.flags, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedAbout(_ about: String?) -> CachedGroupData {
|
func withUpdatedAbout(_ about: String?) -> CachedGroupData {
|
||||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: about, flags: self.flags)
|
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: about, flags: self.flags, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedFlags(_ flags: CachedGroupFlags) -> CachedGroupData {
|
func withUpdatedFlags(_ flags: CachedGroupFlags) -> CachedGroupData {
|
||||||
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: flags)
|
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: flags, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
|
}
|
||||||
|
|
||||||
|
func withUpdatedHasScheduledMessages(_ hasScheduledMessages: Bool) -> CachedGroupData {
|
||||||
|
return CachedGroupData(participants: self.participants, exportedInvitation: self.exportedInvitation, botInfos: self.botInfos, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, about: self.about, flags: self.flags, hasScheduledMessages: hasScheduledMessages)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ public final class CachedUserData: CachedPeerData {
|
|||||||
public let callsAvailable: Bool
|
public let callsAvailable: Bool
|
||||||
public let callsPrivate: Bool
|
public let callsPrivate: Bool
|
||||||
public let canPinMessages: Bool
|
public let canPinMessages: Bool
|
||||||
|
public let hasScheduledMessages: Bool
|
||||||
|
|
||||||
public let peerIds = Set<PeerId>()
|
public let peerIds = Set<PeerId>()
|
||||||
public let messageIds: Set<MessageId>
|
public let messageIds: Set<MessageId>
|
||||||
@ -30,10 +31,11 @@ public final class CachedUserData: CachedPeerData {
|
|||||||
self.callsAvailable = false
|
self.callsAvailable = false
|
||||||
self.callsPrivate = false
|
self.callsPrivate = false
|
||||||
self.canPinMessages = false
|
self.canPinMessages = false
|
||||||
|
self.hasScheduledMessages = false
|
||||||
self.messageIds = Set()
|
self.messageIds = Set()
|
||||||
}
|
}
|
||||||
|
|
||||||
init(about: String?, botInfo: BotInfo?, peerStatusSettings: PeerStatusSettings?, pinnedMessageId: MessageId?, isBlocked: Bool, commonGroupCount: Int32, callsAvailable: Bool, callsPrivate: Bool, canPinMessages: Bool) {
|
init(about: String?, botInfo: BotInfo?, peerStatusSettings: PeerStatusSettings?, pinnedMessageId: MessageId?, isBlocked: Bool, commonGroupCount: Int32, callsAvailable: Bool, callsPrivate: Bool, canPinMessages: Bool, hasScheduledMessages: Bool) {
|
||||||
self.about = about
|
self.about = about
|
||||||
self.botInfo = botInfo
|
self.botInfo = botInfo
|
||||||
self.peerStatusSettings = peerStatusSettings
|
self.peerStatusSettings = peerStatusSettings
|
||||||
@ -43,6 +45,7 @@ public final class CachedUserData: CachedPeerData {
|
|||||||
self.callsAvailable = callsAvailable
|
self.callsAvailable = callsAvailable
|
||||||
self.callsPrivate = callsPrivate
|
self.callsPrivate = callsPrivate
|
||||||
self.canPinMessages = canPinMessages
|
self.canPinMessages = canPinMessages
|
||||||
|
self.hasScheduledMessages = hasScheduledMessages
|
||||||
var messageIds = Set<MessageId>()
|
var messageIds = Set<MessageId>()
|
||||||
if let pinnedMessageId = self.pinnedMessageId {
|
if let pinnedMessageId = self.pinnedMessageId {
|
||||||
messageIds.insert(pinnedMessageId)
|
messageIds.insert(pinnedMessageId)
|
||||||
@ -68,6 +71,7 @@ public final class CachedUserData: CachedPeerData {
|
|||||||
self.callsAvailable = decoder.decodeInt32ForKey("ca", orElse: 0) != 0
|
self.callsAvailable = decoder.decodeInt32ForKey("ca", orElse: 0) != 0
|
||||||
self.callsPrivate = decoder.decodeInt32ForKey("cp", orElse: 0) != 0
|
self.callsPrivate = decoder.decodeInt32ForKey("cp", orElse: 0) != 0
|
||||||
self.canPinMessages = decoder.decodeInt32ForKey("cpm", orElse: 0) != 0
|
self.canPinMessages = decoder.decodeInt32ForKey("cpm", orElse: 0) != 0
|
||||||
|
self.hasScheduledMessages = decoder.decodeBoolForKey("hsm", orElse: false)
|
||||||
|
|
||||||
var messageIds = Set<MessageId>()
|
var messageIds = Set<MessageId>()
|
||||||
if let pinnedMessageId = self.pinnedMessageId {
|
if let pinnedMessageId = self.pinnedMessageId {
|
||||||
@ -106,6 +110,7 @@ public final class CachedUserData: CachedPeerData {
|
|||||||
encoder.encodeInt32(self.callsAvailable ? 1 : 0, forKey: "ca")
|
encoder.encodeInt32(self.callsAvailable ? 1 : 0, forKey: "ca")
|
||||||
encoder.encodeInt32(self.callsPrivate ? 1 : 0, forKey: "cp")
|
encoder.encodeInt32(self.callsPrivate ? 1 : 0, forKey: "cp")
|
||||||
encoder.encodeInt32(self.canPinMessages ? 1 : 0, forKey: "cpm")
|
encoder.encodeInt32(self.canPinMessages ? 1 : 0, forKey: "cpm")
|
||||||
|
encoder.encodeBool(self.hasScheduledMessages, forKey: "hsm")
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isEqual(to: CachedPeerData) -> Bool {
|
public func isEqual(to: CachedPeerData) -> Bool {
|
||||||
@ -120,42 +125,46 @@ public final class CachedUserData: CachedPeerData {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return other.about == self.about && other.botInfo == self.botInfo && self.peerStatusSettings == other.peerStatusSettings && self.isBlocked == other.isBlocked && self.commonGroupCount == other.commonGroupCount && self.callsAvailable == other.callsAvailable && self.callsPrivate == other.callsPrivate
|
return other.about == self.about && other.botInfo == self.botInfo && self.peerStatusSettings == other.peerStatusSettings && self.isBlocked == other.isBlocked && self.commonGroupCount == other.commonGroupCount && self.callsAvailable == other.callsAvailable && self.callsPrivate == other.callsPrivate && self.hasScheduledMessages == other.hasScheduledMessages
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedAbout(_ about: String?) -> CachedUserData {
|
func withUpdatedAbout(_ about: String?) -> CachedUserData {
|
||||||
return CachedUserData(about: about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
return CachedUserData(about: about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedBotInfo(_ botInfo: BotInfo?) -> CachedUserData {
|
func withUpdatedBotInfo(_ botInfo: BotInfo?) -> CachedUserData {
|
||||||
return CachedUserData(about: self.about, botInfo: botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
return CachedUserData(about: self.about, botInfo: botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedPeerStatusSettings(_ peerStatusSettings: PeerStatusSettings) -> CachedUserData {
|
func withUpdatedPeerStatusSettings(_ peerStatusSettings: PeerStatusSettings) -> CachedUserData {
|
||||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedPinnedMessageId(_ pinnedMessageId: MessageId?) -> CachedUserData {
|
func withUpdatedPinnedMessageId(_ pinnedMessageId: MessageId?) -> CachedUserData {
|
||||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedIsBlocked(_ isBlocked: Bool) -> CachedUserData {
|
func withUpdatedIsBlocked(_ isBlocked: Bool) -> CachedUserData {
|
||||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedCommonGroupCount(_ commonGroupCount: Int32) -> CachedUserData {
|
func withUpdatedCommonGroupCount(_ commonGroupCount: Int32) -> CachedUserData {
|
||||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedCallsAvailable(_ callsAvailable: Bool) -> CachedUserData {
|
func withUpdatedCallsAvailable(_ callsAvailable: Bool) -> CachedUserData {
|
||||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages)
|
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedCallsPrivate(_ callsPrivate: Bool) -> CachedUserData {
|
func withUpdatedCallsPrivate(_ callsPrivate: Bool) -> CachedUserData {
|
||||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: callsPrivate, canPinMessages: self.canPinMessages)
|
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: callsPrivate, canPinMessages: self.canPinMessages, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedCanPinMessages(_ canPinMessages: Bool) -> CachedUserData {
|
func withUpdatedCanPinMessages(_ canPinMessages: Bool) -> CachedUserData {
|
||||||
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: canPinMessages)
|
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: canPinMessages, hasScheduledMessages: self.hasScheduledMessages)
|
||||||
|
}
|
||||||
|
|
||||||
|
func withUpdatedHasScheduledMessages(_ hasScheduledMessages: Bool) -> CachedUserData {
|
||||||
|
return CachedUserData(about: self.about, botInfo: self.botInfo, peerStatusSettings: self.peerStatusSettings, pinnedMessageId: self.pinnedMessageId, isBlocked: self.isBlocked, commonGroupCount: self.commonGroupCount, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, canPinMessages: self.canPinMessages, hasScheduledMessages: hasScheduledMessages)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,6 +284,26 @@ final class HistoryViewStateValidationContexts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func hashForScheduledMessages(_ messages: [Message]) -> Int32 {
|
||||||
|
var acc: UInt32 = 0
|
||||||
|
|
||||||
|
let sorted = messages.sorted(by: { $0.timestamp > $1.timestamp })
|
||||||
|
|
||||||
|
for message in sorted {
|
||||||
|
acc = (acc &* 20261) &+ UInt32(message.id.id)
|
||||||
|
var editTimestamp: Int32 = 0
|
||||||
|
inner: for attribute in message.attributes {
|
||||||
|
if let attribute = attribute as? EditedMessageAttribute {
|
||||||
|
editTimestamp = attribute.date
|
||||||
|
break inner
|
||||||
|
}
|
||||||
|
}
|
||||||
|
acc = (acc &* 20261) &+ UInt32(editTimestamp)
|
||||||
|
acc = (acc &* 20261) &+ UInt32(message.timestamp)
|
||||||
|
}
|
||||||
|
return Int32(bitPattern: acc & UInt32(0x7FFFFFFF))
|
||||||
|
}
|
||||||
|
|
||||||
private func hashForMessages(_ messages: [Message], withChannelIds: Bool) -> Int32 {
|
private func hashForMessages(_ messages: [Message], withChannelIds: Bool) -> Int32 {
|
||||||
var acc: UInt32 = 0
|
var acc: UInt32 = 0
|
||||||
|
|
||||||
@ -406,7 +426,8 @@ private func validateScheduledMessagesBatch(postbox: Postbox, network: Network,
|
|||||||
switch historyState {
|
switch historyState {
|
||||||
case let .scheduledMessages(peerId):
|
case let .scheduledMessages(peerId):
|
||||||
if let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) {
|
if let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) {
|
||||||
signal = network.request(Api.functions.messages.getScheduledHistory(peer: inputPeer, hash: 0))
|
let hash = hashForScheduledMessages(messages)
|
||||||
|
signal = network.request(Api.functions.messages.getScheduledHistory(peer: inputPeer, hash: hash))
|
||||||
|> map { result -> ValidatedMessages in
|
|> map { result -> ValidatedMessages in
|
||||||
let messages: [Api.Message]
|
let messages: [Api.Message]
|
||||||
let chats: [Api.Chat]
|
let chats: [Api.Chat]
|
||||||
|
@ -184,7 +184,7 @@ public func updateChannelGeoLocation(postbox: Postbox, network: Network, channel
|
|||||||
} else {
|
} else {
|
||||||
peerGeoLocation = nil
|
peerGeoLocation = nil
|
||||||
}
|
}
|
||||||
return current.withUpdatedPeerGeoLocation(peerGeoLocation: peerGeoLocation)
|
return current.withUpdatedPeerGeoLocation(peerGeoLocation)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|> map { _ in
|
|> map { _ in
|
||||||
|
@ -31,7 +31,7 @@ public func updateChannelSlowModeInteractively(postbox: Postbox, network: Networ
|
|||||||
return postbox.transaction { transaction -> Void in
|
return postbox.transaction { transaction -> Void in
|
||||||
transaction.updatePeerCachedData(peerIds: [peerId], update: { peerId, currentData in
|
transaction.updatePeerCachedData(peerIds: [peerId], update: { peerId, currentData in
|
||||||
let currentData = currentData as? CachedChannelData ?? CachedChannelData()
|
let currentData = currentData as? CachedChannelData ?? CachedChannelData()
|
||||||
return currentData.withUpdatedSlowModeTimeout(slowModeTimeout: timeout)
|
return currentData.withUpdatedSlowModeTimeout(timeout)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|> introduceError(UpdateChannelSlowModeError.self)
|
|> introduceError(UpdateChannelSlowModeError.self)
|
||||||
|
@ -176,8 +176,13 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPeerId: PeerI
|
|||||||
let pinnedMessageId = userFull.pinnedMsgId.flatMap({ MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: $0) })
|
let pinnedMessageId = userFull.pinnedMsgId.flatMap({ MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: $0) })
|
||||||
|
|
||||||
let peerStatusSettings = PeerStatusSettings(apiSettings: userFull.settings)
|
let peerStatusSettings = PeerStatusSettings(apiSettings: userFull.settings)
|
||||||
|
|
||||||
|
var hasScheduledMessages = false
|
||||||
|
if (userFull.flags & 1 << 12) != 0 {
|
||||||
|
hasScheduledMessages = true
|
||||||
|
}
|
||||||
|
|
||||||
return previous.withUpdatedAbout(userFull.about).withUpdatedBotInfo(botInfo).withUpdatedCommonGroupCount(userFull.commonChatsCount).withUpdatedIsBlocked(isBlocked).withUpdatedCallsAvailable(callsAvailable).withUpdatedCallsPrivate(callsPrivate).withUpdatedCanPinMessages(canPinMessages).withUpdatedPeerStatusSettings(peerStatusSettings).withUpdatedPinnedMessageId(pinnedMessageId)
|
return previous.withUpdatedAbout(userFull.about).withUpdatedBotInfo(botInfo).withUpdatedCommonGroupCount(userFull.commonChatsCount).withUpdatedIsBlocked(isBlocked).withUpdatedCallsAvailable(callsAvailable).withUpdatedCallsPrivate(callsPrivate).withUpdatedCanPinMessages(canPinMessages).withUpdatedPeerStatusSettings(peerStatusSettings).withUpdatedPinnedMessageId(pinnedMessageId).withUpdatedHasScheduledMessages(hasScheduledMessages)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -237,6 +242,11 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPeerId: PeerI
|
|||||||
flags.insert(.canChangeUsername)
|
flags.insert(.canChangeUsername)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hasScheduledMessages = false
|
||||||
|
if (chatFull.flags & 1 << 8) != 0 {
|
||||||
|
hasScheduledMessages = true
|
||||||
|
}
|
||||||
|
|
||||||
transaction.updatePeerCachedData(peerIds: [peerId], update: { _, current in
|
transaction.updatePeerCachedData(peerIds: [peerId], update: { _, current in
|
||||||
let previous: CachedGroupData
|
let previous: CachedGroupData
|
||||||
if let current = current as? CachedGroupData {
|
if let current = current as? CachedGroupData {
|
||||||
@ -251,6 +261,7 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPeerId: PeerI
|
|||||||
.withUpdatedPinnedMessageId(pinnedMessageId)
|
.withUpdatedPinnedMessageId(pinnedMessageId)
|
||||||
.withUpdatedAbout(chatFull.about)
|
.withUpdatedAbout(chatFull.about)
|
||||||
.withUpdatedFlags(flags)
|
.withUpdatedFlags(flags)
|
||||||
|
.withUpdatedHasScheduledMessages(hasScheduledMessages)
|
||||||
})
|
})
|
||||||
case .channelFull:
|
case .channelFull:
|
||||||
break
|
break
|
||||||
@ -379,6 +390,11 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPeerId: PeerI
|
|||||||
return StickerPackCollectionInfo(apiSet: apiSet, namespace: namespace)
|
return StickerPackCollectionInfo(apiSet: apiSet, namespace: namespace)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hasScheduledMessages = false
|
||||||
|
if (flags & (1 << 19)) != 0 {
|
||||||
|
hasScheduledMessages = true
|
||||||
|
}
|
||||||
|
|
||||||
var minAvailableMessageIdUpdated = false
|
var minAvailableMessageIdUpdated = false
|
||||||
transaction.updatePeerCachedData(peerIds: [peerId], update: { _, current in
|
transaction.updatePeerCachedData(peerIds: [peerId], update: { _, current in
|
||||||
var previous: CachedChannelData
|
var previous: CachedChannelData
|
||||||
@ -402,9 +418,10 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPeerId: PeerI
|
|||||||
.withUpdatedMinAvailableMessageId(minAvailableMessageId)
|
.withUpdatedMinAvailableMessageId(minAvailableMessageId)
|
||||||
.withUpdatedMigrationReference(migrationReference)
|
.withUpdatedMigrationReference(migrationReference)
|
||||||
.withUpdatedLinkedDiscussionPeerId(linkedDiscussionPeerId)
|
.withUpdatedLinkedDiscussionPeerId(linkedDiscussionPeerId)
|
||||||
.withUpdatedPeerGeoLocation(peerGeoLocation: peerGeoLocation)
|
.withUpdatedPeerGeoLocation(peerGeoLocation)
|
||||||
.withUpdatedSlowModeTimeout(slowModeTimeout: slowmodeSeconds)
|
.withUpdatedSlowModeTimeout(slowmodeSeconds)
|
||||||
.withUpdatedSlowModeValidUntilTimestamp(slowModeValidUntilTimestamp: slowmodeNextSendDate)
|
.withUpdatedSlowModeValidUntilTimestamp(slowmodeNextSendDate)
|
||||||
|
.withUpdatedHasScheduledMessages(hasScheduledMessages)
|
||||||
})
|
})
|
||||||
|
|
||||||
if let minAvailableMessageId = minAvailableMessageId, minAvailableMessageIdUpdated {
|
if let minAvailableMessageId = minAvailableMessageId, minAvailableMessageIdUpdated {
|
||||||
|
@ -13,18 +13,44 @@ private func makeDarkPresentationTheme(accentColor: UIColor, baseColor: Presenta
|
|||||||
let outgoingBubbleHighlightedFillColor: UIColor
|
let outgoingBubbleHighlightedFillColor: UIColor
|
||||||
let outgoingScamColor: UIColor
|
let outgoingScamColor: UIColor
|
||||||
|
|
||||||
|
let outgoingPrimaryTextColor: UIColor
|
||||||
|
let outgoingSecondaryTextColor: UIColor
|
||||||
|
let outgoingLinkTextColor: UIColor
|
||||||
|
let outgoingCheckColor: UIColor
|
||||||
|
|
||||||
if accentColor.rgb == UIColor.white.rgb {
|
if accentColor.rgb == UIColor.white.rgb {
|
||||||
badgeFillColor = .white
|
badgeFillColor = .white
|
||||||
badgeTextColor = .black
|
badgeTextColor = .black
|
||||||
outgoingBubbleFillColor = UIColor(rgb: 0x313131)
|
outgoingBubbleFillColor = UIColor(rgb: 0x313131)
|
||||||
outgoingBubbleHighlightedFillColor = UIColor(rgb: 0x464646)
|
outgoingBubbleHighlightedFillColor = UIColor(rgb: 0x464646)
|
||||||
outgoingScamColor = destructiveColor
|
outgoingScamColor = destructiveColor
|
||||||
|
|
||||||
|
outgoingPrimaryTextColor = .white
|
||||||
|
outgoingSecondaryTextColor = UIColor(rgb: 0xffffff, alpha: 0.5)
|
||||||
|
outgoingLinkTextColor = .white
|
||||||
|
outgoingCheckColor = UIColor(rgb: 0xffffff, alpha: 0.5)
|
||||||
} else {
|
} else {
|
||||||
badgeFillColor = destructiveColor
|
badgeFillColor = destructiveColor
|
||||||
badgeTextColor = .white
|
badgeTextColor = .white
|
||||||
outgoingBubbleFillColor = accentColor
|
outgoingBubbleFillColor = accentColor
|
||||||
outgoingBubbleHighlightedFillColor = accentColor.withMultipliedBrightnessBy(1.421)
|
outgoingBubbleHighlightedFillColor = accentColor.withMultipliedBrightnessBy(1.421)
|
||||||
outgoingScamColor = .white
|
|
||||||
|
|
||||||
|
if accentColor.lightness > 0.72 {
|
||||||
|
outgoingScamColor = .black
|
||||||
|
|
||||||
|
outgoingPrimaryTextColor = .black
|
||||||
|
outgoingSecondaryTextColor = UIColor(rgb: 0x000000, alpha: 0.5)
|
||||||
|
outgoingLinkTextColor = .black
|
||||||
|
outgoingCheckColor = UIColor(rgb: 0x000000, alpha: 0.5)
|
||||||
|
} else {
|
||||||
|
outgoingScamColor = .white
|
||||||
|
|
||||||
|
outgoingPrimaryTextColor = .white
|
||||||
|
outgoingSecondaryTextColor = UIColor(rgb: 0xffffff, alpha: 0.5)
|
||||||
|
outgoingLinkTextColor = .white
|
||||||
|
outgoingCheckColor = UIColor(rgb: 0xffffff, alpha: 0.5)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let rootTabBar = PresentationThemeRootTabBar(
|
let rootTabBar = PresentationThemeRootTabBar(
|
||||||
@ -176,11 +202,11 @@ private func makeDarkPresentationTheme(accentColor: UIColor, baseColor: Presenta
|
|||||||
|
|
||||||
let message = PresentationThemeChatMessage(
|
let message = PresentationThemeChatMessage(
|
||||||
incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x262628), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x262628), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628))), primaryTextColor: .white, secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: accentColor, linkHighlightColor: accentColor.withAlphaComponent(0.5), scamColor: destructiveColor, textHighlightColor: UIColor(rgb: 0xffe438), accentTextColor: accentColor, accentControlColor: accentColor, mediaActiveControlColor: accentColor, mediaInactiveControlColor: accentColor.withAlphaComponent(0.4), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: accentColor, fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x1f1f1f).mixedWith(.white, alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0x737373), radioProgress: accentColor, highlight: accentColor.withAlphaComponent(0.12), separator: UIColor(rgb: 0x000000), bar: accentColor), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff))),
|
incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x262628), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x262628), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628))), primaryTextColor: .white, secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: accentColor, linkHighlightColor: accentColor.withAlphaComponent(0.5), scamColor: destructiveColor, textHighlightColor: UIColor(rgb: 0xffe438), accentTextColor: accentColor, accentControlColor: accentColor, mediaActiveControlColor: accentColor, mediaInactiveControlColor: accentColor.withAlphaComponent(0.4), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: accentColor, fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x1f1f1f).mixedWith(.white, alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0x737373), radioProgress: accentColor, highlight: accentColor.withAlphaComponent(0.12), separator: UIColor(rgb: 0x000000), bar: accentColor), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff))),
|
||||||
outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, highlightedFill: outgoingBubbleHighlightedFillColor, stroke: outgoingBubbleFillColor), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, highlightedFill: outgoingBubbleHighlightedFillColor, stroke: outgoingBubbleFillColor)), primaryTextColor: .white, secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: .white, linkHighlightColor: UIColor.white.withAlphaComponent(0.5), scamColor: outgoingScamColor, textHighlightColor: UIColor(rgb: 0xffe438), accentTextColor: .white, accentControlColor: .white, mediaActiveControlColor: .white, mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.3), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: .white, fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x313131).mixedWith(.white, alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: .white, radioProgress: .white, highlight: UIColor(white: 1.0, alpha: 0.12), separator: UIColor(white: 1.0, alpha: 0.3), bar: .white), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff))),
|
outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, highlightedFill: outgoingBubbleHighlightedFillColor, stroke: outgoingBubbleFillColor), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, highlightedFill: outgoingBubbleHighlightedFillColor, stroke: outgoingBubbleFillColor)), primaryTextColor: outgoingPrimaryTextColor, secondaryTextColor: outgoingSecondaryTextColor, linkTextColor: outgoingLinkTextColor, linkHighlightColor: UIColor.white.withAlphaComponent(0.5), scamColor: outgoingScamColor, textHighlightColor: UIColor(rgb: 0xffe438), accentTextColor: .white, accentControlColor: .white, mediaActiveControlColor: .white, mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.3), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: .white, fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x313131).mixedWith(.white, alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: .white, radioProgress: .white, highlight: UIColor(white: 1.0, alpha: 0.12), separator: UIColor(white: 1.0, alpha: 0.3), bar: .white), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff))),
|
||||||
freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f))),
|
freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f))),
|
||||||
infoPrimaryTextColor: .white,
|
infoPrimaryTextColor: .white,
|
||||||
infoLinkTextColor: accentColor,
|
infoLinkTextColor: accentColor,
|
||||||
outgoingCheckColor: .white,
|
outgoingCheckColor: outgoingCheckColor,
|
||||||
mediaDateAndStatusFillColor: UIColor(white: 0.0, alpha: 0.5),
|
mediaDateAndStatusFillColor: UIColor(white: 0.0, alpha: 0.5),
|
||||||
mediaDateAndStatusTextColor: .white,
|
mediaDateAndStatusTextColor: .white,
|
||||||
shareButtonFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)),
|
shareButtonFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)),
|
||||||
|
@ -8,13 +8,11 @@ private func makeDefaultDayPresentationTheme(accentColor: UIColor, serviceBackgr
|
|||||||
let constructiveColor: UIColor = UIColor(rgb: 0x00c900)
|
let constructiveColor: UIColor = UIColor(rgb: 0x00c900)
|
||||||
let secretColor: UIColor = UIColor(rgb: 0x00b12c)
|
let secretColor: UIColor = UIColor(rgb: 0x00b12c)
|
||||||
|
|
||||||
let accentColorHSV = accentColor.hsv
|
|
||||||
|
|
||||||
let outgoingPrimaryTextColor: UIColor
|
let outgoingPrimaryTextColor: UIColor
|
||||||
let outgoingSecondaryTextColor: UIColor
|
let outgoingSecondaryTextColor: UIColor
|
||||||
let outgoingLinkTextColor: UIColor
|
let outgoingLinkTextColor: UIColor
|
||||||
let outgoingCheckColor: UIColor
|
let outgoingCheckColor: UIColor
|
||||||
if accentColorHSV.2 > 0.83 {
|
if accentColor.lightness > 0.72 {
|
||||||
outgoingPrimaryTextColor = .black
|
outgoingPrimaryTextColor = .black
|
||||||
outgoingSecondaryTextColor = UIColor(rgb: 0x000000, alpha: 0.6)
|
outgoingSecondaryTextColor = UIColor(rgb: 0x000000, alpha: 0.6)
|
||||||
outgoingLinkTextColor = .black
|
outgoingLinkTextColor = .black
|
||||||
|
@ -150,14 +150,15 @@ private func currentDateTimeFormat() -> PresentationDateTimeFormat {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if dateString.contains("M\(dateSeparator)d") {
|
||||||
|
dateFormat = .monthFirst
|
||||||
if dateString.contains("M\(dateSeparator)d") {
|
} else {
|
||||||
dateFormat = .monthFirst
|
dateFormat = .dayFirst
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dateFormat = .dayFirst
|
dateFormat = .dayFirst
|
||||||
}
|
}
|
||||||
|
|
||||||
let decimalSeparator = locale.decimalSeparator ?? "."
|
let decimalSeparator = locale.decimalSeparator ?? "."
|
||||||
let groupingSeparator = locale.groupingSeparator ?? ""
|
let groupingSeparator = locale.groupingSeparator ?? ""
|
||||||
return PresentationDateTimeFormat(timeFormat: timeFormat, dateFormat: dateFormat, dateSeparator: dateSeparator, decimalSeparator: decimalSeparator, groupingSeparator: groupingSeparator)
|
return PresentationDateTimeFormat(timeFormat: timeFormat, dateFormat: dateFormat, dateSeparator: dateSeparator, decimalSeparator: decimalSeparator, groupingSeparator: groupingSeparator)
|
||||||
|
@ -5839,7 +5839,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if case let .peer(peerId) = self.chatLocation, let messageId = messageLocation.messageId, (messageId.peerId != peerId && !forceInCurrentChat) || self.presentationInterfaceState.isScheduledMessages {
|
if case let .peer(peerId) = self.chatLocation, let messageId = messageLocation.messageId, (messageId.peerId != peerId && !forceInCurrentChat) || (self.presentationInterfaceState.isScheduledMessages && messageId.id != 0) {
|
||||||
if let navigationController = self.navigationController as? NavigationController {
|
if let navigationController = self.navigationController as? NavigationController {
|
||||||
self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: self.context, chatLocation: .peer(messageId.peerId), messageId: messageId, keepStack: .always))
|
self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: self.context, chatLocation: .peer(messageId.peerId), messageId: messageId, keepStack: .always))
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,7 @@ private final class ActionSheetItemNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc private func buttonPressed() {
|
@objc private func buttonPressed() {
|
||||||
|
self.buttonNode.isUserInteractionEnabled = false
|
||||||
self.action()
|
self.action()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -613,6 +614,7 @@ final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc private func sendButtonPressed() {
|
@objc private func sendButtonPressed() {
|
||||||
|
self.sendButtonNode.isUserInteractionEnabled = false
|
||||||
self.send?()
|
self.send?()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user