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