Skip to content

Commit

Permalink
fix: a bunch of useful fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyZavar committed Jul 2, 2024
1 parent c4e1e84 commit a851beb
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 17 deletions.
19 changes: 12 additions & 7 deletions Telegram/SourceFiles/apiwrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1352,27 +1352,30 @@ void ApiWrap::migrateFail(not_null<PeerData*> peer, const QString &error) {

void ApiWrap::markContentsRead(
const base::flat_set<not_null<HistoryItem*>> &items) {
const auto settings = &AyuSettings::getInstance();

auto markedIds = QVector<MTPint>();
auto channelMarkedIds = base::flat_map<
not_null<ChannelData*>,
QVector<MTPint>>();
markedIds.reserve(items.size());
for (const auto &item : items) {
const auto passthrough = (item->isUnreadMention() || item->hasUnreadReaction()) && !item->isUnreadMedia();

if (!item->markContentsRead(true) || !item->isRegular()) {
continue;
}

if (!settings->sendReadMessages && !passthrough) {
continue;
}

if (const auto channel = item->history()->peer->asChannel()) {
channelMarkedIds[channel].push_back(MTP_int(item->id));
} else {
markedIds.push_back(MTP_int(item->id));
}
}

const auto settings = &AyuSettings::getInstance();
if (!settings->sendReadMessages) {
return;
}

if (!markedIds.isEmpty()) {
request(MTPmessages_ReadMessageContents(
MTP_vector<MTPint>(markedIds)
Expand All @@ -1389,12 +1392,14 @@ void ApiWrap::markContentsRead(
}

void ApiWrap::markContentsRead(not_null<HistoryItem*> item) {
const auto passthrough = (item->isUnreadMention() || item->hasUnreadReaction()) && !item->isUnreadMedia();

if (!item->markContentsRead(true) || !item->isRegular()) {
return;
}

const auto settings = &AyuSettings::getInstance();
if (!settings->sendReadMessages) {
if (!settings->sendReadMessages && !passthrough) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,21 @@ void enable() {
auto handle = Core::App().activeWindow()->widget()->psHwnd();
SetWindowDisplayAffinity(handle, WDA_EXCLUDEFROMCAPTURE);

Core::App().enumerateWindows([&](not_null<Window::Controller*> w) {
SetWindowDisplayAffinity(w->widget()->psHwnd(), WDA_EXCLUDEFROMCAPTURE);
});

isEnabledVal = true;
}

void disable() {
auto handle = Core::App().activeWindow()->widget()->psHwnd();
SetWindowDisplayAffinity(handle, WDA_NONE);

Core::App().enumerateWindows([&](not_null<Window::Controller*> w) {
SetWindowDisplayAffinity(w->widget()->psHwnd(), WDA_NONE);
});

isEnabledVal = false;
}

Expand Down
6 changes: 3 additions & 3 deletions Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,10 @@ QString getMediaDC(not_null<HistoryItem*> message) {
return {};
}

QString getUserDC(not_null<UserData*> user) {
if (user->hasUserpic()) {
QString getPeerDC(not_null<PeerData*> peer) {
if (peer->hasUserpic()) {
const auto dc = v::match(
user->userpicLocation().file().data,
peer->userpicLocation().file().data,
[&](const StorageFileLocation &data)
{
return data.dcId();
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/ayu/utils/telegram_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ QString getMediaName(not_null<HistoryItem*> message);
QString getMediaResolution(not_null<HistoryItem*> message);
QString getMediaDC(not_null<HistoryItem*> message);

QString getUserDC(not_null<UserData*> user);
QString getPeerDC(not_null<PeerData*> peer);

int getScheduleTime(int64 sumSize);

Expand Down
18 changes: 18 additions & 0 deletions Telegram/SourceFiles/boxes/sticker_set_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ For license and copyright information please follow this link:

// AyuGram includes
#include "ayu/utils/telegram_helpers.h"
#include "styles/style_ayu_styles.h"
#include "window/window_session_controller.h"
#include "data/data_user.h"

Expand Down Expand Up @@ -1392,6 +1393,18 @@ void StickerSetBox::Inner::paintSticker(
(_singleSize.width() - size.width()) / 2,
(_singleSize.height() - size.height()) / 2);
auto lottieFrame = QImage();

if (sticker->setType == Data::StickersType::Stickers) {
QPainterPath path;
path.addRoundedRect(QRectF(ppos, size), st::stickerRoundingSize, st::stickerRoundingSize);

p.save();

p.setRenderHint(QPainter::Antialiasing, true);
p.setClipPath(path);
p.setRenderHint(QPainter::Antialiasing, false);
}

if (element.emoji) {
element.emoji->paint(p, {
.textColor = st::windowFg->c,
Expand Down Expand Up @@ -1425,6 +1438,11 @@ void StickerSetBox::Inner::paintSticker(
QRect(ppos, size),
_pathGradient.get());
}

if (sticker->setType == Data::StickersType::Stickers) {
p.restore();
}

if (premium) {
_premiumMark.paint(
p,
Expand Down
8 changes: 8 additions & 0 deletions Telegram/SourceFiles/core/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ For license and copyright information please follow this link:
#include <QtGui/QScreen>
#include <QtGui/QWindow>

// AyuGram includes
#include "ayu/features/streamer_mode/streamer_mode.h"


namespace Core {
namespace {

Expand Down Expand Up @@ -505,6 +509,10 @@ void Application::processCreatedWindow(
not_null<Window::Controller*> window) {
window->openInMediaViewRequests(
) | rpl::start_to_stream(_openInMediaViewRequests, window->lifetime());

if (AyuFeatures::StreamerMode::isEnabled()) {
AyuFeatures::StreamerMode::hideWidgetWindow(window->widget());
}
}

void Application::startMediaView() {
Expand Down
5 changes: 3 additions & 2 deletions Telegram/SourceFiles/core/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,9 @@ class Application final : public QObject {

void preventOrInvoke(Fn<void()> &&callback);

void enumerateWindows(
Fn<void(not_null<Window::Controller*>)> callback) const;

// Global runtime variables.
void setScreenIsLocked(bool locked);
bool screenIsLocked() const;
Expand Down Expand Up @@ -364,8 +367,6 @@ class Application final : public QObject {
void updateWindowTitles();
void setLastActiveWindow(Window::Controller *window);
void showAccount(not_null<Main::Account*> account);
void enumerateWindows(
Fn<void(not_null<Window::Controller*>)> callback) const;
void processCreatedWindow(not_null<Window::Controller*> window);
void refreshApplicationIcon(Main::Session *session);

Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/core/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ void Launcher::processArguments() {
{ "-tosettings" , KeyFormat::NoValues },
{ "-startintray" , KeyFormat::NoValues },
{ "-quit" , KeyFormat::NoValues },
{ "-ghost" , KeyFormat::NoValues },
{ "-ghost" , KeyFormat::NoValues },
{ "-sendpath" , KeyFormat::AllLeftValues },
{ "-workdir" , KeyFormat::OneValue },
{ "--" , KeyFormat::OneValue },
Expand Down
7 changes: 5 additions & 2 deletions Telegram/SourceFiles/info/profile/info_profile_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
}

if (settings->showPeerId != 0) {
const auto dataCenter = getUserDC(user);
const auto dataCenter = getPeerDC(_peer);
const auto idLabel = dataCenter.isEmpty() ? QString("ID") : dataCenter;

auto idDrawableText = IDValue(
Expand Down Expand Up @@ -1277,14 +1277,17 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
}

if (settings->showPeerId != 0 && !_topic) {
const auto dataCenter = getPeerDC(_peer);
const auto idLabel = dataCenter.isEmpty() ? QString("ID") : dataCenter;

auto idDrawableText = IDValue(
_peer
) | rpl::map([](TextWithEntities &&text)
{
return Ui::Text::Code(text.text);
});
auto idInfo = addInfoOneLine(
rpl::single(QString("ID")),
idLabel,
std::move(idDrawableText),
tr::ayu_ContextCopyID(tr::now)
);
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/window/window_peer_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ void Filler::addJumpToBeginning() {
} else if (group && !chat) {
jumpToDate(controller->session().data().history(group), showPeerHistory);
} else if (chat && !topic) {
if (!chat->migrateFrom()) {
if (!chat->migrateFrom() && chat->availableMinId() == 1) {
showPeerHistory(chat, 1);
} else {
jumpToDate(controller->session().data().history(chat), showPeerHistory);
Expand Down

0 comments on commit a851beb

Please sign in to comment.