2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 09:05:14 +00:00

Updated TDesktop sources to 2.2

This commit is contained in:
RadRussianRus
2020-07-30 09:23:07 +03:00
249 changed files with 9546 additions and 2470 deletions

View File

@@ -31,6 +31,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/application.h"
#include "core/core_settings.h"
#include "base/unixtime.h"
#include "ui/layers/generic_box.h"
#include "ui/text/text_utilities.h"
#include "ui/delayed_activation.h"
#include "boxes/calendar_box.h"
#include "boxes/sticker_set_box.h" // requestAttachedStickerSets.
#include "boxes/confirm_box.h" // requestAttachedStickerSets.
@@ -42,10 +45,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_account.h"
#include "main/main_session_settings.h"
#include "apiwrap.h"
#include "api/api_chat_invite.h"
#include "api/api_global_privacy.h"
#include "support/support_helper.h"
#include "facades.h"
#include "styles/style_window.h"
#include "styles/style_dialogs.h"
#include "styles/style_layers.h" // st::boxLabel
namespace Window {
namespace {
@@ -54,6 +60,12 @@ constexpr auto kMaxChatEntryHistorySize = 50;
} // namespace
void ActivateWindow(not_null<SessionController*> controller) {
const auto window = controller->widget();
window->activateWindow();
Ui::ActivateWindowDelayed(window);
}
DateClickHandler::DateClickHandler(Dialogs::Key chat, QDate date)
: _chat(chat)
, _date(date) {
@@ -127,7 +139,8 @@ SessionController::SessionController(
, _tabbedSelector(
std::make_unique<ChatHelpers::TabbedSelector>(
_window->widget(),
this)) {
this))
, _invitePeekTimer([=] { checkInvitePeek(); }) {
init();
if (Media::Player::instance()->pauseGifByRoundVideo()) {
@@ -159,9 +172,43 @@ SessionController::SessionController(
});
}, lifetime());
session->api().globalPrivacy().suggestArchiveAndMute(
) | rpl::take(1) | rpl::start_with_next([=] {
session->api().globalPrivacy().reload(crl::guard(this, [=] {
if (!session->api().globalPrivacy().archiveAndMuteCurrent()) {
suggestArchiveAndMute();
}
}));
}, _lifetime);
session->addWindow(this);
}
void SessionController::suggestArchiveAndMute() {
const auto weak = base::make_weak(this);
_window->show(Box([=](not_null<Ui::GenericBox*> box) {
box->setTitle(tr::lng_suggest_hide_new_title());
box->addRow(object_ptr<Ui::FlatLabel>(
box,
tr::lng_suggest_hide_new_about(Ui::Text::RichLangValue),
st::boxLabel));
box->addButton(tr::lng_suggest_hide_new_to_settings(), [=] {
showSettings(Settings::Type::PrivacySecurity);
});
box->setCloseByOutsideClick(false);
box->boxClosing(
) | rpl::start_with_next([=] {
crl::on_main(weak, [=] {
auto &privacy = session().api().globalPrivacy();
privacy.dismissArchiveAndMuteSuggestion();
});
}, box->lifetime());
box->addButton(tr::lng_cancel(), [=] {
box->closeBox();
});
}));
}
not_null<::MainWindow*> SessionController::widget() const {
return _window->widget();
}
@@ -331,6 +378,7 @@ void SessionController::setActiveChatEntry(Dialogs::RowDescriptor row) {
const auto now = row.key.history();
if (was && was != now) {
was->setFakeUnreadWhileOpened(false);
_invitePeekTimer.cancel();
}
_activeChatEntry = row;
if (now) {
@@ -339,6 +387,30 @@ void SessionController::setActiveChatEntry(Dialogs::RowDescriptor row) {
if (session().supportMode()) {
pushToChatEntryHistory(row);
}
checkInvitePeek();
}
void SessionController::checkInvitePeek() {
const auto history = activeChatCurrent().history();
if (!history) {
return;
}
const auto channel = history->peer->asChannel();
if (!channel) {
return;
}
const auto expires = channel->invitePeekExpires();
if (!expires) {
return;
}
const auto now = base::unixtime::now();
if (expires > now) {
_invitePeekTimer.callOnce((expires - now) * crl::time(1000));
return;
}
const auto hash = channel->invitePeekHash();
channel->clearInvitePeek();
Api::CheckChatInvite(this, hash, channel);
}
void SessionController::resetFakeUnreadWhileOpened() {