mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-06-07 18:43:56 +02:00
Update Ghostgram features
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
|
||||
|
||||
swift_library(
|
||||
name = "SGAPIWebSettings",
|
||||
module_name = "SGAPIWebSettings",
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//Swiftgram/SGAPI:SGAPI",
|
||||
"//Swiftgram/SGAPIToken:SGAPIToken",
|
||||
"//Swiftgram/SGLogging:SGLogging",
|
||||
"//Swiftgram/SGSimpleSettings:SGSimpleSettings",
|
||||
"//submodules/AccountContext:AccountContext",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,51 @@
|
||||
import Foundation
|
||||
|
||||
import SGAPIToken
|
||||
import SGAPI
|
||||
import SGLogging
|
||||
|
||||
import AccountContext
|
||||
|
||||
import SGSimpleSettings
|
||||
import TelegramCore
|
||||
|
||||
public func updateSGWebSettingsInteractivelly(context: AccountContext) {
|
||||
let _ = getSGApiToken(context: context).startStandalone(next: { token in
|
||||
let _ = getSGSettings(token: token).startStandalone(next: { webSettings in
|
||||
SGLogger.shared.log("SGAPI", "New SGWebSettings for id \(context.account.peerId.id._internalGetInt64Value()): \(webSettings) ")
|
||||
SGSimpleSettings.shared.canUseStealthMode = webSettings.global.storiesAvailable
|
||||
SGSimpleSettings.shared.duckyAppIconAvailable = webSettings.global.duckyAppIconAvailable
|
||||
SGSimpleSettings.shared.canUseNY = webSettings.global.nyAvailable
|
||||
let _ = (context.account.postbox.transaction { transaction in
|
||||
updateAppConfiguration(transaction: transaction, { configuration -> AppConfiguration in
|
||||
var configuration = configuration
|
||||
configuration.sgWebSettings = webSettings
|
||||
return configuration
|
||||
})
|
||||
}).startStandalone()
|
||||
}, error: { e in
|
||||
if case let .generic(errorMessage) = e, let errorMessage = errorMessage {
|
||||
SGLogger.shared.log("SGAPI", errorMessage)
|
||||
}
|
||||
})
|
||||
}, error: { e in
|
||||
if case let .generic(errorMessage) = e, let errorMessage = errorMessage {
|
||||
SGLogger.shared.log("SGAPI", errorMessage)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
public func postSGWebSettingsInteractivelly(context: AccountContext, data: [String: Any]) {
|
||||
let _ = getSGApiToken(context: context).startStandalone(next: { token in
|
||||
let _ = postSGSettings(token: token, data: data).startStandalone(error: { e in
|
||||
if case let .generic(errorMessage) = e, let errorMessage = errorMessage {
|
||||
SGLogger.shared.log("SGAPI", errorMessage)
|
||||
}
|
||||
})
|
||||
}, error: { e in
|
||||
if case let .generic(errorMessage) = e, let errorMessage = errorMessage {
|
||||
SGLogger.shared.log("SGAPI", errorMessage)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user