mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
fix: a bunch of fixes
TTL media, some crashes, useless code
This commit is contained in:
parent
b285b4d309
commit
b2ce1d2d15
7 changed files with 71 additions and 72 deletions
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include "api/api_text_entities.h"
|
#include "api/api_text_entities.h"
|
||||||
|
|
||||||
|
#include "lang_auto.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "data/data_forum.h"
|
#include "data/data_forum.h"
|
||||||
#include "data/data_forum_topic.h"
|
#include "data/data_forum_topic.h"
|
||||||
|
@ -222,4 +223,12 @@ void MarkAsReadThread(not_null<Data::Thread *> thread)
|
||||||
if (thread->unreadReactions().has()) {
|
if (thread->unreadReactions().has()) {
|
||||||
sendReadReactions(thread);
|
sendReadReactions(thread);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString formatTTL(int time) {
|
||||||
|
if (time == 0x7FFFFFFF) {
|
||||||
|
return QString("👀 %1").arg(tr::ayu_OneViewTTL(tr::now));
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString("🕓 %1s").arg(time);
|
||||||
}
|
}
|
|
@ -23,3 +23,5 @@ std::pair<std::string, std::string> serializeTextWithEntities(not_null<HistoryIt
|
||||||
|
|
||||||
void MarkAsReadChatList(not_null<Dialogs::MainList *> list);
|
void MarkAsReadChatList(not_null<Dialogs::MainList *> list);
|
||||||
void MarkAsReadThread(not_null<Data::Thread *> thread);
|
void MarkAsReadThread(not_null<Data::Thread *> thread);
|
||||||
|
|
||||||
|
QString formatTTL(int time);
|
||||||
|
|
|
@ -491,26 +491,29 @@ void GifsListWidget::selectInlineResult(
|
||||||
const auto preview = Data::VideoPreviewState(media.get());
|
const auto preview = Data::VideoPreviewState(media.get());
|
||||||
if (forceSend || (media && preview.loaded())) {
|
if (forceSend || (media && preview.loaded())) {
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
auto sendGIFCallback = [=, this]
|
|
||||||
{
|
|
||||||
_fileChosen.fire({
|
|
||||||
.document = document,
|
|
||||||
.options = options,
|
|
||||||
.messageSendingFrom = messageSendingFrom(),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if (settings->gifConfirmation)
|
if (settings->gifConfirmation) {
|
||||||
{
|
auto sendGIFCallback = [=, this]
|
||||||
|
{
|
||||||
|
_fileChosen.fire({
|
||||||
|
.document = document,
|
||||||
|
.options = options,
|
||||||
|
.messageSendingFrom = messageSendingFrom(),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
Ui::show(Ui::MakeConfirmBox({
|
Ui::show(Ui::MakeConfirmBox({
|
||||||
.text = tr::ayu_ConfirmationGIF(),
|
.text = tr::ayu_ConfirmationGIF(),
|
||||||
.confirmed = sendGIFCallback,
|
.confirmed = sendGIFCallback,
|
||||||
.confirmText = tr::lng_send_button()
|
.confirmText = tr::lng_send_button()
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
_fileChosen.fire({
|
||||||
sendGIFCallback();
|
.document = document,
|
||||||
|
.options = options,
|
||||||
|
.messageSendingFrom = messageSendingFrom(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else if (!preview.usingThumbnail()) {
|
} else if (!preview.usingThumbnail()) {
|
||||||
if (preview.loading()) {
|
if (preview.loading()) {
|
||||||
|
|
|
@ -2292,22 +2292,6 @@ void Session::updateEditedMessage(const MTPMessage &data) {
|
||||||
bool isDocument = media && media->document();
|
bool isDocument = media && media->document();
|
||||||
|
|
||||||
AyuMessages::getInstance().addEditedMessage(edit, existing);
|
AyuMessages::getInstance().addEditedMessage(edit, existing);
|
||||||
|
|
||||||
if (!media || !(media->photo() || media->document()))
|
|
||||||
{
|
|
||||||
// history->addNewLocalMessage(
|
|
||||||
// history->nextNonHistoryEntryId(),
|
|
||||||
// flags,
|
|
||||||
// UserId(),
|
|
||||||
// existing->id,
|
|
||||||
// base::unixtime::now(),
|
|
||||||
// existing->author()->id,
|
|
||||||
// "AyuGram"_q,
|
|
||||||
// msg,
|
|
||||||
// MTP_messageMediaEmpty(),
|
|
||||||
// HistoryMessageMarkupData(),
|
|
||||||
// existing->groupId().empty() ? 0 : existing->groupId().value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
proceed:
|
proceed:
|
||||||
|
|
|
@ -72,6 +72,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
// AyuGram includes
|
// AyuGram includes
|
||||||
#include "ayu/ayu_settings.h"
|
#include "ayu/ayu_settings.h"
|
||||||
|
#include "ayu/utils/telegram_helpers.h"
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -235,7 +236,7 @@ std::unique_ptr<Data::Media> HistoryItem::CreateMedia(
|
||||||
});
|
});
|
||||||
}, [&](const MTPDmessageMediaDocument &media) -> Result {
|
}, [&](const MTPDmessageMediaDocument &media) -> Result {
|
||||||
const auto document = media.vdocument();
|
const auto document = media.vdocument();
|
||||||
if (media.vttl_seconds()) {
|
if (media.vttl_seconds() && false) { // AyuGram: show expiring messages
|
||||||
LOG(("App Error: "
|
LOG(("App Error: "
|
||||||
"Unexpected MTPMessageMediaDocument "
|
"Unexpected MTPMessageMediaDocument "
|
||||||
"with ttl_seconds in CreateMedia."));
|
"with ttl_seconds in CreateMedia."));
|
||||||
|
@ -336,15 +337,15 @@ HistoryItem::HistoryItem(
|
||||||
applyTTL(data);
|
applyTTL(data);
|
||||||
} else {
|
} else {
|
||||||
createComponents(data);
|
createComponents(data);
|
||||||
if (const auto media = data.vmedia()) {
|
if (media) {
|
||||||
setMedia(*media);
|
setMedia(*media);
|
||||||
if (checked == MediaCheckResult::HasTimeToLive) {
|
if (checked == MediaCheckResult::HasTimeToLive) {
|
||||||
media->match([&](const MTPDmessageMediaPhoto &media) {
|
media->match([&](const MTPDmessageMediaPhoto &media) {
|
||||||
auto time = media.vttl_seconds()->v;
|
auto time = media.vttl_seconds()->v;
|
||||||
setAyuHint("🕓 " + QString::number(time) + "s");
|
setAyuHint(formatTTL(time));
|
||||||
}, [&](const MTPDmessageMediaDocument &media) {
|
}, [&](const MTPDmessageMediaDocument &media) {
|
||||||
auto time = media.vttl_seconds()->v;
|
auto time = media.vttl_seconds()->v;
|
||||||
setAyuHint("🕓 " + QString::number(time) + "s");
|
setAyuHint(formatTTL(time));
|
||||||
}, [&](const MTPDmessageMediaWebPage &media) {
|
}, [&](const MTPDmessageMediaWebPage &media) {
|
||||||
}, [&](const MTPDmessageMediaGame &media) {
|
}, [&](const MTPDmessageMediaGame &media) {
|
||||||
}, [&](const MTPDmessageMediaInvoice &media) {
|
}, [&](const MTPDmessageMediaInvoice &media) {
|
||||||
|
|
|
@ -1499,24 +1499,21 @@ void VoiceRecordBar::stopRecording(StopType type) {
|
||||||
const auto duration = Duration(data.samples);
|
const auto duration = Duration(data.samples);
|
||||||
|
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
if (type == StopType::Send)
|
if (type == StopType::Send) {
|
||||||
{
|
if (settings->voiceConfirmation) {
|
||||||
auto sendVoiceCallback = [=, this]
|
auto sendVoiceCallback = [=, this]
|
||||||
{
|
{
|
||||||
_sendVoiceRequests.fire({data.bytes, data.waveform, duration});
|
_sendVoiceRequests.fire({data.bytes, data.waveform, duration});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (settings->voiceConfirmation)
|
|
||||||
{
|
|
||||||
Ui::show(AyuUi::MakeConfirmBox({
|
Ui::show(AyuUi::MakeConfirmBox({
|
||||||
.text = tr::ayu_ConfirmationVoice(),
|
.text = tr::ayu_ConfirmationVoice(),
|
||||||
.confirmed = sendVoiceCallback,
|
.confirmed = sendVoiceCallback,
|
||||||
.confirmText = tr::lng_send_button()
|
.confirmText = tr::lng_send_button()
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
_sendVoiceRequests.fire({data.bytes, data.waveform, duration});
|
||||||
sendVoiceCallback();
|
|
||||||
}
|
}
|
||||||
} else if (type == StopType::Listen) {
|
} else if (type == StopType::Listen) {
|
||||||
_listen = std::make_unique<ListenWrap>(
|
_listen = std::make_unique<ListenWrap>(
|
||||||
|
@ -1589,27 +1586,30 @@ void VoiceRecordBar::requestToSendWithOptions(Api::SendOptions options) {
|
||||||
const auto data = _listen->data();
|
const auto data = _listen->data();
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
auto sendVoiceCallback = [=, this]
|
if (settings->voiceConfirmation) {
|
||||||
{
|
auto sendVoiceCallback = [=, this]
|
||||||
_sendVoiceRequests.fire({
|
{
|
||||||
data->bytes,
|
_sendVoiceRequests.fire({
|
||||||
data->waveform,
|
data->bytes,
|
||||||
Duration(data->samples),
|
data->waveform,
|
||||||
options
|
Duration(data->samples),
|
||||||
});
|
options
|
||||||
};
|
});
|
||||||
|
};
|
||||||
|
|
||||||
if (settings->voiceConfirmation)
|
|
||||||
{
|
|
||||||
Ui::show(AyuUi::MakeConfirmBox({
|
Ui::show(AyuUi::MakeConfirmBox({
|
||||||
.text = tr::ayu_ConfirmationVoice(),
|
.text = tr::ayu_ConfirmationVoice(),
|
||||||
.confirmed = sendVoiceCallback,
|
.confirmed = sendVoiceCallback,
|
||||||
.confirmText = tr::lng_send_button()
|
.confirmText = tr::lng_send_button()
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
_sendVoiceRequests.fire({
|
||||||
sendVoiceCallback();
|
data->bytes,
|
||||||
|
data->waveform,
|
||||||
|
Duration(data->samples),
|
||||||
|
options
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1428,7 +1428,7 @@ Element *Element::previousInBlocks() const {
|
||||||
|
|
||||||
Element *Element::previousDisplayedInBlocks() const {
|
Element *Element::previousDisplayedInBlocks() const {
|
||||||
auto result = previousInBlocks();
|
auto result = previousInBlocks();
|
||||||
while (result && (result->data()->isEmpty() || result->isHidden() || result->data()->isLocal())) {
|
while (result && (result->data()->isEmpty() || result->isHidden())) {
|
||||||
result = result->previousInBlocks();
|
result = result->previousInBlocks();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -1449,7 +1449,7 @@ Element *Element::nextInBlocks() const {
|
||||||
|
|
||||||
Element *Element::nextDisplayedInBlocks() const {
|
Element *Element::nextDisplayedInBlocks() const {
|
||||||
auto result = nextInBlocks();
|
auto result = nextInBlocks();
|
||||||
while (result && (result->data()->isEmpty() || result->isHidden() || result->data()->isLocal())) {
|
while (result && (result->data()->isEmpty() || result->isHidden())) {
|
||||||
result = result->nextInBlocks();
|
result = result->nextInBlocks();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Add table
Reference in a new issue