Skip to content

Commit a35a6ed

Browse files
author
Mike Renoir
committed
bug fixes
1 parent e153469 commit a35a6ed

File tree

105 files changed

+640
-456
lines changed

Some content is hidden

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

105 files changed

+640
-456
lines changed

Telegram-Mac/AccountContext.swift

+12-9
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ final class AccountContextBindings {
5252
let entertainment:()->EntertainmentViewController
5353
let needFullsize:()->Void
5454
let displayUpgradeProgress:(CGFloat)->Void
55-
let callSession: ()->PCallSession?
56-
let groupCall: ()->GroupCallContext?
57-
let getContext:()->AccountContext?
58-
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() }, callSession: @escaping()->PCallSession? = { return nil }, groupCall: @escaping()->GroupCallContext? = { return nil }, getContext:@escaping()->AccountContext? = { return nil }) {
55+
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() }) {
5956
self.rootNavigation = rootNavigation
6057
self.mainController = mainController
6158
self.showControllerToaster = showControllerToaster
@@ -64,9 +61,6 @@ final class AccountContextBindings {
6461
self.switchSplitLayout = switchSplitLayout
6562
self.needFullsize = needFullsize
6663
self.displayUpgradeProgress = displayUpgradeProgress
67-
self.callSession = callSession
68-
self.groupCall = groupCall
69-
self.getContext = getContext
7064
}
7165
#endif
7266
}
@@ -79,6 +73,9 @@ final class AccountContext {
7973
let sharedContext: SharedAccountContext
8074
let account: Account
8175
let window: Window
76+
77+
var bindings: AccountContextBindings = AccountContextBindings()
78+
8279

8380
#if !SHARE
8481
let fetchManager: FetchManager
@@ -115,6 +112,7 @@ final class AccountContext {
115112

116113
let cancelGlobalSearch:ValuePromise<Bool> = ValuePromise(ignoreRepeated: false)
117114

115+
private(set) var isSupport: Bool = false
118116

119117

120118
var isCurrent: Bool = false {
@@ -203,11 +201,12 @@ final class AccountContext {
203201
let engine: TelegramEngine
204202

205203

206-
init(sharedContext: SharedAccountContext, window: Window, account: Account) {
204+
init(sharedContext: SharedAccountContext, window: Window, account: Account, isSupport: Bool = false) {
207205
self.sharedContext = sharedContext
208206
self.account = account
209207
self.window = window
210208
self.engine = TelegramEngine(account: account)
209+
self.isSupport = isSupport
211210
#if !SHARE
212211
self.peerChannelMemberCategoriesContextsManager = PeerChannelMemberCategoriesContextsManager(self.engine, account: account)
213212
self.diceCache = DiceCache(postbox: account.postbox, engine: self.engine)
@@ -511,6 +510,10 @@ final class AccountContext {
511510
self.isKeyWindowValue.set(window.isKeyWindow)
512511
}
513512

513+
func focus() {
514+
window.makeKeyAndOrderFront(nil)
515+
}
516+
514517
private func updateTheme(_ update: ApplyThemeUpdate) {
515518
switch update {
516519
case let .cloud(cloudTheme):
@@ -693,7 +696,7 @@ final class AccountContext {
693696

694697
_ = create.start(next: { [weak self] peerId in
695698
guard let `self` = self else {return}
696-
self.sharedContext.bindings.rootNavigation().push(ChatController(context: self, chatLocation: .peer(peerId)))
699+
self.bindings.rootNavigation().push(ChatController(context: self, chatLocation: .peer(peerId)))
697700
})
698701
}
699702
#endif

Telegram-Mac/AccountViewController.swift

+27-16
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,22 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
258258
return ShortPeerRowItem(initialSize, peer: info.peer, account: info.account, height: 42, photoSize: NSMakeSize(28, 28), titleStyle: ControlStyle(font: .normal(.title), foregroundColor: theme.colors.text, highlightColor: theme.colors.underSelectedColor), borderType: [.Right], inset: NSEdgeInsets(left: 12, right: 12), viewType: viewType, action: {
259259
arguments.context.sharedContext.switchToAccount(id: info.account.id, action: nil)
260260
}, contextMenuItems: {
261-
return .single([ContextMenuItem(strings().accountSettingsDeleteAccount, handler: {
261+
262+
var items:[ContextMenuItem] = []
263+
264+
items.append(ContextMenuItem("Open In Window", handler: {
265+
arguments.context.sharedContext.openAccount(id: info.account.id)
266+
}, itemImage: MenuAnimation.menu_open_profile.value))
267+
268+
items.append(ContextSeparatorItem())
269+
270+
items.append(ContextMenuItem(strings().accountSettingsDeleteAccount, handler: {
262271
confirm(for: arguments.context.window, information: strings().accountConfirmLogoutText, successHandler: { _ in
263272
_ = logoutFromAccount(id: info.account.id, accountManager: arguments.context.sharedContext.accountManager, alreadyLoggedOutRemotely: false).start()
264273
})
265-
}, itemMode: .destruct, itemImage: MenuAnimation.menu_delete.value),
266-
ContextMenuItem("Open In Separate Window", handler: {
267-
268-
}, itemMode: .destruct, itemImage: MenuAnimation.menu_delete.value)])
274+
}, itemMode: .destruct, itemImage: MenuAnimation.menu_delete.value))
275+
276+
return .single(items)
269277
}, alwaysHighlight: true, badgeNode: GlobalBadgeNode(info.account, sharedContext: arguments.context.sharedContext, getColor: { _ in theme.colors.accent }, sync: true), compactText: true)
270278
case let .addAccount(_, viewType):
271279
return GeneralInteractedRowItem(initialSize, stableId: stableId, name: strings().accountSettingsAddAccount, nameStyle: ControlStyle(font: .normal(.title), foregroundColor: theme.colors.accentIcon), type: .none, viewType: viewType, action: {
@@ -286,7 +294,7 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
286294
}
287295
message = message.trimmed
288296

289-
showModal(with: ShareModalController(ShareLinkObject(arguments.context, link: message)), for: mainWindow)
297+
showModal(with: ShareModalController(ShareLinkObject(arguments.context, link: message)), for: arguments.context.window)
290298
}, pushController: { controller in
291299
arguments.presentController(controller, false)
292300
})
@@ -331,10 +339,10 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
331339
return GeneralInteractedRowItem(initialSize, stableId: stableId, name: strings().accountSettingsFAQ, icon: theme.icons.settingsFaq, activeIcon: theme.icons.settingsFaqActive, type: .next, viewType: viewType, action: arguments.openFaq, border:[BorderType.Right], inset:NSEdgeInsets(left: 12, right: 12))
332340
case let .ask(_, viewType):
333341
return GeneralInteractedRowItem(initialSize, stableId: stableId, name: strings().accountSettingsAskQuestion, icon: theme.icons.settingsAskQuestion, activeIcon: theme.icons.settingsAskQuestionActive, type: .next, viewType: viewType, action: {
334-
confirm(for: mainWindow, information: strings().accountConfirmAskQuestion, thridTitle: strings().accountConfirmGoToFaq, successHandler: { result in
342+
confirm(for: arguments.context.window, information: strings().accountConfirmAskQuestion, thridTitle: strings().accountConfirmGoToFaq, successHandler: { result in
335343
switch result {
336344
case .basic:
337-
_ = showModalProgress(signal: arguments.context.engine.peers.supportPeerId(), for: mainWindow).start(next: { peerId in
345+
_ = showModalProgress(signal: arguments.context.engine.peers.supportPeerId(), for: arguments.context.window).start(next: { peerId in
338346
if let peerId = peerId {
339347
arguments.presentController(ChatController(context: arguments.context, chatLocation: .peer(peerId)), true)
340348
}
@@ -395,13 +403,16 @@ private func accountInfoEntries(peerView:PeerView, context: AccountContext, acco
395403
entries.append(.whiteSpace(index: index, height: 20))
396404
index += 1
397405

398-
for account in accounts {
399-
if account.account.id != context.account.id {
400-
entries.append(.accountRecord(index: index, viewType: .singleItem, info: account))
401-
index += 1
406+
if !context.isSupport {
407+
for account in accounts {
408+
if account.account.id != context.account.id {
409+
entries.append(.accountRecord(index: index, viewType: .singleItem, info: account))
410+
index += 1
411+
}
402412
}
403413
}
404-
if accounts.count < 3 {
414+
415+
if accounts.count < 3, !context.isSupport {
405416
entries.append(.addAccount(index: index, viewType: .singleItem))
406417
index += 1
407418
}
@@ -445,7 +456,7 @@ private func accountInfoEntries(peerView:PeerView, context: AccountContext, acco
445456
index += 1
446457
}
447458

448-
if let state = appUpdateState {
459+
if let state = appUpdateState, !context.isSupport {
449460
entries.append(.update(index: index, viewType: .singleItem, state: AnyUpdateStateEquatable(any: state)))
450461
index += 1
451462
}
@@ -493,7 +504,7 @@ class LayoutAccountController : TableViewController {
493504
private var searchController: InputDataController?
494505
private let searchState: ValuePromise<SearchState> = ValuePromise(ignoreRepeated: true)
495506
var navigation:NavigationViewController? {
496-
return context.sharedContext.bindings.rootNavigation()
507+
return context.bindings.rootNavigation()
497508
}
498509

499510
override func viewDidResized(_ size: NSSize) {
@@ -834,7 +845,7 @@ class LayoutAccountController : TableViewController {
834845
}
835846

836847
if let currentEvent = NSApp.currentEvent, currentEvent.clickCount == 5 {
837-
context.sharedContext.bindings.rootNavigation().push(DeveloperViewController(context: context))
848+
context.bindings.rootNavigation().push(DeveloperViewController(context: context))
838849
}
839850

840851
genericView.scroll(to: .up(true))

Telegram-Mac/AddContactModalController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ func AddContactModalController(_ context: AccountContext) -> InputDataModalContr
123123
if !fields.isEmpty {
124124
f(.fail(.fields(fields)))
125125
} else {
126-
_ = (showModalProgress(signal: context.engine.contacts.importContact(firstName: state.firstName, lastName: state.lastName, phoneNumber: state.phoneNumber), for: mainWindow) |> deliverOnMainQueue).start(next: { peerId in
126+
_ = (showModalProgress(signal: context.engine.contacts.importContact(firstName: state.firstName, lastName: state.lastName, phoneNumber: state.phoneNumber), for: context.window) |> deliverOnMainQueue).start(next: { peerId in
127127
if let peerId = peerId {
128-
context.sharedContext.bindings.rootNavigation().push(ChatController(context: context, chatLocation: .peer(peerId)))
128+
context.bindings.rootNavigation().push(ChatController(context: context, chatLocation: .peer(peerId)))
129129
close?()
130130
} else {
131131
updateState {

Telegram-Mac/AppAppearanceViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ func AppAppearanceViewController(context: AccountContext, focusOnItemTag: ThemeS
534534
}, selectChatBackground: {
535535
showModal(with: ChatWallpaperModalController(context), for: context.window)
536536
}, openAutoNightSettings: {
537-
context.sharedContext.bindings.rootNavigation().push(AutoNightSettingsController(context: context))
537+
context.bindings.rootNavigation().push(AutoNightSettingsController(context: context))
538538
}, removeTheme: { cloudTheme in
539539
confirm(for: context.window, header: strings().appearanceConfirmRemoveTitle, information: strings().appearanceConfirmRemoveText, okTitle: strings().appearanceConfirmRemoveOK, successHandler: { _ in
540540
var signals:[Signal<Void, NoError>] = []

0 commit comments

Comments
 (0)