mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
ed5f2636aa
commit
7c16a1d0eb
@ -28,9 +28,11 @@ private final class CachedImageRecognizedContent: Codable {
|
||||
|
||||
private func cachedImageRecognizedContent(postbox: Postbox, messageId: MessageId) -> Signal<CachedImageRecognizedContent?, NoError> {
|
||||
return postbox.transaction { transaction -> CachedImageRecognizedContent? in
|
||||
let key = ValueBoxKey(length: 8)
|
||||
let key = ValueBoxKey(length: 20)
|
||||
key.setInt32(0, value: messageId.namespace)
|
||||
key.setInt32(4, value: messageId.id)
|
||||
key.setInt32(4, value: messageId.peerId.namespace._internalGetInt32Value())
|
||||
key.setInt64(8, value: messageId.peerId.id._internalGetInt64Value())
|
||||
key.setInt32(16, value: messageId.id)
|
||||
if let entry = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: ApplicationSpecificItemCacheCollectionId.cachedImageRecognizedContent, key: key))?.get(CachedImageRecognizedContent.self) {
|
||||
return entry
|
||||
} else {
|
||||
@ -43,9 +45,11 @@ private let collectionSpec = ItemCacheCollectionSpec(lowWaterItemCount: 50, high
|
||||
|
||||
private func updateCachedImageRecognizedContent(postbox: Postbox, messageId: MessageId, content: CachedImageRecognizedContent?) -> Signal<Void, NoError> {
|
||||
return postbox.transaction { transaction -> Void in
|
||||
let key = ValueBoxKey(length: 8)
|
||||
let key = ValueBoxKey(length: 20)
|
||||
key.setInt32(0, value: messageId.namespace)
|
||||
key.setInt32(4, value: messageId.id)
|
||||
key.setInt32(4, value: messageId.peerId.namespace._internalGetInt32Value())
|
||||
key.setInt64(8, value: messageId.peerId.id._internalGetInt64Value())
|
||||
key.setInt32(16, value: messageId.id)
|
||||
let id = ItemCacheEntryId(collectionId: ApplicationSpecificItemCacheCollectionId.cachedImageRecognizedContent, key: key)
|
||||
if let content = content, let entry = CodableEntry(content) {
|
||||
transaction.putItemCacheEntry(id: id, entry: entry, collectionSpec: collectionSpec)
|
||||
|
@ -463,7 +463,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
||||
case let .assets(fetchResult, preload, mediaAccess, cameraAccess):
|
||||
if let fetchResult = fetchResult {
|
||||
let totalCount = fetchResult.count
|
||||
let count = preload ? min(10, totalCount) : totalCount
|
||||
let count = preload ? min(13, totalCount) : totalCount
|
||||
|
||||
for i in 0 ..< count {
|
||||
let index: Int
|
||||
|
@ -31,9 +31,11 @@ public final class MediaPlaybackStoredState: Codable {
|
||||
|
||||
public func mediaPlaybackStoredState(postbox: Postbox, messageId: MessageId) -> Signal<MediaPlaybackStoredState?, NoError> {
|
||||
return postbox.transaction { transaction -> MediaPlaybackStoredState? in
|
||||
let key = ValueBoxKey(length: 8)
|
||||
let key = ValueBoxKey(length: 20)
|
||||
key.setInt32(0, value: messageId.namespace)
|
||||
key.setInt32(4, value: messageId.id)
|
||||
key.setInt32(4, value: messageId.peerId.namespace._internalGetInt32Value())
|
||||
key.setInt64(8, value: messageId.peerId.id._internalGetInt64Value())
|
||||
key.setInt32(16, value: messageId.id)
|
||||
if let entry = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: ApplicationSpecificItemCacheCollectionId.mediaPlaybackStoredState, key: key))?.get(MediaPlaybackStoredState.self) {
|
||||
return entry
|
||||
} else {
|
||||
@ -46,9 +48,11 @@ private let collectionSpec = ItemCacheCollectionSpec(lowWaterItemCount: 25, high
|
||||
|
||||
public func updateMediaPlaybackStoredStateInteractively(postbox: Postbox, messageId: MessageId, state: MediaPlaybackStoredState?) -> Signal<Void, NoError> {
|
||||
return postbox.transaction { transaction -> Void in
|
||||
let key = ValueBoxKey(length: 8)
|
||||
let key = ValueBoxKey(length: 20)
|
||||
key.setInt32(0, value: messageId.namespace)
|
||||
key.setInt32(4, value: messageId.id)
|
||||
key.setInt32(4, value: messageId.peerId.namespace._internalGetInt32Value())
|
||||
key.setInt64(8, value: messageId.peerId.id._internalGetInt64Value())
|
||||
key.setInt32(16, value: messageId.id)
|
||||
let id = ItemCacheEntryId(collectionId: ApplicationSpecificItemCacheCollectionId.mediaPlaybackStoredState, key: key)
|
||||
if let state = state, let entry = CodableEntry(state) {
|
||||
transaction.putItemCacheEntry(id: id, entry: entry, collectionSpec: collectionSpec)
|
||||
|
@ -144,6 +144,7 @@ public final class PremiumStickersScreen: ViewController {
|
||||
self.containerNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false)
|
||||
self.textNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false)
|
||||
self.carouselNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false)
|
||||
self.carouselNode.animateOut()
|
||||
|
||||
self.dimNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false)
|
||||
self.blurView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak self] _ in
|
||||
|
@ -67,6 +67,12 @@ final class ReactionCarouselNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
self.scrollTo(1, playReaction: true, duration: 0.5, clockwise: true)
|
||||
}
|
||||
|
||||
func animateOut() {
|
||||
if let standaloneReactionAnimation = self.standaloneReactionAnimation {
|
||||
standaloneReactionAnimation.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false)
|
||||
}
|
||||
}
|
||||
|
||||
func scrollTo(_ index: Int, playReaction: Bool, duration: Double, clockwise: Bool? = nil) {
|
||||
guard index >= 0 && index < self.itemNodes.count else {
|
||||
return
|
||||
@ -188,6 +194,7 @@ final class ReactionCarouselNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
avatarPeers: [],
|
||||
playHaptic: false,
|
||||
isLarge: true,
|
||||
forceSmallEffectAnimation: true,
|
||||
targetView: targetView,
|
||||
addStandaloneReactionAnimation: nil,
|
||||
completion: { [weak standaloneReactionAnimation, weak self] in
|
||||
|
@ -932,11 +932,11 @@ public final class StandaloneReactionAnimation: ASDisplayNode {
|
||||
self.isUserInteractionEnabled = false
|
||||
}
|
||||
|
||||
public func animateReactionSelection(context: AccountContext, theme: PresentationTheme, reaction: ReactionItem, avatarPeers: [EnginePeer], playHaptic: Bool, isLarge: Bool, targetView: UIView, addStandaloneReactionAnimation: ((StandaloneReactionAnimation) -> Void)?, completion: @escaping () -> Void) {
|
||||
self.animateReactionSelection(context: context, theme: theme, reaction: reaction, avatarPeers: avatarPeers, playHaptic: playHaptic, isLarge: isLarge, targetView: targetView, addStandaloneReactionAnimation: addStandaloneReactionAnimation, currentItemNode: nil, completion: completion)
|
||||
public func animateReactionSelection(context: AccountContext, theme: PresentationTheme, reaction: ReactionItem, avatarPeers: [EnginePeer], playHaptic: Bool, isLarge: Bool, forceSmallEffectAnimation: Bool = false, targetView: UIView, addStandaloneReactionAnimation: ((StandaloneReactionAnimation) -> Void)?, completion: @escaping () -> Void) {
|
||||
self.animateReactionSelection(context: context, theme: theme, reaction: reaction, avatarPeers: avatarPeers, playHaptic: playHaptic, isLarge: isLarge, forceSmallEffectAnimation: forceSmallEffectAnimation, targetView: targetView, addStandaloneReactionAnimation: addStandaloneReactionAnimation, currentItemNode: nil, completion: completion)
|
||||
}
|
||||
|
||||
func animateReactionSelection(context: AccountContext, theme: PresentationTheme, reaction: ReactionItem, avatarPeers: [EnginePeer], playHaptic: Bool, isLarge: Bool, targetView: UIView, addStandaloneReactionAnimation: ((StandaloneReactionAnimation) -> Void)?, currentItemNode: ReactionNode?, completion: @escaping () -> Void) {
|
||||
func animateReactionSelection(context: AccountContext, theme: PresentationTheme, reaction: ReactionItem, avatarPeers: [EnginePeer], playHaptic: Bool, isLarge: Bool, forceSmallEffectAnimation: Bool = false, targetView: UIView, addStandaloneReactionAnimation: ((StandaloneReactionAnimation) -> Void)?, currentItemNode: ReactionNode?, completion: @escaping () -> Void) {
|
||||
guard let sourceSnapshotView = targetView.snapshotContentTree() else {
|
||||
completion()
|
||||
return
|
||||
@ -988,7 +988,7 @@ public final class StandaloneReactionAnimation: ASDisplayNode {
|
||||
|
||||
let effectFrame: CGRect
|
||||
let incomingMessage: Bool = expandedFrame.midX < self.bounds.width / 2.0
|
||||
if isLarge {
|
||||
if isLarge && !forceSmallEffectAnimation {
|
||||
effectFrame = expandedFrame.insetBy(dx: -expandedFrame.width * 0.5, dy: -expandedFrame.height * 0.5).offsetBy(dx: incomingMessage ? (expandedFrame.width - 50.0) : (-expandedFrame.width + 50.0), dy: 0.0)
|
||||
} else {
|
||||
effectFrame = expandedFrame.insetBy(dx: -expandedSize.width, dy: -expandedSize.height)
|
||||
@ -1017,7 +1017,7 @@ public final class StandaloneReactionAnimation: ASDisplayNode {
|
||||
let additionalAnimationNode = AnimatedStickerNode()
|
||||
|
||||
let additionalAnimation: TelegramMediaFile
|
||||
if isLarge {
|
||||
if isLarge && !forceSmallEffectAnimation {
|
||||
additionalAnimation = itemNode.item.largeApplicationAnimation
|
||||
if incomingMessage {
|
||||
additionalAnimationNode.transform = CATransform3DMakeScale(-1.0, 1.0, 1.0)
|
||||
|
@ -1271,7 +1271,7 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr
|
||||
}
|
||||
}
|
||||
|
||||
if isCreator {
|
||||
if isCreator { //if let cachedData = data.cachedData as? CachedChannelData, cachedData.flags.contains(.canDeleteHistory) {
|
||||
items[.peerActions]!.append(PeerInfoScreenActionItem(id: ItemDeleteChannel, text: presentationData.strings.ChannelInfo_DeleteChannel, color: .destructive, icon: nil, alignment: .natural, action: {
|
||||
interaction.openDeletePeer()
|
||||
}))
|
||||
@ -4144,16 +4144,6 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
||||
|
||||
self?.openLeavePeer(delete: false)
|
||||
})))
|
||||
|
||||
if let cachedData = data.cachedData as? CachedChannelData, cachedData.flags.contains(.canDeleteHistory) {
|
||||
items.append(.action(ContextMenuActionItem(text: presentationData.strings.ChannelInfo_DeleteChannel, textColor: .destructive, icon: { theme in
|
||||
generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Clear"), color: theme.contextMenu.destructiveColor)
|
||||
}, action: { [weak self] _, f in
|
||||
f(.dismissWithoutContent)
|
||||
|
||||
self?.openLeavePeer(delete: true)
|
||||
})))
|
||||
}
|
||||
}
|
||||
case .group:
|
||||
if case .member = channel.participationStatus, !headerButtons.contains(.leave) {
|
||||
@ -5656,10 +5646,21 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
||||
let dismissAction: () -> Void = { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
}
|
||||
|
||||
let title: String
|
||||
let text: String
|
||||
if isGroup {
|
||||
title = strongSelf.presentationData.strings.PeerInfo_DeleteGroupTitle
|
||||
text = strongSelf.presentationData.strings.PeerInfo_DeleteGroupText(peer.debugDisplayTitle).string
|
||||
} else {
|
||||
title = strongSelf.presentationData.strings.PeerInfo_DeleteChannelTitle
|
||||
text = strongSelf.presentationData.strings.PeerInfo_DeleteChannelText(peer.debugDisplayTitle).string
|
||||
}
|
||||
|
||||
actionSheet.setItemGroups([
|
||||
ActionSheetItemGroup(items: [
|
||||
ActionSheetTextItem(title: isGroup ? presentationData.strings.ChannelInfo_DeleteGroupConfirmation : presentationData.strings.ChannelInfo_DeleteChannelConfirmation),
|
||||
ActionSheetButtonItem(title: isGroup ? presentationData.strings.ChannelInfo_DeleteGroup : presentationData.strings.ChannelInfo_DeleteChannel, color: .destructive, action: {
|
||||
ActionSheetTextItem(title: title),
|
||||
ActionSheetButtonItem(title: text, color: .destructive, action: {
|
||||
dismissAction()
|
||||
self?.deletePeerChat(peer: peer, globally: true)
|
||||
}),
|
||||
|
@ -302,10 +302,6 @@ public func generateTextEntities(_ text: String, enabledTypes: EnabledEntityType
|
||||
}
|
||||
|
||||
public func addLocallyGeneratedEntities(_ text: String, enabledTypes: EnabledEntityTypes, entities: [MessageTextEntity], mediaDuration: Double? = nil) -> [MessageTextEntity]? {
|
||||
if "".isEmpty {
|
||||
return nil
|
||||
}
|
||||
|
||||
var resultEntities = entities
|
||||
|
||||
var hasDigits = false
|
||||
|
Loading…
x
Reference in New Issue
Block a user