Added touchbar hiding while recording voice message.

This commit is contained in:
23rd 2020-10-12 22:30:14 +03:00 committed by John Preston
parent 041d8571c2
commit b3925a3bec
3 changed files with 18 additions and 3 deletions

View file

@ -96,6 +96,9 @@ void Instance::start() {
_updates.fire_error({});
});
});
crl::on_main(this, [=] {
_started = true;
});
});
}
@ -103,11 +106,13 @@ void Instance::stop(Fn<void(Result&&)> callback) {
InvokeQueued(_inner.get(), [=] {
if (!callback) {
_inner->stop();
crl::on_main(this, [=] { _started = false; });
return;
}
_inner->stop([=](Result &&result) {
crl::on_main([=, result = std::move(result)]() mutable {
callback(std::move(result));
_started = false;
});
});
});

View file

@ -42,6 +42,10 @@ public:
return _updates.events();
}
[[nodiscard]] rpl::producer<bool> startedChanges() const {
return _started.changes();
}
void start();
void stop(Fn<void(Result&&)> callback = nullptr);
@ -50,6 +54,7 @@ private:
friend class Inner;
bool _available = false;
rpl::variable<bool> _started = false;;
rpl::event_stream<Update, rpl::empty_error> _updates;
QThread _thread;
std::unique_ptr<Inner> _inner;

View file

@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_domain.h"
#include "main/main_session.h"
#include "mainwidget.h" // MainWidget::closeBothPlayers
#include "media/audio/media_audio_capture.h"
#include "media/player/media_player_instance.h"
#include "platform/mac/touchbar/mac_touchbar_audio.h"
#include "platform/mac/touchbar/mac_touchbar_common.h"
@ -91,20 +92,24 @@ const auto kAudioItemIdentifier = @"touchbarAudio";
Media::Player::instance()->startsPlay(type) | rpl::map_to(true)
);
auto voiceRecording = ::Media::Capture::instance()->startedChanges();
rpl::combine(
std::move(sessionChanges),
rpl::single(false) | rpl::then(Core::App().passcodeLockChanges()),
rpl::single(false) | rpl::then(std::move(audioPlayer))
rpl::single(false) | rpl::then(std::move(audioPlayer)),
rpl::single(false) | rpl::then(std::move(voiceRecording))
) | rpl::start_with_next([=](
Main::Session *session,
bool lock,
bool audio) {
bool audio,
bool recording) {
TouchBar::CustomEnterToCocoaEventLoop([=] {
_touchBarSwitches.fire({});
if (!audio) {
self.defaultItemIdentifiers = @[];
}
self.defaultItemIdentifiers = lock
self.defaultItemIdentifiers = (lock || recording)
? @[]
: audio
? @[kAudioItemIdentifier]