Hide Post Story button

This commit is contained in:
Kylmakalle 2024-07-21 23:42:59 +03:00
parent 22d27b24e9
commit 2ddfd501a5
3 changed files with 22 additions and 33 deletions

View File

@ -6324,6 +6324,14 @@ private final class ChatListLocationContext {
return lhs == rhs
})
// MARK: Swiftgram
let hideStoriesSignal = context.account.postbox.preferencesView(keys: [ApplicationSpecificPreferencesKeys.SGUISettings])
|> map { view -> Bool in
let settings: SGUISettings = view.values[ApplicationSpecificPreferencesKeys.SGUISettings]?.get(SGUISettings.self) ?? .default
return settings.hideStories
}
|> distinctUntilChanged
let passcode = context.sharedContext.accountManager.accessChallengeData()
|> map { view -> (Bool, Bool) in
let data = view.data
@ -6392,6 +6400,7 @@ private final class ChatListLocationContext {
case .chatList:
if !hideNetworkActivityStatus {
self.titleDisposable = combineLatest(queue: .mainQueue(),
hideStoriesSignal,
networkState,
hasProxy,
passcode,
@ -6400,12 +6409,13 @@ private final class ChatListLocationContext {
peerStatus,
parentController.updatedPresentationData.1,
storyPostingAvailable
).startStrict(next: { [weak self] networkState, proxy, passcode, stateAndFilterId, isReorderingTabs, peerStatus, presentationData, storyPostingAvailable in
).startStrict(next: { [weak self] hideStories, networkState, proxy, passcode, stateAndFilterId, isReorderingTabs, peerStatus, presentationData, storyPostingAvailable in
guard let self else {
return
}
self.updateChatList(
hideStories: hideStories,
networkState: networkState,
proxy: proxy,
passcode: passcode,
@ -6624,6 +6634,7 @@ private final class ChatListLocationContext {
}
private func updateChatList(
hideStories: Bool,
networkState: AccountNetworkState,
proxy: (Bool, Bool),
passcode: (Bool, Bool),
@ -6740,7 +6751,7 @@ private final class ChatListLocationContext {
}
}
if storyPostingAvailable {
if storyPostingAvailable && !hideStories {
self.storyButton = AnyComponentWithIdentity(id: "story", component: AnyComponent(NavigationButtonComponent(
content: .icon(imageName: "Chat List/AddStoryIcon"),
pressed: { [weak self] _ in

View File

@ -6,23 +6,10 @@ sgdeps = [
"//Swiftgram/SGSimpleSettings:SGSimpleSettings",
"//Swiftgram/SGRegDate:SGRegDate",
"//Swiftgram/SGRegDateScheme:SGRegDateScheme"
"//Swiftgram/SGRegDateScheme:SGRegDateScheme",
"//Swiftgram/SGDebugUI:SGDebugUI",
]
config_setting(
name = "debug_build",
values = {
"compilation_mode": "dbg",
},
)
flex_dependency = select({
":debug_build": [
"@flex_sdk//:FLEX"
],
"//conditions:default": [],
})
swift_library(
name = "PeerInfoScreen",
@ -33,7 +20,7 @@ swift_library(
copts = [
"-warnings-as-errors",
],
deps = flex_dependency + sgdeps + [
deps = sgdeps + [
"//submodules/AccountContext",
"//submodules/AccountUtils",
"//submodules/ActionSheetPeerItem",

View File

@ -1,7 +1,5 @@
// MARK: Swiftgram
#if DEBUG
import FLEX
#endif
import SGDebugUI
import SGSimpleSettings
import SGSettingsUI
import SGStrings
@ -13186,19 +13184,10 @@ public final class PeerInfoScreenImpl: ViewController, PeerInfoScreen, KeyShortc
items.append(.action(ContextMenuActionItem(text: "Swiftgram Debug", icon: { theme in
return generateTintedImage(image: nil, color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, f in
guard let _ = self else {
guard let self = self else {
return
}
#if DEBUG
FLEXManager.shared.showExplorer()
#endif
// SGSimpleSettings.shared.hideReactions = !SGSimpleSettings.shared.hideReactions
// let _ = updateSGUISettings(engine: strongSelf.context.engine, { settings in
// var settings = settings
// settings.sendWithReturnKey = !settings.sendWithReturnKey
// print("New setting value \(settings.sendWithReturnKey)")
// return settings
// }).startStandalone()
self.push(sgDebugController(context: self.context))
f(.dismissWithoutContent)
})))
@ -14362,9 +14351,11 @@ extension PeerInfoScreenImpl {
items.append(.action(ContextMenuActionItem(text: "Swiftgram Debug", icon: { theme in
return generateTintedImage(image: nil, color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, f in
guard let _ = self else {
guard let self = self else {
return
}
self.push(sgDebugController(context: self.context))
f(.dismissWithoutContent)
})))
#endif