diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift index 77098e8839..02b181312a 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift @@ -425,7 +425,6 @@ final class WallpaperGalleryItemNode: GalleryItemNode { } strongSelf.presentationData = presentationData - strongSelf.nativeNode.updateBubbleTheme(bubbleTheme: presentationData.theme, bubbleCorners: presentationData.chatBubbleCorners) if let (layout, _) = strongSelf.validLayout { strongSelf.updateMessagesLayout(layout: layout, offset: CGPoint(), transition: .animated(duration: 0.3, curve: .easeInOut)) @@ -533,7 +532,9 @@ final class WallpaperGalleryItemNode: GalleryItemNode { switch entry { case let .wallpaper(wallpaper, _): - self.nativeNode.update(wallpaper: wallpaper) + Queue.mainQueue().justDispatch { + self.nativeNode.update(wallpaper: wallpaper) + } if case let .file(file) = wallpaper, file.isPattern { self.nativeNode.isHidden = false @@ -559,15 +560,14 @@ final class WallpaperGalleryItemNode: GalleryItemNode { self.nativeNode.update(wallpaper: wallpaper) self.patternButtonNode.isSelected = false } else { + self.nativeNode._internalUpdateIsSettingUpWallpaper() self.nativeNode.isHidden = true self.patternButtonNode.isSelected = false self.playButtonNode.setIcon(self.playButtonRotateImage) } case .asset: self.nativeNode._internalUpdateIsSettingUpWallpaper() - - //self.nativeNode.update(wallpaper: .color(0xff000000)) - self.nativeNode.isHidden = false + self.nativeNode.isHidden = true self.patternButtonNode.isSelected = false self.playButtonNode.setIcon(self.playButtonRotateImage) default: @@ -1322,6 +1322,8 @@ final class WallpaperGalleryItemNode: GalleryItemNode { } private func updateMessagesLayout(layout: ContainerViewLayout, offset: CGPoint, transition: ContainedViewLayoutTransition) { + self.nativeNode.updateBubbleTheme(bubbleTheme: self.presentationData.theme, bubbleCorners: self.presentationData.chatBubbleCorners) + var bottomInset: CGFloat = 132.0 var items: [ListViewItem] = [] @@ -1468,7 +1470,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode { if let _ = serviceMessageText, let messageNodes = self.messageNodes, let node = messageNodes.last { if let backgroundNode = node.subnodes?.first?.subnodes?.first?.subnodes?.first?.subnodes?.first, let backdropNode = node.subnodes?.first?.subnodes?.first?.subnodes?.first?.subnodes?.last?.subnodes?.last?.subnodes?.first { - backdropNode.isHidden = true + backdropNode.isHidden = true let serviceBackgroundFrame = backgroundNode.view.convert(backgroundNode.bounds, to: self.view).offsetBy(dx: 0.0, dy: -1.0).insetBy(dx: 0.0, dy: -1.0) transition.updateFrame(node: self.serviceBackgroundNode, frame: serviceBackgroundFrame) self.serviceBackgroundNode.update(size: serviceBackgroundFrame.size, cornerRadius: serviceBackgroundFrame.height / 2.0, transition: transition) diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperOptionButtonNode.swift b/submodules/SettingsUI/Sources/Themes/WallpaperOptionButtonNode.swift index ab8bc1b3b4..88335906e7 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperOptionButtonNode.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperOptionButtonNode.swift @@ -423,7 +423,6 @@ final class WallpaperOptionButtonNode: HighlightTrackingButtonNode { func setEnabled(_ enabled: Bool) { let alpha: CGFloat = enabled ? 1.0 : 0.4 - self.backgroundNode.alpha = alpha self.checkNode.alpha = alpha self.colorNode.alpha = alpha self.textNode.alpha = alpha diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift b/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift index f7be6abafd..b81a8f26f3 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift @@ -164,6 +164,10 @@ func _internal_setExistingChatWallpaper(account: Account, messageId: MessageId, return account.postbox.transaction { transaction -> Peer? in if let peer = transaction.getPeer(messageId.peerId), let message = transaction.getMessage(messageId) { if let action = message.media.first(where: { $0 is TelegramMediaAction }) as? TelegramMediaAction, case let .setChatWallpaper(wallpaper) = action.action { + var wallpaper = wallpaper + if let settings = settings { + wallpaper = wallpaper.withUpdatedSettings(settings) + } transaction.updatePeerCachedData(peerIds: Set([peer.id]), update: { _, current in if let current = current as? CachedUserData { return current.withUpdatedWallpaper(wallpaper) diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 710f40a519..186396ff83 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -858,11 +858,18 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } strongSelf.chatDisplayNode.dismissInput() let wallpaperPreviewController = WallpaperGalleryController(context: strongSelf.context, source: .wallpaper(wallpaper, nil, [], nil, nil, nil), mode: .peer(EnginePeer(peer), true)) - wallpaperPreviewController.apply = { wallpaper, options, _, _ in - let _ = (strongSelf.context.engine.themes.setExistingChatWallpaper(messageId: message.id, settings: nil) - |> deliverOnMainQueue).start(completed: { [weak wallpaperPreviewController] in - wallpaperPreviewController?.dismiss() - }) + wallpaperPreviewController.apply = { [weak wallpaperPreviewController] entry, options, _, _ in + if case let .wallpaper(wallpaper, _) = entry, case let .file(file) = wallpaper, !file.isPattern && options.contains(.blur) { + uploadCustomPeerWallpaper(context: strongSelf.context, wallpaper: entry, mode: options, cropRect: nil, brightness: nil, peerId: message.id.peerId, completion: { + wallpaperPreviewController?.dismiss() + }) + } else { + let _ = (strongSelf.context.engine.themes.setExistingChatWallpaper(messageId: message.id, settings: nil) + |> deliverOnMainQueue).start() + Queue.mainQueue().after(0.1) { + wallpaperPreviewController?.dismiss() + } + } } strongSelf.push(wallpaperPreviewController) return true @@ -5861,7 +5868,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G var themeEmoticon = themeEmoticon if let themeEmoticonPreview = themeEmoticonPreview { if !themeEmoticonPreview.isEmpty { - if themeEmoticon != themeEmoticonPreview { + if themeEmoticon?.strippedEmoji != themeEmoticonPreview.strippedEmoji { chatWallpaper = nil themeEmoticon = themeEmoticonPreview } diff --git a/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift b/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift index af8c9bc9f0..058a4c8ac0 100644 --- a/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift +++ b/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift @@ -904,8 +904,19 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode return } var dimAlpha: Float = 0.0 - if case let .file(file) = wallpaper, !file.isPattern { - if let intensity = file.settings.intensity, intensity < 100, theme.overallDarkAppearance == true { + if theme.overallDarkAppearance == true { + var intensity: Int32? + switch wallpaper { + case let .image(_, settings): + intensity = settings.intensity + case let .file(file): + if !file.isPattern { + intensity = file.settings.intensity + } + default: + break + } + if let intensity, intensity < 100 { dimAlpha = 1.0 - max(0.0, min(1.0, Float(intensity) / 100.0)) } }