mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 03:09:56 +00:00
Fixes
This commit is contained in:
parent
86548eb214
commit
0c091f6c1b
@ -1093,9 +1093,9 @@ public struct StoriesConfiguration {
|
||||
}
|
||||
|
||||
public static func with(appConfiguration: AppConfiguration) -> StoriesConfiguration {
|
||||
#if DEBUG
|
||||
return StoriesConfiguration(posting: .premium)
|
||||
#else
|
||||
//#if DEBUG
|
||||
// return StoriesConfiguration(posting: .premium)
|
||||
//#else
|
||||
if let data = appConfiguration.data, let postingString = data["stories_posting"] as? String {
|
||||
let posting: PostingAvailability
|
||||
switch postingString {
|
||||
@ -1110,6 +1110,6 @@ public struct StoriesConfiguration {
|
||||
} else {
|
||||
return .defaultValue
|
||||
}
|
||||
#endif
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,6 +161,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
private(set) var isPremium: Bool = false
|
||||
private(set) var storyPostingAvailability: StoriesConfiguration.PostingAvailability = .disabled
|
||||
private var storiesPostingAvailabilityDisposable: Disposable?
|
||||
private let storyPostingAvailabilityValue = ValuePromise<StoriesConfiguration.PostingAvailability>(.disabled)
|
||||
|
||||
private var didSetupTabs = false
|
||||
|
||||
@ -247,7 +248,15 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
parentController: self,
|
||||
hideNetworkActivityStatus: self.hideNetworkActivityStatus,
|
||||
containerNode: self.chatListDisplayNode.mainContainerNode,
|
||||
isReorderingTabs: self.isReorderingTabsValue.get()
|
||||
isReorderingTabs: self.isReorderingTabsValue.get(),
|
||||
storyPostingAvailable: self.storyPostingAvailabilityValue.get() |> map { availability -> Bool in
|
||||
switch availability {
|
||||
case .enabled, .premium:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
)
|
||||
self.primaryContext = primaryContext
|
||||
self.primaryInfoReady.set(primaryContext.ready.get())
|
||||
@ -713,6 +722,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
).start(next: { [weak self] postingAvailability in
|
||||
if let self {
|
||||
self.storyPostingAvailability = postingAvailability
|
||||
self.storyPostingAvailabilityValue.set(postingAvailability)
|
||||
}
|
||||
})
|
||||
|
||||
@ -2792,7 +2802,8 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
parentController: self,
|
||||
hideNetworkActivityStatus: false,
|
||||
containerNode: inlineNode,
|
||||
isReorderingTabs: .single(false)
|
||||
isReorderingTabs: .single(false),
|
||||
storyPostingAvailable: .single(false)
|
||||
)
|
||||
self.pendingSecondaryContext = pendingSecondaryContext
|
||||
let _ = (pendingSecondaryContext.ready.get()
|
||||
@ -5069,7 +5080,8 @@ private final class ChatListLocationContext {
|
||||
parentController: ChatListControllerImpl,
|
||||
hideNetworkActivityStatus: Bool,
|
||||
containerNode: ChatListContainerNode,
|
||||
isReorderingTabs: Signal<Bool, NoError>
|
||||
isReorderingTabs: Signal<Bool, NoError>,
|
||||
storyPostingAvailable: Signal<Bool, NoError>
|
||||
) {
|
||||
self.context = context
|
||||
self.location = location
|
||||
@ -5124,8 +5136,9 @@ private final class ChatListLocationContext {
|
||||
containerNode.currentItemState,
|
||||
isReorderingTabs,
|
||||
peerStatus,
|
||||
parentController.updatedPresentationData.1
|
||||
).start(next: { [weak self] networkState, proxy, passcode, stateAndFilterId, isReorderingTabs, peerStatus, presentationData in
|
||||
parentController.updatedPresentationData.1,
|
||||
storyPostingAvailable
|
||||
).start(next: { [weak self] networkState, proxy, passcode, stateAndFilterId, isReorderingTabs, peerStatus, presentationData, storyPostingAvailable in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
@ -5136,7 +5149,8 @@ private final class ChatListLocationContext {
|
||||
stateAndFilterId: stateAndFilterId,
|
||||
isReorderingTabs: isReorderingTabs,
|
||||
peerStatus: peerStatus,
|
||||
presentationData: presentationData
|
||||
presentationData: presentationData,
|
||||
storyPostingAvailable: storyPostingAvailable
|
||||
)
|
||||
})
|
||||
} else {
|
||||
@ -5346,7 +5360,8 @@ private final class ChatListLocationContext {
|
||||
stateAndFilterId: (state: ChatListNodeState, filterId: Int32?),
|
||||
isReorderingTabs: Bool,
|
||||
peerStatus: NetworkStatusTitle.Status?,
|
||||
presentationData: PresentationData
|
||||
presentationData: PresentationData,
|
||||
storyPostingAvailable: Bool
|
||||
) {
|
||||
let defaultTitle: String
|
||||
switch location {
|
||||
@ -5453,15 +5468,19 @@ private final class ChatListLocationContext {
|
||||
}
|
||||
}
|
||||
|
||||
self.storyButton = AnyComponentWithIdentity(id: "story", component: AnyComponent(NavigationButtonComponent(
|
||||
content: .icon(imageName: "Chat List/AddStoryIcon"),
|
||||
pressed: { [weak self] _ in
|
||||
guard let self, let parentController = self.parentController else {
|
||||
return
|
||||
if storyPostingAvailable {
|
||||
self.storyButton = AnyComponentWithIdentity(id: "story", component: AnyComponent(NavigationButtonComponent(
|
||||
content: .icon(imageName: "Chat List/AddStoryIcon"),
|
||||
pressed: { [weak self] _ in
|
||||
guard let self, let parentController = self.parentController else {
|
||||
return
|
||||
}
|
||||
parentController.openStoryCamera()
|
||||
}
|
||||
parentController.openStoryCamera()
|
||||
}
|
||||
)))
|
||||
)))
|
||||
} else {
|
||||
self.storyButton = nil
|
||||
}
|
||||
} else {
|
||||
self.rightButton = AnyComponentWithIdentity(id: "edit", component: AnyComponent(NavigationButtonComponent(
|
||||
content: .text(title: presentationData.strings.Common_Edit, isBold: false),
|
||||
|
||||
@ -68,8 +68,8 @@ final class ContactsControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
||||
private var presentationDataDisposable: Disposable?
|
||||
private let stringsPromise = Promise<PresentationStrings>()
|
||||
|
||||
private var isPremium = false
|
||||
private var isPremiumDisposable: Disposable?
|
||||
private var isStoryPostingAvailable = false
|
||||
private var storiesPostingAvailabilityDisposable: Disposable?
|
||||
|
||||
weak var controller: ContactsController?
|
||||
|
||||
@ -262,13 +262,40 @@ final class ContactsControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
||||
self.storiesReady.set(.single(true))
|
||||
})
|
||||
|
||||
self.isPremiumDisposable = (self.context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: self.context.account.peerId))
|
||||
|> map {
|
||||
return $0?.isPremium ?? false
|
||||
let storiesPostingAvailability = self.context.account.postbox.preferencesView(keys: [PreferencesKeys.appConfiguration])
|
||||
|> map { view -> AppConfiguration in
|
||||
let appConfiguration: AppConfiguration = view.values[PreferencesKeys.appConfiguration]?.get(AppConfiguration.self) ?? AppConfiguration.defaultValue
|
||||
return appConfiguration
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { [weak self] isPremium in
|
||||
|> distinctUntilChanged
|
||||
|> map { appConfiguration -> StoriesConfiguration.PostingAvailability in
|
||||
let storiesConfiguration = StoriesConfiguration.with(appConfiguration: appConfiguration)
|
||||
return storiesConfiguration.posting
|
||||
}
|
||||
|
||||
self.storiesPostingAvailabilityDisposable = combineLatest(queue: Queue.mainQueue(),
|
||||
storiesPostingAvailability,
|
||||
self.context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: self.context.account.peerId))
|
||||
|> map { peer -> Bool in
|
||||
if case let .user(user) = peer, user.isPremium {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|> distinctUntilChanged
|
||||
).start(next: { [weak self] postingAvailability, isPremium in
|
||||
if let self {
|
||||
self.isPremium = isPremium
|
||||
let isStoryPostingAvailable: Bool
|
||||
switch postingAvailability {
|
||||
case .enabled:
|
||||
isStoryPostingAvailable = true
|
||||
case .premium:
|
||||
isStoryPostingAvailable = isPremium
|
||||
case .disabled:
|
||||
isStoryPostingAvailable = false
|
||||
}
|
||||
self.isStoryPostingAvailable = isStoryPostingAvailable
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -276,7 +303,7 @@ final class ContactsControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
||||
deinit {
|
||||
self.presentationDataDisposable?.dispose()
|
||||
self.storySubscriptionsDisposable?.dispose()
|
||||
self.isPremiumDisposable?.dispose()
|
||||
self.storiesPostingAvailabilityDisposable?.dispose()
|
||||
}
|
||||
|
||||
override func didLoad() {
|
||||
@ -308,7 +335,7 @@ final class ContactsControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
||||
}
|
||||
|
||||
override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||
return self.isPremium
|
||||
return self.isStoryPostingAvailable
|
||||
}
|
||||
|
||||
private func updateThemeAndStrings() {
|
||||
|
||||
@ -1248,7 +1248,7 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
return
|
||||
}
|
||||
|
||||
let _ = component.context.engine.peers.updatePeerStoriesHidden(id: component.slice.peer.id, isHidden: true)
|
||||
let _ = component.context.engine.peers.updatePeerStoriesHidden(id: component.slice.peer.id, isHidden: !isHidden)
|
||||
})))
|
||||
|
||||
items.append(.action(ContextMenuActionItem(text: "Report", icon: { theme in
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user