mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-29 08:47:52 +00:00
Compare commits
6 Commits
dev
...
dev-bleizix
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a3723a7ee | |||
| 48ec267f7f | |||
| 852f3b2359 | |||
| 8584c8daff | |||
| 1d9af5bafb | |||
| 1c9278d050 |
@@ -652,6 +652,22 @@ QString FormatReadDate(TimeId date, const QDateTime &now) {
|
|||||||
const auto parsed = base::unixtime::parse(date);
|
const auto parsed = base::unixtime::parse(date);
|
||||||
const auto readDate = parsed.date();
|
const auto readDate = parsed.date();
|
||||||
const auto nowDate = now.date();
|
const auto nowDate = now.date();
|
||||||
|
|
||||||
|
if (readDate.year() < nowDate.year()) {
|
||||||
|
return tr::lng_mediaview_date_time(
|
||||||
|
tr::now,
|
||||||
|
lt_date,
|
||||||
|
tr::lng_month_day_year(
|
||||||
|
tr::now,
|
||||||
|
lt_month,
|
||||||
|
Lang::MonthDay(readDate.month())(tr::now),
|
||||||
|
lt_day,
|
||||||
|
QString::number(readDate.day()),
|
||||||
|
lt_year,
|
||||||
|
QString::number(readDate.year())),
|
||||||
|
lt_time,
|
||||||
|
QLocale().toString(parsed.time(), "HH:mm:ss"));
|
||||||
|
}
|
||||||
if (readDate == nowDate) {
|
if (readDate == nowDate) {
|
||||||
return tr::lng_mediaview_today(
|
return tr::lng_mediaview_today(
|
||||||
tr::now,
|
tr::now,
|
||||||
|
|||||||
@@ -38,8 +38,7 @@ bool isForwarding(const PeerId &id) {
|
|||||||
return state.state != ForwardState::State::Finished
|
return state.state != ForwardState::State::Finished
|
||||||
&& state.currentChunk < state.totalChunks
|
&& state.currentChunk < state.totalChunks
|
||||||
&& !state.stopRequested
|
&& !state.stopRequested
|
||||||
&& state.totalChunks
|
&& (state.totalChunks && state.totalMessages || state.state == ForwardState::State::Downloading);
|
||||||
&& state.totalMessages;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -85,7 +84,7 @@ std::pair<QString, QString> stateName(const PeerId &id) {
|
|||||||
if (state->state == ForwardState::State::Preparing) {
|
if (state->state == ForwardState::State::Preparing) {
|
||||||
status = tr::ayu_AyuForwardStatusPreparing(tr::now);
|
status = tr::ayu_AyuForwardStatusPreparing(tr::now);
|
||||||
} else if (state->state == ForwardState::State::Downloading) {
|
} else if (state->state == ForwardState::State::Downloading) {
|
||||||
status = tr::ayu_AyuForwardStatusLoadingMedia(tr::now);
|
return std::make_pair(tr::ayu_AyuForwardStatusLoadingMedia(tr::now), "");
|
||||||
} else if (state->state == ForwardState::State::Sending) {
|
} else if (state->state == ForwardState::State::Sending) {
|
||||||
status = tr::ayu_AyuForwardStatusForwarding(tr::now);
|
status = tr::ayu_AyuForwardStatusForwarding(tr::now);
|
||||||
} else {
|
} else {
|
||||||
@@ -367,6 +366,7 @@ void forwardMessages(
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto message = Api::MessageToSend(Api::SendAction(session->data().history(peer->id)));
|
auto message = Api::MessageToSend(Api::SendAction(session->data().history(peer->id)));
|
||||||
|
message.action.options.invertCaption = item->invertMedia();
|
||||||
message.action.replyTo = action.replyTo;
|
message.action.replyTo = action.replyTo;
|
||||||
|
|
||||||
if (draft.options != Data::ForwardOptions::NoNamesAndCaptions) {
|
if (draft.options != Data::ForwardOptions::NoNamesAndCaptions) {
|
||||||
|
|||||||
@@ -85,6 +85,17 @@ QString filePath(not_null<Main::Session*> session, const Data::Media *media) {
|
|||||||
return pathForSave(session) + "round_" + QString::number(document->getDC()) + "_" +
|
return pathForSave(session) + "round_" + QString::number(document->getDC()) + "_" +
|
||||||
QString::number(document->id) + ".mp4";
|
QString::number(document->id) + ".mp4";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// media without any file name
|
||||||
|
if (document->isGifv()) {
|
||||||
|
return pathForSave(session) + "gif_" + QString::number(document->getDC()) + "_" +
|
||||||
|
QString::number(document->id) + ".gif";
|
||||||
|
}
|
||||||
|
if (document->isVideoFile()) {
|
||||||
|
return pathForSave(session) + "video_" + QString::number(document->getDC()) + "_" +
|
||||||
|
QString::number(document->id) + ".mp4";
|
||||||
|
}
|
||||||
} else if (const auto photo = media->photo()) {
|
} else if (const auto photo = media->photo()) {
|
||||||
return pathForSave(session) + QString::number(photo->getDC()) + "_" + QString::number(photo->id) + ".jpg";
|
return pathForSave(session) + QString::number(photo->getDC()) + "_" + QString::number(photo->id) + ".jpg";
|
||||||
}
|
}
|
||||||
@@ -140,9 +151,8 @@ void loadDocumentSync(not_null<Main::Session*> session, DocumentData *data, not_
|
|||||||
{
|
{
|
||||||
data->save(Data::FileOriginMessage(item->fullId()), path);
|
data->save(Data::FileOriginMessage(item->fullId()), path);
|
||||||
|
|
||||||
rpl::single() | rpl::then(
|
|
||||||
session->downloaderTaskFinished()
|
session->downloaderTaskFinished() | rpl::filter([&]
|
||||||
) | rpl::filter([&]
|
|
||||||
{
|
{
|
||||||
return data->status == FileDownloadFailed || fileSize(item) == data->size;
|
return data->status == FileDownloadFailed || fileSize(item) == data->size;
|
||||||
}) | rpl::start_with_next([&]() mutable
|
}) | rpl::start_with_next([&]() mutable
|
||||||
@@ -290,13 +300,13 @@ void sendDocumentSync(not_null<Main::Session*> session,
|
|||||||
SendMediaType type,
|
SendMediaType type,
|
||||||
TextWithTags &&caption,
|
TextWithTags &&caption,
|
||||||
const Api::SendAction &action) {
|
const Api::SendAction &action) {
|
||||||
|
|
||||||
auto groupId = std::make_shared<SendingAlbum>();
|
auto groupId = std::make_shared<SendingAlbum>();
|
||||||
groupId->groupId = base::RandomValue<uint64>();
|
groupId->groupId = base::RandomValue<uint64>();
|
||||||
|
|
||||||
crl::on_main([=, lst = std::move(group.list), caption = std::move(caption)]() mutable
|
crl::on_main([=, lst = std::move(group.list), caption = std::move(caption)]() mutable
|
||||||
{
|
{
|
||||||
session->api().sendFiles(std::move(lst), type, std::move(caption), groupId, action);
|
auto size = lst.files.size();
|
||||||
|
session->api().sendFiles(std::move(lst), type, std::move(caption), size > 1 ? groupId : nullptr, action);
|
||||||
});
|
});
|
||||||
|
|
||||||
waitForMsgSync(session, action);
|
waitForMsgSync(session, action);
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ Cover GetCurrentCover(
|
|||||||
};
|
};
|
||||||
if (const auto normal = dataMedia->thumbnail()) {
|
if (const auto normal = dataMedia->thumbnail()) {
|
||||||
return {
|
return {
|
||||||
.pixToDraw = normal->pixSingle(scaled(normal), args),
|
.pixToDraw = normal->pixNoCache(scaled(normal), args),
|
||||||
.pixToBg = normal->pix(),
|
.pixToBg = normal->pixNoCache(),
|
||||||
.noCover = false
|
.noCover = false
|
||||||
};
|
};
|
||||||
} /*else if (const auto blurred = dataMedia->thumbnailInline()) {
|
} /*else if (const auto blurred = dataMedia->thumbnailInline()) {
|
||||||
|
|||||||
@@ -78,15 +78,13 @@ void SetupGhostModeToggle(not_null<Ui::VerticalLayout*> container) {
|
|||||||
AddCollapsibleToggle(container, tr::ayu_GhostModeToggle(), checkboxes, true);
|
AddCollapsibleToggle(container, tr::ayu_GhostModeToggle(), checkboxes, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupGhostEssentials(not_null<Ui::VerticalLayout*> container) {
|
void SetupGhostEssentials(
|
||||||
auto *settings = &AyuSettings::getInstance();
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
not_null<AyuSettings::AyuGramSettings*> settings,
|
||||||
|
not_null<rpl::variable<bool>*> markReadAfterActionVal,
|
||||||
|
not_null<rpl::variable<bool>*> useScheduledMessagesVal) {
|
||||||
SetupGhostModeToggle(container);
|
SetupGhostModeToggle(container);
|
||||||
|
|
||||||
auto markReadAfterActionVal = container->lifetime().make_state<rpl::variable<bool>>(
|
|
||||||
settings->markReadAfterAction);
|
|
||||||
auto useScheduledMessagesVal = container->lifetime().make_state<rpl::variable<
|
|
||||||
bool>>(settings->useScheduledMessages);
|
|
||||||
|
|
||||||
AddButtonWithIcon(
|
AddButtonWithIcon(
|
||||||
container,
|
container,
|
||||||
@@ -115,14 +113,11 @@ void SetupGhostEssentials(not_null<Ui::VerticalLayout*> container) {
|
|||||||
AddDividerText(container, tr::ayu_MarkReadAfterActionDescription());
|
AddDividerText(container, tr::ayu_MarkReadAfterActionDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupScheduleMessages(not_null<Ui::VerticalLayout*> container) {
|
void SetupScheduleMessages(
|
||||||
auto *settings = &AyuSettings::getInstance();
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
not_null<AyuSettings::AyuGramSettings*> settings,
|
||||||
auto markReadAfterActionVal = container->lifetime().make_state<rpl::variable<bool>>(
|
not_null<rpl::variable<bool>*> markReadAfterActionVal,
|
||||||
settings->markReadAfterAction);
|
not_null<rpl::variable<bool>*> useScheduledMessagesVal) {
|
||||||
auto useScheduledMessagesVal = container->lifetime().make_state<rpl::variable<
|
|
||||||
bool>>(settings->useScheduledMessages);
|
|
||||||
|
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
AddButtonWithIcon(
|
AddButtonWithIcon(
|
||||||
container,
|
container,
|
||||||
@@ -290,11 +285,17 @@ void SetupOther(not_null<Ui::VerticalLayout*> container) {
|
|||||||
|
|
||||||
void AyuGhost::setupContent(not_null<Window::SessionController*> controller) {
|
void AyuGhost::setupContent(not_null<Window::SessionController*> controller) {
|
||||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||||
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
|
auto markReadAfterActionVal = content->lifetime().make_state<rpl::variable<bool>>(
|
||||||
|
settings->markReadAfterAction);
|
||||||
|
auto useScheduledMessagesVal = content->lifetime().make_state<rpl::variable<bool>>(
|
||||||
|
settings->useScheduledMessages);
|
||||||
|
|
||||||
AddSkip(content);
|
AddSkip(content);
|
||||||
|
|
||||||
SetupGhostEssentials(content);
|
SetupGhostEssentials(content, settings, markReadAfterActionVal, useScheduledMessagesVal);
|
||||||
SetupScheduleMessages(content);
|
SetupScheduleMessages(content, settings, markReadAfterActionVal, useScheduledMessagesVal);
|
||||||
SetupSendWithoutSound(content);
|
SetupSendWithoutSound(content);
|
||||||
|
|
||||||
AddSkip(content);
|
AddSkip(content);
|
||||||
|
|||||||
@@ -182,6 +182,24 @@ void SetupQoLToggles(not_null<Ui::VerticalLayout*> container, not_null<Window::S
|
|||||||
|
|
||||||
AddCollapsibleToggle(container, tr::ayu_DisableSimilarChannels(), checkboxes, true);
|
AddCollapsibleToggle(container, tr::ayu_DisableSimilarChannels(), checkboxes, true);
|
||||||
|
|
||||||
|
|
||||||
|
AddButtonWithIcon(
|
||||||
|
container,
|
||||||
|
tr::ayu_DisableNotificationsDelay(),
|
||||||
|
st::settingsButtonNoIcon
|
||||||
|
)->toggleOn(
|
||||||
|
rpl::single(settings->disableNotificationsDelay)
|
||||||
|
)->toggledValue(
|
||||||
|
) | rpl::filter([=](bool enabled)
|
||||||
|
{
|
||||||
|
return (enabled != settings->disableNotificationsDelay);
|
||||||
|
}) | start_with_next([=](bool enabled)
|
||||||
|
{
|
||||||
|
AyuSettings::set_disableNotificationsDelay(enabled);
|
||||||
|
AyuSettings::save();
|
||||||
|
},
|
||||||
|
container->lifetime());
|
||||||
|
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
AddDivider(container);
|
AddDivider(container);
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
|
|||||||
@@ -917,7 +917,7 @@ void Cover::setupSavedMusic() {
|
|||||||
dispatchToMainThread(
|
dispatchToMainThread(
|
||||||
[=]
|
[=]
|
||||||
{
|
{
|
||||||
if (const auto strong = weak.get()) {
|
if (const auto strong = weak.get(); strong && strong->_musicButton) {
|
||||||
strong->_musicButton->show(anim::type::normal);
|
strong->_musicButton->show(anim::type::normal);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -928,15 +928,19 @@ void Cover::setupSavedMusic() {
|
|||||||
widthValue() | rpl::start_with_next(
|
widthValue() | rpl::start_with_next(
|
||||||
[=](int newWidth)
|
[=](int newWidth)
|
||||||
{
|
{
|
||||||
_musicButton->resizeToWidth(newWidth);
|
if (_musicButton) {
|
||||||
_musicButton->moveToLeft(0, _st.height, newWidth);
|
_musicButton->resizeToWidth(newWidth);
|
||||||
resize(width(), _st.height + _musicButton->height());
|
_musicButton->moveToLeft(0, _st.height, newWidth);
|
||||||
|
resize(width(), _st.height + _musicButton->height());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_musicButton->lifetime());
|
_musicButton->lifetime());
|
||||||
_musicButton->heightValue() | rpl::start_with_next(
|
_musicButton->heightValue() | rpl::start_with_next(
|
||||||
[=]
|
[=]
|
||||||
{
|
{
|
||||||
resize(width(), _st.height + _musicButton->height());
|
if (_musicButton) {
|
||||||
|
resize(width(), _st.height + _musicButton->height());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_musicButton->lifetime());
|
_musicButton->lifetime());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -45,7 +45,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"
|
||||||
|
|
||||||
#if __has_include(<gio/gio.hpp>)
|
#if __has_include(<gio/gio.hpp>)
|
||||||
#include <gio/gio.hpp>
|
#include <gio/gio.hpp>
|
||||||
@@ -397,6 +397,10 @@ void System::schedule(Data::ItemNotification notification) {
|
|||||||
thread->popNotification(notification);
|
thread->popNotification(notification);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (isMessageHidden(item)) {
|
||||||
|
thread->popNotification(notification);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto ready = (skip.value != SkipState::Unknown)
|
const auto ready = (skip.value != SkipState::Unknown)
|
||||||
&& item->notificationReady();
|
&& item->notificationReady();
|
||||||
|
|
||||||
|
|||||||
@@ -247,11 +247,6 @@ void Manager::showNextFromQueue() {
|
|||||||
auto queued = _queuedNotifications.front();
|
auto queued = _queuedNotifications.front();
|
||||||
_queuedNotifications.pop_front();
|
_queuedNotifications.pop_front();
|
||||||
|
|
||||||
if (queued.item && isMessageHidden(queued.item)) {
|
|
||||||
--count;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
subscribeToSession(&queued.history->session());
|
subscribeToSession(&queued.history->session());
|
||||||
_notifications.push_back(std::make_unique<Notification>(
|
_notifications.push_back(std::make_unique<Notification>(
|
||||||
this,
|
this,
|
||||||
|
|||||||
Reference in New Issue
Block a user