Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
overtake committed Jul 3, 2024
2 parents b4ae933 + 3a1ce35 commit 539b85f
Show file tree
Hide file tree
Showing 498 changed files with 26,386 additions and 6,699 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ [email protected]:overtake/tgcalls.git
url = [email protected]:desktop-app/tg_owt.git
[submodule "submodules/libprisma"]
path = submodules/libprisma
url = [email protected]:TelegramMessenger/libprisma.git
url=[email protected]:desktop-app/libprisma.git
[submodule "submodules/regex"]
path = submodules/regex
url = [email protected]:boostorg/regex.git
13 changes: 13 additions & 0 deletions FocusIntents/FocusIntents.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>6N38VWS5BX.ru.keepcoder.Telegram.FocusIntents</string>
<string>6N38VWS5BX.ru.keepcoder.Telegram</string>
</array>
</dict>
</plist>
69 changes: 69 additions & 0 deletions FocusIntents/FocusIntents.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//
// FocusIntents.swift
// FocusIntents
//
// Created by Mikhail Filimonov on 25.04.2024.
// Copyright © 2024 Telegram. All rights reserved.
//

import AppIntents
import OSLog
import TelegramCore
import Postbox
import SwiftSignalKit
import InAppSettings
import ApiCredentials


@available(macOS 13, *)
struct FocusFilter: SetFocusFilterIntent {

@Parameter(title: "Use Dark Mode", description: "Automatically enable dark mode.", default: false)
var alwaysUseDarkMode: Bool

@Parameter(title: "Set Unable Status", description: "Set your account status to Unable. This feature requires Telegram Premium.", default: false)
var unableStatus: Bool


static var title: LocalizedStringResource = "Set Appearance And Status"

static var description: LocalizedStringResource? = """
Configure Appearance of app in focus mode
"""

var displayRepresentation: DisplayRepresentation {
var status: String = ""
if alwaysUseDarkMode {
status += "Dark Mode"
}
if unableStatus {
if status.isEmpty {
status += "Status"
} else {
status += ", Status"
}
}
return DisplayRepresentation(title: "Appearance And Status",
subtitle: LocalizedStringResource(stringLiteral: status))
}


var appContext: FocusFilterAppContext {
return FocusFilterAppContext(notificationFilterPredicate: nil)
}

static func suggestedFocusFilters(for context: FocusFilterSuggestionContext) async -> [FocusFilter] {
let workFilter = FocusFilter()
workFilter.alwaysUseDarkMode = true
workFilter.unableStatus = true
return [workFilter]
}

func perform() async throws -> some IntentResult {
let model = AppIntentDataModel(alwaysUseDarkMode: self.alwaysUseDarkMode, useUnableStatus: self.unableStatus)
if let model = model.encoded() {
UserDefaults(suiteName: ApiEnvironment.intentsBundleId)?.set(model, forKey: AppIntentDataModel.key)
}
return .result()
}
}
18 changes: 18 additions & 0 deletions FocusIntents/FocusIntentsExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// FocusIntentsExtension.swift
// FocusIntents
//
// Created by Mikhail Filimonov on 25.04.2024.
// Copyright © 2024 Telegram. All rights reserved.
//

import AppIntents
import OSLog


@main
struct FocusIntentsExtension: AppIntentsExtension {
init() {
AppDependencyManager.shared.add(dependency: AppIntentsData.shared)
}
}
13 changes: 13 additions & 0 deletions FocusIntents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EXAppExtensionAttributes</key>
<dict>
<key>EXExtensionPointIdentifier</key>
<string>com.apple.appintents-extension</string>
</dict>
<key>SOURCE</key>
<string>${SOURCE}</string>
</dict>
</plist>
60 changes: 57 additions & 3 deletions Telegram-Mac/AccountContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ import InAppPurchaseManager
import ApiCredentials

let clown: String = "🤡"
let focusIntentEmoji = "⛔️"



func bestWindow(_ accountContext: AccountContext, _ controller: ViewController?) -> Window {
return controller?.window ?? accountContext.window
}

public struct PremiumConfiguration {
public static var defaultValue: PremiumConfiguration {
return PremiumConfiguration(
Expand Down Expand Up @@ -169,6 +174,13 @@ extension AppConfiguration {
return defaultValue
}
}
func getStringValue(_ key: String, orElse defaultValue: String) -> String {
if let value = self.data?[key] as? String {
return value
} else {
return defaultValue
}
}
func getBoolValue(_ key: String, orElse defaultValue: Bool) -> Bool {
if let value = self.data?[key] as? Bool {
return value
Expand Down Expand Up @@ -325,12 +337,12 @@ final class AccountContextBindings {
let rootNavigation: () -> MajorNavigationController
let mainController: () -> MainViewController
let showControllerToaster: (ControllerToaster, Bool) -> Void
let globalSearch:(String)->Void
let globalSearch:(String, PeerId?)->Void
let switchSplitLayout:(SplitViewState)->Void
let entertainment:()->EntertainmentViewController
let needFullsize:()->Void
let displayUpgradeProgress:(CGFloat)->Void
init(rootNavigation: @escaping() -> MajorNavigationController = { fatalError() }, mainController: @escaping() -> MainViewController = { fatalError() }, showControllerToaster: @escaping(ControllerToaster, Bool) -> Void = { _, _ in fatalError() }, globalSearch: @escaping(String) -> Void = { _ in fatalError() }, entertainment: @escaping()->EntertainmentViewController = { fatalError() }, switchSplitLayout: @escaping(SplitViewState)->Void = { _ in fatalError() }, needFullsize: @escaping() -> Void = { fatalError() }, displayUpgradeProgress: @escaping(CGFloat)->Void = { _ in fatalError() }) {
init(rootNavigation: @escaping() -> MajorNavigationController = { fatalError() }, mainController: @escaping() -> MainViewController = { fatalError() }, showControllerToaster: @escaping(ControllerToaster, Bool) -> Void = { _, _ in fatalError() }, globalSearch: @escaping(String, PeerId?) -> Void = { _, _ in fatalError() }, entertainment: @escaping()->EntertainmentViewController = { fatalError() }, switchSplitLayout: @escaping(SplitViewState)->Void = { _ in fatalError() }, needFullsize: @escaping() -> Void = { fatalError() }, displayUpgradeProgress: @escaping(CGFloat)->Void = { _ in fatalError() }) {
self.rootNavigation = rootNavigation
self.mainController = mainController
self.showControllerToaster = showControllerToaster
Expand Down Expand Up @@ -362,6 +374,7 @@ final class AccountContext {
let cachedGroupCallContexts: AccountGroupCallContextCacheImpl
let networkStatusManager: NetworkStatusManager
let inAppPurchaseManager: InAppPurchaseManager
let starsContext: StarsContext

#endif
private(set) var timeDifference:TimeInterval = 0
Expand Down Expand Up @@ -597,7 +610,8 @@ final class AccountContext {
self.networkStatusManager = NetworkStatusManager(account: account, window: window, sharedContext: sharedContext)
self.reactions = Reactions(engine)
self.dockControl = DockControl(engine, accountManager: sharedContext.accountManager)
#endif
self.starsContext = engine.payments.peerStarsContext()
#endif


giftStickersValues.set(engine.stickers.loadedStickerPack(reference: .premiumGifts, forceActualized: false)
Expand Down Expand Up @@ -916,6 +930,46 @@ final class AccountContext {

actionsDisposable.add(requestApplicationIcons(engine: engine).start())

// let focusIntentStatus = someAccountSetings(postbox: account.postbox)
// |> distinctUntilChanged(isEqual: {
// $0.focusIntentStatusEnabled == $1.focusIntentStatusEnabled &&
// $0.focusIntentStatusActive == $1.focusIntentStatusActive
// })
// |> deliverOnMainQueue
//
// actionsDisposable.add(focusIntentStatus.startStandalone(next: { [weak self] settings in
// guard let self else {
// return
// }
// let setStatus:(Int64?)->Void = { [weak self] fileId in
// guard let self else {
// return
// }
// if let fileId {
// let file = self.inlinePacksContext.load(fileId: fileId) |> deliverOnMainQueue
// _ = file.startStandalone(next: { file in
// _ = engine.accountData.setEmojiStatus(file: file, expirationDate: nil).start()
// })
// } else {
// _ = engine.accountData.setEmojiStatus(file: nil, expirationDate: nil).start()
// }
// }
// if settings.focusIntentStatusEnabled {
// if let fileId = settings.focusIntentStatusActive {
// setStatus(fileId)
// } else {
// _ = (self.diceCache.top_emojies_status |> deliverOnMainQueue).startStandalone(next: { files in
// if let file = files.first(where: { $0.customEmojiText == focusIntentEmoji }) {
// setStatus(file.fileId.id)
// }
// })
// }
// } else if let fileId = settings.focusIntentStatusFallback {
// setStatus(fileId)
// } else {
// setStatus(nil)
// }
// }))

#endif

Expand Down
Loading

0 comments on commit 539b85f

Please sign in to comment.