mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-05-03 14:34:24 +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
Telegram/SourceFiles/history
|
@ -773,6 +773,12 @@ void HistoryWidget::initVoiceRecordBar() {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const auto applyLocalDraft = [=] {
|
||||||
|
if (_history && _history->localDraft()) {
|
||||||
|
applyDraft();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
_voiceRecordBar->sendActionUpdates(
|
_voiceRecordBar->sendActionUpdates(
|
||||||
) | rpl::start_with_next([=](const auto &data) {
|
) | rpl::start_with_next([=](const auto &data) {
|
||||||
if (!_history) {
|
if (!_history) {
|
||||||
|
@ -799,8 +805,12 @@ void HistoryWidget::initVoiceRecordBar() {
|
||||||
data.duration,
|
data.duration,
|
||||||
action);
|
action);
|
||||||
_voiceRecordBar->clearListenState();
|
_voiceRecordBar->clearListenState();
|
||||||
|
applyLocalDraft();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
_voiceRecordBar->cancelRequests(
|
||||||
|
) | rpl::start_with_next(applyLocalDraft, lifetime());
|
||||||
|
|
||||||
_voiceRecordBar->lockShowStarts(
|
_voiceRecordBar->lockShowStarts(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
updateHistoryDownVisibility();
|
updateHistoryDownVisibility();
|
||||||
|
@ -817,13 +827,6 @@ void HistoryWidget::initVoiceRecordBar() {
|
||||||
_scroll->viewportEvent(e);
|
_scroll->viewportEvent(e);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
_voiceRecordBar->shownValue(
|
|
||||||
) | rpl::start_with_next([=](bool shown) {
|
|
||||||
if (!shown) {
|
|
||||||
applyDraft();
|
|
||||||
}
|
|
||||||
}, lifetime());
|
|
||||||
|
|
||||||
_voiceRecordBar->hideFast();
|
_voiceRecordBar->hideFast();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1620,13 +1623,16 @@ void HistoryWidget::fastShowAtEnd(not_null<History*> history) {
|
||||||
void HistoryWidget::applyDraft(FieldHistoryAction fieldHistoryAction) {
|
void HistoryWidget::applyDraft(FieldHistoryAction fieldHistoryAction) {
|
||||||
InvokeQueued(this, [=] { updateStickersByEmoji(); });
|
InvokeQueued(this, [=] { updateStickersByEmoji(); });
|
||||||
|
|
||||||
|
if (_voiceRecordBar->isActive()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto draft = !_history
|
auto draft = !_history
|
||||||
? nullptr
|
? nullptr
|
||||||
: _history->localEditDraft()
|
: _history->localEditDraft()
|
||||||
? _history->localEditDraft()
|
? _history->localEditDraft()
|
||||||
: _history->localDraft();
|
: _history->localDraft();
|
||||||
auto fieldAvailable = canWriteMessage()
|
auto fieldAvailable = canWriteMessage();
|
||||||
&& !_voiceRecordBar->isActive();
|
|
||||||
if (!draft || (!_history->localEditDraft() && !fieldAvailable)) {
|
if (!draft || (!_history->localEditDraft() && !fieldAvailable)) {
|
||||||
auto fieldWillBeHiddenAfterEdit = (!fieldAvailable && _editMsgId != 0);
|
auto fieldWillBeHiddenAfterEdit = (!fieldAvailable && _editMsgId != 0);
|
||||||
clearFieldText(0, fieldHistoryAction);
|
clearFieldText(0, fieldHistoryAction);
|
||||||
|
|
|
@ -1307,6 +1307,7 @@ void VoiceRecordBar::hideFast() {
|
||||||
void VoiceRecordBar::stopRecording(StopType type) {
|
void VoiceRecordBar::stopRecording(StopType type) {
|
||||||
using namespace ::Media::Capture;
|
using namespace ::Media::Capture;
|
||||||
if (type == StopType::Cancel) {
|
if (type == StopType::Cancel) {
|
||||||
|
_cancelRequests.fire({});
|
||||||
instance()->stop();
|
instance()->stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1404,6 +1405,10 @@ rpl::producer<VoiceToSend> VoiceRecordBar::sendVoiceRequests() const {
|
||||||
return _sendVoiceRequests.events();
|
return _sendVoiceRequests.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpl::producer<> VoiceRecordBar::cancelRequests() const {
|
||||||
|
return _cancelRequests.events();
|
||||||
|
}
|
||||||
|
|
||||||
bool VoiceRecordBar::isRecording() const {
|
bool VoiceRecordBar::isRecording() const {
|
||||||
return _recording.current();
|
return _recording.current();
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<SendActionUpdate> sendActionUpdates() const;
|
[[nodiscard]] rpl::producer<SendActionUpdate> sendActionUpdates() const;
|
||||||
[[nodiscard]] rpl::producer<VoiceToSend> sendVoiceRequests() const;
|
[[nodiscard]] rpl::producer<VoiceToSend> sendVoiceRequests() const;
|
||||||
|
[[nodiscard]] rpl::producer<> cancelRequests() const;
|
||||||
[[nodiscard]] rpl::producer<bool> recordingStateChanges() const;
|
[[nodiscard]] rpl::producer<bool> recordingStateChanges() const;
|
||||||
[[nodiscard]] rpl::producer<bool> lockShowStarts() const;
|
[[nodiscard]] rpl::producer<bool> lockShowStarts() const;
|
||||||
[[nodiscard]] rpl::producer<not_null<QEvent*>> lockViewportEvents() const;
|
[[nodiscard]] rpl::producer<not_null<QEvent*>> lockViewportEvents() const;
|
||||||
|
@ -128,6 +129,7 @@ private:
|
||||||
|
|
||||||
rpl::event_stream<SendActionUpdate> _sendActionUpdates;
|
rpl::event_stream<SendActionUpdate> _sendActionUpdates;
|
||||||
rpl::event_stream<VoiceToSend> _sendVoiceRequests;
|
rpl::event_stream<VoiceToSend> _sendVoiceRequests;
|
||||||
|
rpl::event_stream<> _cancelRequests;
|
||||||
rpl::event_stream<> _listenChanges;
|
rpl::event_stream<> _listenChanges;
|
||||||
|
|
||||||
int _centerY = 0;
|
int _centerY = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue