mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +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 "lang_auto.h"
|
||||
#include "apiwrap.h"
|
||||
#include "data/data_forum.h"
|
||||
#include "data/data_forum_topic.h"
|
||||
|
@ -222,4 +223,12 @@ void MarkAsReadThread(not_null<Data::Thread *> thread)
|
|||
if (thread->unreadReactions().has()) {
|
||||
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 MarkAsReadThread(not_null<Data::Thread *> thread);
|
||||
|
||||
QString formatTTL(int time);
|
||||
|
|
|
@ -491,26 +491,29 @@ void GifsListWidget::selectInlineResult(
|
|||
const auto preview = Data::VideoPreviewState(media.get());
|
||||
if (forceSend || (media && preview.loaded())) {
|
||||
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({
|
||||
.text = tr::ayu_ConfirmationGIF(),
|
||||
.confirmed = sendGIFCallback,
|
||||
.confirmText = tr::lng_send_button()
|
||||
}));
|
||||
.text = tr::ayu_ConfirmationGIF(),
|
||||
.confirmed = sendGIFCallback,
|
||||
.confirmText = tr::lng_send_button()
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
sendGIFCallback();
|
||||
else {
|
||||
_fileChosen.fire({
|
||||
.document = document,
|
||||
.options = options,
|
||||
.messageSendingFrom = messageSendingFrom(),
|
||||
});
|
||||
}
|
||||
} else if (!preview.usingThumbnail()) {
|
||||
if (preview.loading()) {
|
||||
|
|
|
@ -2292,22 +2292,6 @@ void Session::updateEditedMessage(const MTPMessage &data) {
|
|||
bool isDocument = media && media->document();
|
||||
|
||||
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:
|
||||
|
|
|
@ -72,6 +72,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
#include "ayu/utils/telegram_helpers.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
@ -235,7 +236,7 @@ std::unique_ptr<Data::Media> HistoryItem::CreateMedia(
|
|||
});
|
||||
}, [&](const MTPDmessageMediaDocument &media) -> Result {
|
||||
const auto document = media.vdocument();
|
||||
if (media.vttl_seconds()) {
|
||||
if (media.vttl_seconds() && false) { // AyuGram: show expiring messages
|
||||
LOG(("App Error: "
|
||||
"Unexpected MTPMessageMediaDocument "
|
||||
"with ttl_seconds in CreateMedia."));
|
||||
|
@ -336,15 +337,15 @@ HistoryItem::HistoryItem(
|
|||
applyTTL(data);
|
||||
} else {
|
||||
createComponents(data);
|
||||
if (const auto media = data.vmedia()) {
|
||||
if (media) {
|
||||
setMedia(*media);
|
||||
if (checked == MediaCheckResult::HasTimeToLive) {
|
||||
media->match([&](const MTPDmessageMediaPhoto &media) {
|
||||
auto time = media.vttl_seconds()->v;
|
||||
setAyuHint("🕓 " + QString::number(time) + "s");
|
||||
setAyuHint(formatTTL(time));
|
||||
}, [&](const MTPDmessageMediaDocument &media) {
|
||||
auto time = media.vttl_seconds()->v;
|
||||
setAyuHint("🕓 " + QString::number(time) + "s");
|
||||
setAyuHint(formatTTL(time));
|
||||
}, [&](const MTPDmessageMediaWebPage &media) {
|
||||
}, [&](const MTPDmessageMediaGame &media) {
|
||||
}, [&](const MTPDmessageMediaInvoice &media) {
|
||||
|
|
|
@ -1499,24 +1499,21 @@ void VoiceRecordBar::stopRecording(StopType type) {
|
|||
const auto duration = Duration(data.samples);
|
||||
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
if (type == StopType::Send)
|
||||
{
|
||||
auto sendVoiceCallback = [=, this]
|
||||
{
|
||||
_sendVoiceRequests.fire({data.bytes, data.waveform, duration});
|
||||
};
|
||||
if (type == StopType::Send) {
|
||||
if (settings->voiceConfirmation) {
|
||||
auto sendVoiceCallback = [=, this]
|
||||
{
|
||||
_sendVoiceRequests.fire({data.bytes, data.waveform, duration});
|
||||
};
|
||||
|
||||
if (settings->voiceConfirmation)
|
||||
{
|
||||
Ui::show(AyuUi::MakeConfirmBox({
|
||||
.text = tr::ayu_ConfirmationVoice(),
|
||||
.confirmed = sendVoiceCallback,
|
||||
.confirmText = tr::lng_send_button()
|
||||
}));
|
||||
.text = tr::ayu_ConfirmationVoice(),
|
||||
.confirmed = sendVoiceCallback,
|
||||
.confirmText = tr::lng_send_button()
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
sendVoiceCallback();
|
||||
else {
|
||||
_sendVoiceRequests.fire({data.bytes, data.waveform, duration});
|
||||
}
|
||||
} else if (type == StopType::Listen) {
|
||||
_listen = std::make_unique<ListenWrap>(
|
||||
|
@ -1589,27 +1586,30 @@ void VoiceRecordBar::requestToSendWithOptions(Api::SendOptions options) {
|
|||
const auto data = _listen->data();
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
|
||||
auto sendVoiceCallback = [=, this]
|
||||
{
|
||||
_sendVoiceRequests.fire({
|
||||
data->bytes,
|
||||
data->waveform,
|
||||
Duration(data->samples),
|
||||
options
|
||||
});
|
||||
};
|
||||
if (settings->voiceConfirmation) {
|
||||
auto sendVoiceCallback = [=, this]
|
||||
{
|
||||
_sendVoiceRequests.fire({
|
||||
data->bytes,
|
||||
data->waveform,
|
||||
Duration(data->samples),
|
||||
options
|
||||
});
|
||||
};
|
||||
|
||||
if (settings->voiceConfirmation)
|
||||
{
|
||||
Ui::show(AyuUi::MakeConfirmBox({
|
||||
.text = tr::ayu_ConfirmationVoice(),
|
||||
.confirmed = sendVoiceCallback,
|
||||
.confirmText = tr::lng_send_button()
|
||||
}));
|
||||
.text = tr::ayu_ConfirmationVoice(),
|
||||
.confirmed = sendVoiceCallback,
|
||||
.confirmText = tr::lng_send_button()
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
sendVoiceCallback();
|
||||
else {
|
||||
_sendVoiceRequests.fire({
|
||||
data->bytes,
|
||||
data->waveform,
|
||||
Duration(data->samples),
|
||||
options
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1428,7 +1428,7 @@ Element *Element::previousInBlocks() const {
|
|||
|
||||
Element *Element::previousDisplayedInBlocks() const {
|
||||
auto result = previousInBlocks();
|
||||
while (result && (result->data()->isEmpty() || result->isHidden() || result->data()->isLocal())) {
|
||||
while (result && (result->data()->isEmpty() || result->isHidden())) {
|
||||
result = result->previousInBlocks();
|
||||
}
|
||||
return result;
|
||||
|
@ -1449,7 +1449,7 @@ Element *Element::nextInBlocks() const {
|
|||
|
||||
Element *Element::nextDisplayedInBlocks() const {
|
||||
auto result = nextInBlocks();
|
||||
while (result && (result->data()->isEmpty() || result->isHidden() || result->data()->isLocal())) {
|
||||
while (result && (result->data()->isEmpty() || result->isHidden())) {
|
||||
result = result->nextInBlocks();
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Add table
Reference in a new issue