Added ability to send recorded voice data from ComposeControls.

This commit is contained in:
23rd 2020-11-16 19:54:47 +03:00 committed by John Preston
parent ab38ddc21d
commit 024a35d770
2 changed files with 21 additions and 2 deletions

View File

@ -721,12 +721,15 @@ rpl::producer<not_null<QKeyEvent*>> ComposeControls::keyEvents() const {
});
}
rpl::producer<Api::SendOptions> ComposeControls::sendRequests() const {
auto ComposeControls::sendContentRequests(SendRequestType requestType) const {
auto filter = rpl::filter([=] {
const auto type = (_mode == Mode::Normal)
? Ui::SendButton::Type::Send
: Ui::SendButton::Type::Schedule;
return (_send->type() == type);
const auto sendRequestType = _voiceRecordBar->isListenState()
? SendRequestType::Voice
: SendRequestType::Text;
return (_send->type() == type) && (sendRequestType == requestType);
});
auto map = rpl::map_to(Api::SendOptions());
auto submits = base::qt_signal_producer(
@ -738,6 +741,10 @@ rpl::producer<Api::SendOptions> ComposeControls::sendRequests() const {
_sendCustomRequests.events());
}
rpl::producer<Api::SendOptions> ComposeControls::sendRequests() const {
return sendContentRequests(SendRequestType::Text);
}
rpl::producer<VoiceToSend> ComposeControls::sendVoiceRequests() const {
return _voiceRecordBar->sendVoiceRequests();
}
@ -973,6 +980,12 @@ void ComposeControls::init() {
updateHeight();
}, _wrap->lifetime());
sendContentRequests(
SendRequestType::Voice
) | rpl::start_with_next([=](Api::SendOptions options) {
_voiceRecordBar->requestToSendWithOptions(options);
}, _wrap->lifetime());
{
const auto lastMsgId = _wrap->lifetime().make_state<FullMsgId>();

View File

@ -169,6 +169,10 @@ private:
Normal,
Edit,
};
enum class SendRequestType {
Text,
Voice,
};
using TextUpdateEvents = base::flags<TextUpdateEvent>;
friend inline constexpr bool is_flag_type(TextUpdateEvent) { return true; };
@ -195,6 +199,8 @@ private:
void sendSilent();
void sendScheduled();
[[nodiscard]] auto sendContentRequests(
SendRequestType requestType = SendRequestType::Text) const;
void orderControls();
void checkAutocomplete();