forked from TelegramMessenger/Telegram-iOS
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
392 changed files
with
19,254 additions
and
7,542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,42 @@ | ||
import AccountContext | ||
import FeatPremium | ||
import NGCore | ||
import NGStrings | ||
import TelegramUIPreferences | ||
|
||
public struct NGStealthMode { | ||
private static var stealthModeSubscription: Any? | ||
} | ||
public struct NGStealthMode {} | ||
|
||
public extension NGStealthMode { | ||
static func initialize( | ||
sharedContext: SharedAccountContext | ||
) { | ||
guard #available(iOS 13.0, *) else { | ||
return | ||
} | ||
|
||
let getPremiumStatusUseCase = PremiumContainer.shared.getPremiumStatusUseCase() | ||
|
||
stealthModeSubscription = $stealthModeEnabled | ||
.combineLatest(getPremiumStatusUseCase.hasPremiumOnDevicePublisher()) | ||
.map { stealthModeEnabled, hasPremium in | ||
stealthModeEnabled && hasPremium | ||
} | ||
.sink { [weak sharedContext] useStealthMode in | ||
guard let sharedContext else { | ||
return | ||
} | ||
|
||
let _ = updateExperimentalUISettingsInteractively(accountManager: sharedContext.accountManager, { settings in | ||
var settings = settings | ||
settings.skipReadHistory = useStealthMode | ||
return settings | ||
}).start() | ||
} | ||
} | ||
|
||
static func isStealthModeEnabled() -> Bool { | ||
if #available(iOS 13.0, *) { | ||
stealthModeEnabled | ||
} else { | ||
false | ||
} | ||
} | ||
|
||
static func setStealthModeEnabled(_ enabled: Bool) { | ||
if #available(iOS 13.0, *) { | ||
stealthModeEnabled = enabled | ||
maybeDisableStealthMode( | ||
sharedContext: sharedContext | ||
) | ||
} | ||
} | ||
} | ||
|
||
public extension NGStealthMode { | ||
struct Resources {} | ||
} | ||
public extension NGStealthMode.Resources { | ||
static func toggleTitle() -> String { | ||
l("StealthMode.Toggle") | ||
} | ||
} | ||
|
||
@available(iOS 13.0, *) | ||
private extension NGStealthMode { | ||
@UserDefaultsValue( | ||
key: "stealthModeEnabled", | ||
key: "ngStealthModeWasDisabled", | ||
defaultValue: false | ||
) | ||
static var stealthModeEnabled: Bool | ||
static var stealthModeWasDisabled | ||
|
||
static func maybeDisableStealthMode( | ||
sharedContext: SharedAccountContext | ||
) { | ||
guard !stealthModeWasDisabled else { | ||
return | ||
} | ||
|
||
let _ = updateExperimentalUISettingsInteractively(accountManager: sharedContext.accountManager, { settings in | ||
var settings = settings | ||
settings.skipReadHistory = false | ||
return settings | ||
}).start() | ||
|
||
stealthModeWasDisabled = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") | ||
|
||
swift_library( | ||
name = "NGWrap", | ||
module_name = "NGWrap", | ||
srcs = glob([ | ||
"Sources/**/*.swift", | ||
]), | ||
deps = [ | ||
|
||
], | ||
visibility = [ | ||
"//visibility:public", | ||
], | ||
) |
Oops, something went wrong.