Fixed display of chat buttons on main touchbar after audio touchbar.

Fixed #10361.
This commit is contained in:
23rd 2021-04-03 19:29:30 +03:00 committed by John Preston
parent 07c65dfd74
commit 23996d14d3
2 changed files with 14 additions and 15 deletions

View file

@ -540,10 +540,7 @@ void AppendEmojiPacks(
self.popoverTouchBar = [[[NSTouchBar alloc] init] autorelease];
self.popoverTouchBar.delegate = self;
rpl::single(
controller->sessionController()->activeChatCurrent()
) | rpl::then(
controller->sessionController()->activeChatChanges()
controller->sessionController()->activeChatValue(
) | rpl::map([](Dialogs::Key k) {
return k.peer()
&& k.history()

View file

@ -59,7 +59,8 @@ const auto kAudioItemIdentifier = @"touchbarAudio";
Main::Session *_session;
Window::Controller *_controller;
rpl::producer<bool> _canApplyMarkdown;
bool _canApplyMarkdownLast;
rpl::event_stream<bool> _canApplyMarkdown;
rpl::event_stream<> _touchBarSwitches;
rpl::lifetime _lifetime;
}
@ -76,7 +77,10 @@ const auto kAudioItemIdentifier = @"touchbarAudio";
self.defaultItemIdentifiers = @[];
});
_controller = controller;
_canApplyMarkdown = std::move(canApplyMarkdown);
_canApplyMarkdownLast = false;
std::move(
canApplyMarkdown
) | rpl::start_to_stream(_canApplyMarkdown, _lifetime);
auto sessionChanges = domain->activeSessionChanges(
) | rpl::map([=](Main::Session *session) {
@ -138,18 +142,16 @@ const auto kAudioItemIdentifier = @"touchbarAudio";
init:_controller
touchBarSwitches:_touchBarSwitches.events()] autorelease];
rpl::combine(
rpl::single(false) | rpl::then(rpl::duplicate(_canApplyMarkdown)),
rpl::single(
false
) | rpl::then(
_controller->sessionController()->activeChatChanges(
) | rpl::map([](Dialogs::Key k) {
return k.peer() && k.history() && k.peer()->canWrite();
})
) | rpl::distinct_until_changed()
_canApplyMarkdown.events_starting_with_copy(
_canApplyMarkdownLast),
_controller->sessionController()->activeChatValue(
) | rpl::map([](Dialogs::Key k) {
return k.peer() && k.history() && k.peer()->canWrite();
}) | rpl::distinct_until_changed()
) | rpl::start_with_next([=](
bool canApplyMarkdown,
bool hasActiveChat) {
_canApplyMarkdownLast = canApplyMarkdown;
item.groupTouchBar.defaultItemIdentifiers = @[
kPinnedPanelItemIdentifier,
canApplyMarkdown