From c90e803f1b2701c37717100737facb62474d5255 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 8 May 2019 13:42:15 +0300 Subject: [PATCH] Added handler of logout to touchbar. --- Telegram/SourceFiles/apiwrap.cpp | 1 + .../platform/mac/main_window_mac.mm | 23 ++++++++++--------- Telegram/SourceFiles/platform/mac/touchbar.h | 3 ++- .../SourceFiles/platform/platform_specific.h | 5 ---- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 25fc210bb4..a9ee13bc17 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -944,6 +944,7 @@ void ApiWrap::requestPinnedDialogs(Data::Folder *folder) { data.vmessages.v, data.vdialogs.v); _session->data().chatsListChanged(folder); + _session->data().notifyPinnedDialogsOrderUpdated(); }); }).fail([=](const RPCError &error) { finalize(); diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.mm b/Telegram/SourceFiles/platform/mac/main_window_mac.mm index 78c4047e16..95c3b19cea 100644 --- a/Telegram/SourceFiles/platform/mac/main_window_mac.mm +++ b/Telegram/SourceFiles/platform/mac/main_window_mac.mm @@ -398,18 +398,19 @@ MainWindow::MainWindow() subscribe(Core::App().authSessionChanged(), [this] { if (AuthSession::Exists()) { - - Auth().data().chatsListChanges( - ) | rpl::start_with_next([this](Data::Folder* folder) { - // We need only common pinned dialogs. - if (!folder && !_private->_touchBar) { - if (auto view = reinterpret_cast(winId())) { - // Create TouchBar. - [NSApplication sharedApplication].automaticCustomizeTouchBarMenuItemEnabled = YES; - _private->_touchBar = [[TouchBar alloc] init:view]; - } + // We need only common pinned dialogs. + if (!_private->_touchBar) { + if (auto view = reinterpret_cast(winId())) { + // Create TouchBar. + [NSApplication sharedApplication].automaticCustomizeTouchBarMenuItemEnabled = YES; + _private->_touchBar = [[TouchBar alloc] init:view]; } - }, lifetime()); + } + } else { + if (_private->_touchBar) { + [_private->_touchBar setTouchBar:TouchBarType::None]; + } + _private->_touchBar = nullptr; } }); diff --git a/Telegram/SourceFiles/platform/mac/touchbar.h b/Telegram/SourceFiles/platform/mac/touchbar.h index 1796d6ae7e..de8625b7d6 100644 --- a/Telegram/SourceFiles/platform/mac/touchbar.h +++ b/Telegram/SourceFiles/platform/mac/touchbar.h @@ -49,6 +49,7 @@ static NSTouchBarItemIdentifier _Nullable currentPosition = [NSString stringWith @property(retain) NSMutableArray * _Nullable mainPinnedButtons; - (id _Nonnull) init:(NSView * _Nonnull)view; -- (void)handlePropertyChange:(Media::Player::TrackState)property; +- (void) handlePropertyChange:(Media::Player::TrackState)property; +- (void) setTouchBar:(TouchBarType)type; @end diff --git a/Telegram/SourceFiles/platform/platform_specific.h b/Telegram/SourceFiles/platform/platform_specific.h index f376f01daa..919065a02d 100644 --- a/Telegram/SourceFiles/platform/platform_specific.h +++ b/Telegram/SourceFiles/platform/platform_specific.h @@ -26,11 +26,6 @@ enum class SystemSettingsType { Audio, }; -enum class TouchBarType { - AudioPlayer, - None, -}; - void SetWatchingMediaKeys(bool watching); bool IsApplicationActive(); void SetApplicationIcon(const QIcon &icon);