Skip to content

Commit 539b85f

Browse files
committed
Merge branch 'beta'
2 parents b4ae933 + 3a1ce35 commit 539b85f

File tree

498 files changed

+26386
-6699
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

498 files changed

+26386
-6699
lines changed

‎.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ url=git@github.com:overtake/tgcalls.git
1818
url = git@github.com:desktop-app/tg_owt.git
1919
[submodule "submodules/libprisma"]
2020
path = submodules/libprisma
21-
url = git@github.com:TelegramMessenger/libprisma.git
21+
url=git@github.com:desktop-app/libprisma.git
2222
[submodule "submodules/regex"]
2323
path = submodules/regex
2424
url = git@github.com:boostorg/regex.git
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.app-sandbox</key>
6+
<true/>
7+
<key>com.apple.security.application-groups</key>
8+
<array>
9+
<string>6N38VWS5BX.ru.keepcoder.Telegram.FocusIntents</string>
10+
<string>6N38VWS5BX.ru.keepcoder.Telegram</string>
11+
</array>
12+
</dict>
13+
</plist>

‎FocusIntents/FocusIntents.swift

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
//
2+
// FocusIntents.swift
3+
// FocusIntents
4+
//
5+
// Created by Mikhail Filimonov on 25.04.2024.
6+
// Copyright © 2024 Telegram. All rights reserved.
7+
//
8+
9+
import AppIntents
10+
import OSLog
11+
import TelegramCore
12+
import Postbox
13+
import SwiftSignalKit
14+
import InAppSettings
15+
import ApiCredentials
16+
17+
18+
@available(macOS 13, *)
19+
struct FocusFilter: SetFocusFilterIntent {
20+
21+
@Parameter(title: "Use Dark Mode", description: "Automatically enable dark mode.", default: false)
22+
var alwaysUseDarkMode: Bool
23+
24+
@Parameter(title: "Set Unable Status", description: "Set your account status to Unable. This feature requires Telegram Premium.", default: false)
25+
var unableStatus: Bool
26+
27+
28+
static var title: LocalizedStringResource = "Set Appearance And Status"
29+
30+
static var description: LocalizedStringResource? = """
31+
Configure Appearance of app in focus mode
32+
"""
33+
34+
var displayRepresentation: DisplayRepresentation {
35+
var status: String = ""
36+
if alwaysUseDarkMode {
37+
status += "Dark Mode"
38+
}
39+
if unableStatus {
40+
if status.isEmpty {
41+
status += "Status"
42+
} else {
43+
status += ", Status"
44+
}
45+
}
46+
return DisplayRepresentation(title: "Appearance And Status",
47+
subtitle: LocalizedStringResource(stringLiteral: status))
48+
}
49+
50+
51+
var appContext: FocusFilterAppContext {
52+
return FocusFilterAppContext(notificationFilterPredicate: nil)
53+
}
54+
55+
static func suggestedFocusFilters(for context: FocusFilterSuggestionContext) async -> [FocusFilter] {
56+
let workFilter = FocusFilter()
57+
workFilter.alwaysUseDarkMode = true
58+
workFilter.unableStatus = true
59+
return [workFilter]
60+
}
61+
62+
func perform() async throws -> some IntentResult {
63+
let model = AppIntentDataModel(alwaysUseDarkMode: self.alwaysUseDarkMode, useUnableStatus: self.unableStatus)
64+
if let model = model.encoded() {
65+
UserDefaults(suiteName: ApiEnvironment.intentsBundleId)?.set(model, forKey: AppIntentDataModel.key)
66+
}
67+
return .result()
68+
}
69+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// FocusIntentsExtension.swift
3+
// FocusIntents
4+
//
5+
// Created by Mikhail Filimonov on 25.04.2024.
6+
// Copyright © 2024 Telegram. All rights reserved.
7+
//
8+
9+
import AppIntents
10+
import OSLog
11+
12+
13+
@main
14+
struct FocusIntentsExtension: AppIntentsExtension {
15+
init() {
16+
AppDependencyManager.shared.add(dependency: AppIntentsData.shared)
17+
}
18+
}

‎FocusIntents/Info.plist

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>EXAppExtensionAttributes</key>
6+
<dict>
7+
<key>EXExtensionPointIdentifier</key>
8+
<string>com.apple.appintents-extension</string>
9+
</dict>
10+
<key>SOURCE</key>
11+
<string>${SOURCE}</string>
12+
</dict>
13+
</plist>

‎Telegram-Mac/AccountContext.swift

+57-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ import InAppPurchaseManager
2222
import ApiCredentials
2323

2424
let clown: String = "🤡"
25+
let focusIntentEmoji = "⛔️"
2526

2627

2728

29+
func bestWindow(_ accountContext: AccountContext, _ controller: ViewController?) -> Window {
30+
return controller?.window ?? accountContext.window
31+
}
32+
2833
public struct PremiumConfiguration {
2934
public static var defaultValue: PremiumConfiguration {
3035
return PremiumConfiguration(
@@ -169,6 +174,13 @@ extension AppConfiguration {
169174
return defaultValue
170175
}
171176
}
177+
func getStringValue(_ key: String, orElse defaultValue: String) -> String {
178+
if let value = self.data?[key] as? String {
179+
return value
180+
} else {
181+
return defaultValue
182+
}
183+
}
172184
func getBoolValue(_ key: String, orElse defaultValue: Bool) -> Bool {
173185
if let value = self.data?[key] as? Bool {
174186
return value
@@ -325,12 +337,12 @@ final class AccountContextBindings {
325337
let rootNavigation: () -> MajorNavigationController
326338
let mainController: () -> MainViewController
327339
let showControllerToaster: (ControllerToaster, Bool) -> Void
328-
let globalSearch:(String)->Void
340+
let globalSearch:(String, PeerId?)->Void
329341
let switchSplitLayout:(SplitViewState)->Void
330342
let entertainment:()->EntertainmentViewController
331343
let needFullsize:()->Void
332344
let displayUpgradeProgress:(CGFloat)->Void
333-
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() }) {
345+
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() }) {
334346
self.rootNavigation = rootNavigation
335347
self.mainController = mainController
336348
self.showControllerToaster = showControllerToaster
@@ -362,6 +374,7 @@ final class AccountContext {
362374
let cachedGroupCallContexts: AccountGroupCallContextCacheImpl
363375
let networkStatusManager: NetworkStatusManager
364376
let inAppPurchaseManager: InAppPurchaseManager
377+
let starsContext: StarsContext
365378

366379
#endif
367380
private(set) var timeDifference:TimeInterval = 0
@@ -597,7 +610,8 @@ final class AccountContext {
597610
self.networkStatusManager = NetworkStatusManager(account: account, window: window, sharedContext: sharedContext)
598611
self.reactions = Reactions(engine)
599612
self.dockControl = DockControl(engine, accountManager: sharedContext.accountManager)
600-
#endif
613+
self.starsContext = engine.payments.peerStarsContext()
614+
#endif
601615

602616

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

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

933+
// let focusIntentStatus = someAccountSetings(postbox: account.postbox)
934+
// |> distinctUntilChanged(isEqual: {
935+
// $0.focusIntentStatusEnabled == $1.focusIntentStatusEnabled &&
936+
// $0.focusIntentStatusActive == $1.focusIntentStatusActive
937+
// })
938+
// |> deliverOnMainQueue
939+
//
940+
// actionsDisposable.add(focusIntentStatus.startStandalone(next: { [weak self] settings in
941+
// guard let self else {
942+
// return
943+
// }
944+
// let setStatus:(Int64?)->Void = { [weak self] fileId in
945+
// guard let self else {
946+
// return
947+
// }
948+
// if let fileId {
949+
// let file = self.inlinePacksContext.load(fileId: fileId) |> deliverOnMainQueue
950+
// _ = file.startStandalone(next: { file in
951+
// _ = engine.accountData.setEmojiStatus(file: file, expirationDate: nil).start()
952+
// })
953+
// } else {
954+
// _ = engine.accountData.setEmojiStatus(file: nil, expirationDate: nil).start()
955+
// }
956+
// }
957+
// if settings.focusIntentStatusEnabled {
958+
// if let fileId = settings.focusIntentStatusActive {
959+
// setStatus(fileId)
960+
// } else {
961+
// _ = (self.diceCache.top_emojies_status |> deliverOnMainQueue).startStandalone(next: { files in
962+
// if let file = files.first(where: { $0.customEmojiText == focusIntentEmoji }) {
963+
// setStatus(file.fileId.id)
964+
// }
965+
// })
966+
// }
967+
// } else if let fileId = settings.focusIntentStatusFallback {
968+
// setStatus(fileId)
969+
// } else {
970+
// setStatus(nil)
971+
// }
972+
// }))
919973

920974
#endif
921975

0 commit comments

Comments
 (0)