mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-22 09:07:05 +02:00
Fixed ability to reply with voice message.
This commit is contained in:
parent
a0b0799399
commit
50ed60f443
3 changed files with 22 additions and 9 deletions
|
@ -773,6 +773,12 @@ void HistoryWidget::initVoiceRecordBar() {
|
|||
return false;
|
||||
});
|
||||
|
||||
const auto applyLocalDraft = [=] {
|
||||
if (_history && _history->localDraft()) {
|
||||
applyDraft();
|
||||
}
|
||||
};
|
||||
|
||||
_voiceRecordBar->sendActionUpdates(
|
||||
) | rpl::start_with_next([=](const auto &data) {
|
||||
if (!_history) {
|
||||
|
@ -799,8 +805,12 @@ void HistoryWidget::initVoiceRecordBar() {
|
|||
data.duration,
|
||||
action);
|
||||
_voiceRecordBar->clearListenState();
|
||||
applyLocalDraft();
|
||||
}, lifetime());
|
||||
|
||||
_voiceRecordBar->cancelRequests(
|
||||
) | rpl::start_with_next(applyLocalDraft, lifetime());
|
||||
|
||||
_voiceRecordBar->lockShowStarts(
|
||||
) | rpl::start_with_next([=] {
|
||||
updateHistoryDownVisibility();
|
||||
|
@ -817,13 +827,6 @@ void HistoryWidget::initVoiceRecordBar() {
|
|||
_scroll->viewportEvent(e);
|
||||
}, lifetime());
|
||||
|
||||
_voiceRecordBar->shownValue(
|
||||
) | rpl::start_with_next([=](bool shown) {
|
||||
if (!shown) {
|
||||
applyDraft();
|
||||
}
|
||||
}, lifetime());
|
||||
|
||||
_voiceRecordBar->hideFast();
|
||||
}
|
||||
|
||||
|
@ -1620,13 +1623,16 @@ void HistoryWidget::fastShowAtEnd(not_null<History*> history) {
|
|||
void HistoryWidget::applyDraft(FieldHistoryAction fieldHistoryAction) {
|
||||
InvokeQueued(this, [=] { updateStickersByEmoji(); });
|
||||
|
||||
if (_voiceRecordBar->isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto draft = !_history
|
||||
? nullptr
|
||||
: _history->localEditDraft()
|
||||
? _history->localEditDraft()
|
||||
: _history->localDraft();
|
||||
auto fieldAvailable = canWriteMessage()
|
||||
&& !_voiceRecordBar->isActive();
|
||||
auto fieldAvailable = canWriteMessage();
|
||||
if (!draft || (!_history->localEditDraft() && !fieldAvailable)) {
|
||||
auto fieldWillBeHiddenAfterEdit = (!fieldAvailable && _editMsgId != 0);
|
||||
clearFieldText(0, fieldHistoryAction);
|
||||
|
|
|
@ -1307,6 +1307,7 @@ void VoiceRecordBar::hideFast() {
|
|||
void VoiceRecordBar::stopRecording(StopType type) {
|
||||
using namespace ::Media::Capture;
|
||||
if (type == StopType::Cancel) {
|
||||
_cancelRequests.fire({});
|
||||
instance()->stop();
|
||||
return;
|
||||
}
|
||||
|
@ -1404,6 +1405,10 @@ rpl::producer<VoiceToSend> VoiceRecordBar::sendVoiceRequests() const {
|
|||
return _sendVoiceRequests.events();
|
||||
}
|
||||
|
||||
rpl::producer<> VoiceRecordBar::cancelRequests() const {
|
||||
return _cancelRequests.events();
|
||||
}
|
||||
|
||||
bool VoiceRecordBar::isRecording() const {
|
||||
return _recording.current();
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
|
||||
[[nodiscard]] rpl::producer<SendActionUpdate> sendActionUpdates() const;
|
||||
[[nodiscard]] rpl::producer<VoiceToSend> sendVoiceRequests() const;
|
||||
[[nodiscard]] rpl::producer<> cancelRequests() const;
|
||||
[[nodiscard]] rpl::producer<bool> recordingStateChanges() const;
|
||||
[[nodiscard]] rpl::producer<bool> lockShowStarts() const;
|
||||
[[nodiscard]] rpl::producer<not_null<QEvent*>> lockViewportEvents() const;
|
||||
|
@ -128,6 +129,7 @@ private:
|
|||
|
||||
rpl::event_stream<SendActionUpdate> _sendActionUpdates;
|
||||
rpl::event_stream<VoiceToSend> _sendVoiceRequests;
|
||||
rpl::event_stream<> _cancelRequests;
|
||||
rpl::event_stream<> _listenChanges;
|
||||
|
||||
int _centerY = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue