diff --git a/submodules/ChatListUI/Sources/ChatListControllerNode.swift b/submodules/ChatListUI/Sources/ChatListControllerNode.swift index 6fa08b2bc6..d828653729 100644 --- a/submodules/ChatListUI/Sources/ChatListControllerNode.swift +++ b/submodules/ChatListUI/Sources/ChatListControllerNode.swift @@ -1295,39 +1295,38 @@ public final class ChatListContainerNode: ASDisplayNode, UIGestureRecognizerDele let hasStoryCameraTransition = self.controller?.hasStoryCameraTransition ?? false if hasStoryCameraTransition { self.controller?.storyCameraPanGestureEnded(transitionFraction: translation.x / layout.size.width, velocity: velocity.x) - } else { - var applyNodeAsCurrent: ChatListFilterTabEntryId? - - if let directionIsToRight = directionIsToRight { - var updatedIndex = selectedIndex - if directionIsToRight { - updatedIndex = min(updatedIndex + 1, maxFilterIndex) - } else { - updatedIndex = max(updatedIndex - 1, 0) - } - let switchToId = self.availableFilters[updatedIndex].id - if switchToId != self.selectedId, let itemNode = self.itemNodes[switchToId] { - let _ = itemNode - self.selectedId = switchToId - applyNodeAsCurrent = switchToId - } - } - self.transitionFraction = 0.0 - let transition: ContainedViewLayoutTransition = .animated(duration: 0.45, curve: .spring) - self.disableItemNodeOperationsWhileAnimating = true - self.update(layout: layout, navigationBarHeight: navigationBarHeight, visualNavigationHeight: visualNavigationHeight, originalNavigationHeight: originalNavigationHeight, cleanNavigationBarHeight: cleanNavigationBarHeight, insets: insets, isReorderingFilters: isReorderingFilters, isEditing: isEditing, inlineNavigationLocation: inlineNavigationLocation, inlineNavigationTransitionFraction: inlineNavigationTransitionFraction, storiesInset: storiesInset, transition: transition) - DispatchQueue.main.async { - self.disableItemNodeOperationsWhileAnimating = false - if let (layout, navigationBarHeight, visualNavigationHeight, originalNavigationHeight, cleanNavigationBarHeight, insets, isReorderingFilters, isEditing, inlineNavigationLocation, inlineNavigationTransitionFraction, storiesInset) = self.validLayout { - self.update(layout: layout, navigationBarHeight: navigationBarHeight, visualNavigationHeight: visualNavigationHeight, originalNavigationHeight: originalNavigationHeight, cleanNavigationBarHeight: cleanNavigationBarHeight, insets: insets, isReorderingFilters: isReorderingFilters, isEditing: isEditing, inlineNavigationLocation: inlineNavigationLocation, inlineNavigationTransitionFraction: inlineNavigationTransitionFraction, storiesInset: storiesInset, transition: .immediate) - } - } - - if let switchToId = applyNodeAsCurrent, let itemNode = self.itemNodes[switchToId] { - self.applyItemNodeAsCurrent(id: switchToId, itemNode: itemNode) - } - self.currentItemFilterUpdated?(self.currentItemFilter, self.transitionFraction, transition, false) } + var applyNodeAsCurrent: ChatListFilterTabEntryId? + + if let directionIsToRight = directionIsToRight { + var updatedIndex = selectedIndex + if directionIsToRight { + updatedIndex = min(updatedIndex + 1, maxFilterIndex) + } else { + updatedIndex = max(updatedIndex - 1, 0) + } + let switchToId = self.availableFilters[updatedIndex].id + if switchToId != self.selectedId, let itemNode = self.itemNodes[switchToId] { + let _ = itemNode + self.selectedId = switchToId + applyNodeAsCurrent = switchToId + } + } + self.transitionFraction = 0.0 + let transition: ContainedViewLayoutTransition = .animated(duration: 0.45, curve: .spring) + self.disableItemNodeOperationsWhileAnimating = true + self.update(layout: layout, navigationBarHeight: navigationBarHeight, visualNavigationHeight: visualNavigationHeight, originalNavigationHeight: originalNavigationHeight, cleanNavigationBarHeight: cleanNavigationBarHeight, insets: insets, isReorderingFilters: isReorderingFilters, isEditing: isEditing, inlineNavigationLocation: inlineNavigationLocation, inlineNavigationTransitionFraction: inlineNavigationTransitionFraction, storiesInset: storiesInset, transition: transition) + DispatchQueue.main.async { + self.disableItemNodeOperationsWhileAnimating = false + if let (layout, navigationBarHeight, visualNavigationHeight, originalNavigationHeight, cleanNavigationBarHeight, insets, isReorderingFilters, isEditing, inlineNavigationLocation, inlineNavigationTransitionFraction, storiesInset) = self.validLayout { + self.update(layout: layout, navigationBarHeight: navigationBarHeight, visualNavigationHeight: visualNavigationHeight, originalNavigationHeight: originalNavigationHeight, cleanNavigationBarHeight: cleanNavigationBarHeight, insets: insets, isReorderingFilters: isReorderingFilters, isEditing: isEditing, inlineNavigationLocation: inlineNavigationLocation, inlineNavigationTransitionFraction: inlineNavigationTransitionFraction, storiesInset: storiesInset, transition: .immediate) + } + } + + if let switchToId = applyNodeAsCurrent, let itemNode = self.itemNodes[switchToId] { + self.applyItemNodeAsCurrent(id: switchToId, itemNode: itemNode) + } + self.currentItemFilterUpdated?(self.currentItemFilter, self.transitionFraction, transition, false) } default: break diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index f3fc446d39..6f6ac0c4c2 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -2577,6 +2577,36 @@ public final class StoryItemSetContainerComponent: Component { return contentSize } + private func presentPrivacyTooltip(privacy: EngineStoryPrivacy) { + guard let component = self.component else { + return + } + + let text: String + if privacy.base == .contacts { + text = "This story is shown to all your contacts." + } else if privacy.base == .closeFriends { + text = "This story is shown to your close friends." + } else if privacy.base == .nobody { + if !privacy.additionallyIncludePeers.isEmpty { + text = "This story is shown to selected contacts." + } else { + text = "This story is shown only to you." + } + } else { + text = "This story is shown to everyone." + } + + let presentationData = component.context.sharedContext.currentPresentationData.with { $0 } + self.component?.presentController(UndoOverlayController( + presentationData: presentationData, + content: .info(title: nil, text: text, timeout: nil), + elevatedLayout: false, + animateInAsReplacement: false, + action: { _ in return false } + ), nil) + } + private func openItemPrivacySettings(initialPrivacy: EngineStoryPrivacy? = nil) { guard let context = self.component?.context else { return @@ -2602,6 +2632,8 @@ public final class StoryItemSetContainerComponent: Component { } let _ = component.context.engine.messages.editStoryPrivacy(id: component.slice.item.storyItem.id, privacy: privacy).start() + self.presentPrivacyTooltip(privacy: privacy) + self.privacyController = nil self.updateIsProgressPaused() }, @@ -2939,6 +2971,8 @@ public final class StoryItemSetContainerComponent: Component { component.controller()?.forEachController { c in if let c = c as? UndoOverlayController { c.dismiss() + } else if let c = c as? TooltipScreen { + c.dismiss() } return true } diff --git a/submodules/TelegramUI/Sources/TelegramRootController.swift b/submodules/TelegramUI/Sources/TelegramRootController.swift index ef9fcd5d0a..b5d2010422 100644 --- a/submodules/TelegramUI/Sources/TelegramRootController.swift +++ b/submodules/TelegramUI/Sources/TelegramRootController.swift @@ -361,6 +361,12 @@ public final class TelegramRootController: NavigationController, TelegramRootCon return } + if let rootTabController = self.rootTabController { + if let index = rootTabController.controllers.firstIndex(where: { $0 is ChatListController}) { + rootTabController.selectedIndex = index + } + } + if let chatListController = self.chatListController as? ChatListControllerImpl { chatListController.scrollToStories() switch mediaResult {