mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix sending single-time voice messages.
This commit is contained in:
parent
104cf504ab
commit
b31bb6dd33
2 changed files with 12 additions and 5 deletions
|
@ -1638,10 +1638,12 @@ void VoiceRecordBar::stop(bool send) {
|
||||||
if (isHidden() && !send) {
|
if (isHidden() && !send) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const auto ttlBeforeHide = peekTTLState();
|
||||||
auto disappearanceCallback = [=] {
|
auto disappearanceCallback = [=] {
|
||||||
hide();
|
hide();
|
||||||
|
|
||||||
stopRecording(send ? StopType::Send : StopType::Cancel);
|
const auto type = send ? StopType::Send : StopType::Cancel;
|
||||||
|
stopRecording(type, ttlBeforeHide);
|
||||||
};
|
};
|
||||||
_lockShowing = false;
|
_lockShowing = false;
|
||||||
visibilityAnimate(false, std::move(disappearanceCallback));
|
visibilityAnimate(false, std::move(disappearanceCallback));
|
||||||
|
@ -1671,7 +1673,7 @@ void VoiceRecordBar::hideFast() {
|
||||||
[[maybe_unused]] const auto s = takeTTLState();
|
[[maybe_unused]] const auto s = takeTTLState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoiceRecordBar::stopRecording(StopType type) {
|
void VoiceRecordBar::stopRecording(StopType type, bool ttlBeforeHide) {
|
||||||
using namespace ::Media::Capture;
|
using namespace ::Media::Capture;
|
||||||
if (type == StopType::Cancel) {
|
if (type == StopType::Cancel) {
|
||||||
instance()->stop(crl::guard(this, [=](Result &&data) {
|
instance()->stop(crl::guard(this, [=](Result &&data) {
|
||||||
|
@ -1691,9 +1693,9 @@ void VoiceRecordBar::stopRecording(StopType type) {
|
||||||
const auto duration = Duration(data.samples);
|
const auto duration = Duration(data.samples);
|
||||||
if (type == StopType::Send) {
|
if (type == StopType::Send) {
|
||||||
const auto options = Api::SendOptions{
|
const auto options = Api::SendOptions{
|
||||||
.ttlSeconds = takeTTLState()
|
.ttlSeconds = (ttlBeforeHide
|
||||||
? std::numeric_limits<int>::max()
|
? std::numeric_limits<int>::max()
|
||||||
: 0
|
: 0),
|
||||||
};
|
};
|
||||||
_sendVoiceRequests.fire({
|
_sendVoiceRequests.fire({
|
||||||
data.bytes,
|
data.bytes,
|
||||||
|
@ -1901,6 +1903,10 @@ void VoiceRecordBar::computeAndSetLockProgress(QPoint globalPos) {
|
||||||
_lock->requestPaintProgress(Progress(localPos.y(), higher - lower));
|
_lock->requestPaintProgress(Progress(localPos.y(), higher - lower));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VoiceRecordBar::peekTTLState() const {
|
||||||
|
return !_ttlButton->isDisabled();
|
||||||
|
}
|
||||||
|
|
||||||
bool VoiceRecordBar::takeTTLState() const {
|
bool VoiceRecordBar::takeTTLState() const {
|
||||||
const auto hasTtl = !_ttlButton->isDisabled();
|
const auto hasTtl = !_ttlButton->isDisabled();
|
||||||
_ttlButton->clearState();
|
_ttlButton->clearState();
|
||||||
|
|
|
@ -126,7 +126,7 @@ private:
|
||||||
[[nodiscard]] bool recordingAnimationCallback(crl::time now);
|
[[nodiscard]] bool recordingAnimationCallback(crl::time now);
|
||||||
|
|
||||||
void stop(bool send);
|
void stop(bool send);
|
||||||
void stopRecording(StopType type);
|
void stopRecording(StopType type, bool ttlBeforeHide = false);
|
||||||
void visibilityAnimate(bool show, Fn<void()> &&callback);
|
void visibilityAnimate(bool show, Fn<void()> &&callback);
|
||||||
|
|
||||||
[[nodiscard]] bool showRecordButton() const;
|
[[nodiscard]] bool showRecordButton() const;
|
||||||
|
@ -149,6 +149,7 @@ private:
|
||||||
|
|
||||||
void computeAndSetLockProgress(QPoint globalPos);
|
void computeAndSetLockProgress(QPoint globalPos);
|
||||||
|
|
||||||
|
[[nodiscard]] bool peekTTLState() const;
|
||||||
[[nodiscard]] bool takeTTLState() const;
|
[[nodiscard]] bool takeTTLState() const;
|
||||||
|
|
||||||
const style::RecordBar &_st;
|
const style::RecordBar &_st;
|
||||||
|
|
Loading…
Add table
Reference in a new issue