diff --git a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift index 7a13b856ff..5f5db9e12f 100644 --- a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift +++ b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift @@ -1832,6 +1832,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { guard let self else { return } + let items = items.filter { $0.count > 0 } var dismissImpl: (() -> Void)? let content: ContextControllerItemsContent = MediaGroupsContextMenuContent( context: self.context, diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryToolbarNode.swift b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryToolbarNode.swift index 8a7da896e2..0c61687451 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryToolbarNode.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryToolbarNode.swift @@ -156,8 +156,9 @@ final class WallpaperGalleryToolbarNode: ASDisplayNode, WallpaperGalleryToolbar } self.doneButtonSolidBackgroundNode.frame = bounds + let constrainedSize = CGSize(width: size.width - 44.0, height: size.height) let iconSize = CGSize(width: 30.0, height: 30.0) - let doneTitleSize = self.doneButtonTitleNode.updateLayout(size) + let doneTitleSize = self.doneButtonTitleNode.updateLayout(constrainedSize) var totalWidth = doneTitleSize.width if self.isLocked { @@ -168,7 +169,7 @@ final class WallpaperGalleryToolbarNode: ASDisplayNode, WallpaperGalleryToolbar self.animationNode.frame = CGRect(origin: CGPoint(x: titleOriginX, y: floorToScreenPixels((bounds.height - iconSize.height) / 2.0)), size: iconSize) self.doneButtonTitleNode.frame = CGRect(origin: CGPoint(x: titleOriginX + totalWidth - doneTitleSize.width, y: floorToScreenPixels((bounds.height - doneTitleSize.height) / 2.0)), size: doneTitleSize).offsetBy(dx: bounds.minX, dy: bounds.minY) - let _ = self.doneButtonSolidTitleNode.updateLayout(size) + let _ = self.doneButtonSolidTitleNode.updateLayout(constrainedSize) self.doneButtonSolidTitleNode.frame = self.doneButtonTitleNode.frame self.doneButton.frame = bounds diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift b/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift index 7c7f38c3b3..6b943dff85 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift @@ -184,12 +184,29 @@ func _internal_revertChatWallpaper(account: Account, peerId: EnginePeer.Id) -> S } let flags: Int32 = 1 << 4 return account.network.request(Api.functions.messages.setChatWallPaper(flags: flags, peer: inputPeer, wallpaper: nil, settings: nil, id: nil), automaticFloodWait: false) - |> `catch` { _ -> Signal in + |> map(Optional.init) + |> `catch` { error -> Signal in + if error.description == "WALLPAPER_NOT_FOUND" { + return .single(nil) + } return .fail(.generic) } |> mapToSignal { updates -> Signal in - account.stateManager.addUpdates(updates) - return .complete() + if let updates = updates { + account.stateManager.addUpdates(updates) + return .complete() + } else { + return account.postbox.transaction { transaction in + transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in + if let current = current as? CachedUserData { + return current.withUpdatedWallpaper(nil) + } else { + return current + } + }) + } + |> castError(RevertChatWallpaperError.self) + } } } } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode/Sources/ChatMessageGiveawayBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode/Sources/ChatMessageGiveawayBubbleContentNode.swift index d65462b819..3222c8b419 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode/Sources/ChatMessageGiveawayBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode/Sources/ChatMessageGiveawayBubbleContentNode.swift @@ -684,7 +684,7 @@ private final class PeerButtonsStackNode: ASDisplayNode { var titleColor = titleColor var backgroundColor = backgroundColor - if incoming, let nameColor = peer.nameColor { + if incoming, let nameColor = peer.nameColor, makeChannelButtonLayouts.count > 1 { titleColor = context.peerNameColors.get(nameColor, dark: dark).main backgroundColor = titleColor.withAlphaComponent(0.1) }