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 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() let passcode = context.sharedContext.accountManager.accessChallengeData()
|> map { view -> (Bool, Bool) in |> map { view -> (Bool, Bool) in
let data = view.data let data = view.data
@ -6392,6 +6400,7 @@ private final class ChatListLocationContext {
case .chatList: case .chatList:
if !hideNetworkActivityStatus { if !hideNetworkActivityStatus {
self.titleDisposable = combineLatest(queue: .mainQueue(), self.titleDisposable = combineLatest(queue: .mainQueue(),
hideStoriesSignal,
networkState, networkState,
hasProxy, hasProxy,
passcode, passcode,
@ -6400,12 +6409,13 @@ private final class ChatListLocationContext {
peerStatus, peerStatus,
parentController.updatedPresentationData.1, parentController.updatedPresentationData.1,
storyPostingAvailable 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 { guard let self else {
return return
} }
self.updateChatList( self.updateChatList(
hideStories: hideStories,
networkState: networkState, networkState: networkState,
proxy: proxy, proxy: proxy,
passcode: passcode, passcode: passcode,
@ -6624,6 +6634,7 @@ private final class ChatListLocationContext {
} }
private func updateChatList( private func updateChatList(
hideStories: Bool,
networkState: AccountNetworkState, networkState: AccountNetworkState,
proxy: (Bool, Bool), proxy: (Bool, Bool),
passcode: (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( 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

View File

@ -6,23 +6,10 @@ sgdeps = [
"//Swiftgram/SGSimpleSettings:SGSimpleSettings", "//Swiftgram/SGSimpleSettings:SGSimpleSettings",
"//Swiftgram/SGRegDate:SGRegDate", "//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( swift_library(
name = "PeerInfoScreen", name = "PeerInfoScreen",
@ -33,7 +20,7 @@ swift_library(
copts = [ copts = [
"-warnings-as-errors", "-warnings-as-errors",
], ],
deps = flex_dependency + sgdeps + [ deps = sgdeps + [
"//submodules/AccountContext", "//submodules/AccountContext",
"//submodules/AccountUtils", "//submodules/AccountUtils",
"//submodules/ActionSheetPeerItem", "//submodules/ActionSheetPeerItem",

View File

@ -1,7 +1,5 @@
// MARK: Swiftgram // MARK: Swiftgram
#if DEBUG import SGDebugUI
import FLEX
#endif
import SGSimpleSettings import SGSimpleSettings
import SGSettingsUI import SGSettingsUI
import SGStrings import SGStrings
@ -13186,19 +13184,10 @@ public final class PeerInfoScreenImpl: ViewController, PeerInfoScreen, KeyShortc
items.append(.action(ContextMenuActionItem(text: "Swiftgram Debug", icon: { theme in items.append(.action(ContextMenuActionItem(text: "Swiftgram Debug", icon: { theme in
return generateTintedImage(image: nil, color: theme.contextMenu.primaryColor) return generateTintedImage(image: nil, color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, f in }, action: { [weak self] _, f in
guard let _ = self else { guard let self = self else {
return return
} }
#if DEBUG self.push(sgDebugController(context: self.context))
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()
f(.dismissWithoutContent) f(.dismissWithoutContent)
}))) })))
@ -14362,9 +14351,11 @@ extension PeerInfoScreenImpl {
items.append(.action(ContextMenuActionItem(text: "Swiftgram Debug", icon: { theme in items.append(.action(ContextMenuActionItem(text: "Swiftgram Debug", icon: { theme in
return generateTintedImage(image: nil, color: theme.contextMenu.primaryColor) return generateTintedImage(image: nil, color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, f in }, action: { [weak self] _, f in
guard let _ = self else { guard let self = self else {
return return
} }
self.push(sgDebugController(context: self.context))
f(.dismissWithoutContent) f(.dismissWithoutContent)
}))) })))
#endif #endif