From 107dea085c5fddcb244245c1b6773f0eca60f653 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 00:05:27 +0400 Subject: [PATCH 01/37] Fix build for OS X 10.10-10.11. --- .../chat_helpers/field_autocomplete.h | 1 - .../SourceFiles/history/history_widget.cpp | 1 + .../SourceFiles/platform/mac/mac_touchbar.h | 19 +++++++++++++------ .../SourceFiles/platform/mac/mac_touchbar.mm | 18 +++++++++++------- .../platform/mac/main_window_mac.mm | 12 ++++++++++-- 5 files changed, 35 insertions(+), 16 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/field_autocomplete.h b/Telegram/SourceFiles/chat_helpers/field_autocomplete.h index 69127992c..94a7578f4 100644 --- a/Telegram/SourceFiles/chat_helpers/field_autocomplete.h +++ b/Telegram/SourceFiles/chat_helpers/field_autocomplete.h @@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/rp_widget.h" #include "base/timer.h" #include "base/object_ptr.h" -#include "data/stickers/data_stickers.h" namespace Ui { class ScrollArea; diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 89879b90b..1f0148fbb 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_scheduled_messages.h" #include "data/data_file_origin.h" #include "data/data_histories.h" +#include "data/stickers/data_stickers.h" #include "history/history.h" #include "history/history_item.h" #include "history/history_message.h" diff --git a/Telegram/SourceFiles/platform/mac/mac_touchbar.h b/Telegram/SourceFiles/platform/mac/mac_touchbar.h index 931face15..979e054e7 100644 --- a/Telegram/SourceFiles/platform/mac/mac_touchbar.h +++ b/Telegram/SourceFiles/platform/mac/mac_touchbar.h @@ -1,10 +1,13 @@ /* - This file is part of Telegram Desktop, - the official desktop application for the Telegram messaging service. +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. - For license and copyright information please follow this link: - https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL - */ +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#pragma once + +#ifndef OS_OSX #include "platform/platform_specific.h" #include "media/audio/media_audio.h" @@ -12,13 +15,15 @@ #import namespace Platform { + enum class TouchBarType { None, Main, AudioPlayer, AudioPlayerForce, }; -} // namespace + +} // namespace Platform @interface TouchBar : NSTouchBar @@ -31,3 +36,5 @@ enum class TouchBarType { - (void) showInputFieldItem:(bool)show; @end + +#endif // OS_OSX diff --git a/Telegram/SourceFiles/platform/mac/mac_touchbar.mm b/Telegram/SourceFiles/platform/mac/mac_touchbar.mm index 7ffdc970e..cf5c06f1d 100644 --- a/Telegram/SourceFiles/platform/mac/mac_touchbar.mm +++ b/Telegram/SourceFiles/platform/mac/mac_touchbar.mm @@ -1,13 +1,13 @@ /* - This file is part of Telegram Desktop, - the official desktop application for the Telegram messaging service. +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. - For license and copyright information please follow this link: - https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL - */ +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#include "platform/mac/mac_touchbar.h" -#import "mac_touchbar.h" -#import +#ifndef OS_OSX #include "api/api_sending.h" #include "apiwrap.h" @@ -49,6 +49,8 @@ #include "window/window_controller.h" #include "window/window_session_controller.h" +#import + NSImage *qt_mac_create_nsimage(const QPixmap &pm); namespace { @@ -1907,3 +1909,5 @@ void AppendEmojiPacks( } @end // @implementation TouchBar + +#endif // OS_OSX diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.mm b/Telegram/SourceFiles/platform/mac/main_window_mac.mm index 449fb0fbc..4f864f0a2 100644 --- a/Telegram/SourceFiles/platform/mac/main_window_mac.mm +++ b/Telegram/SourceFiles/platform/mac/main_window_mac.mm @@ -144,9 +144,9 @@ public: void didExitFullScreen(); bool clipboardHasText(); - +#ifndef OS_OSX TouchBar *_touchBar = nil; - +#endif // OS_OSX ~Private(); private: @@ -475,6 +475,7 @@ MainWindow::MainWindow(not_null controller) } void MainWindow::initTouchBar() { +#ifndef OS_OSX if (!IsMac10_13OrGreater()) { return; } @@ -502,14 +503,17 @@ void MainWindow::initTouchBar() { destroyCurrentTouchBar(); } }, lifetime()); +#endif // OS_OSX } void MainWindow::destroyCurrentTouchBar() { +#ifndef OS_OSX if (_private->_touchBar) { [_private->_touchBar setTouchBar:Platform::TouchBarType::None]; [_private->_touchBar release]; } _private->_touchBar = nil; +#endif // OS_OSX } void MainWindow::closeWithoutDestroy() { @@ -831,9 +835,13 @@ void MainWindow::updateGlobalMenuHook() { canCopy = list->canCopySelected(); canDelete = list->canDeleteSelected(); } + +#ifndef OS_OSX if (_private->_touchBar) { [_private->_touchBar showInputFieldItem:showTouchBarItem]; } +#endif // OS_OSX + App::wnd()->updateIsActive(); const auto logged = (sessionController() != nullptr); const auto inactive = !logged || controller().locked(); From 90af3d295b9dd6f2edca90b6a3dc8008d073c52b Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 30 Jun 2020 00:23:33 +0400 Subject: [PATCH 02/37] Always fallback to gtk icon theme To inherit icon theme even on WM-based environments --- Telegram/SourceFiles/platform/linux/linux_libs.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/linux_libs.cpp b/Telegram/SourceFiles/platform/linux/linux_libs.cpp index e0706f293..0d6a5bf1f 100644 --- a/Telegram/SourceFiles/platform/linux/linux_libs.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_libs.cpp @@ -253,11 +253,10 @@ void start() { // change the icon theme only if it isn't already set by a platformtheme plugin // if QT_QPA_PLATFORMTHEME=(gtk2|gtk3), then force-apply the icon theme - if ((((QIcon::themeName() == qstr("hicolor") // QGenericUnixTheme + if (((QIcon::themeName() == qstr("hicolor") // QGenericUnixTheme && QIcon::fallbackThemeName() == qstr("hicolor")) || (QIcon::themeName() == qstr("Adwaita") // QGnomeTheme && QIcon::fallbackThemeName() == qstr("gnome"))) - && DesktopEnvironment::IsGtkBased()) || IsGtkIntegrationForced()) { DEBUG_LOG(("Set GTK icon theme")); QIcon::setThemeName(gtkSetting("gtk-icon-theme-name")); From 87eaab15b5976d8a83c05bc6e124562aac9cabdd Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 11:02:44 +0400 Subject: [PATCH 03/37] Load filters before creating session on log in. --- .../SourceFiles/data/data_chat_filters.cpp | 72 +++++++++++-------- Telegram/SourceFiles/data/data_chat_filters.h | 3 + Telegram/SourceFiles/intro/intro_step.cpp | 23 +++++- Telegram/SourceFiles/intro/intro_step.h | 4 ++ Telegram/SourceFiles/main/main_account.cpp | 10 ++- Telegram/SourceFiles/main/main_account.h | 4 +- 6 files changed, 83 insertions(+), 33 deletions(-) diff --git a/Telegram/SourceFiles/data/data_chat_filters.cpp b/Telegram/SourceFiles/data/data_chat_filters.cpp index 00f56ed1c..8d5e01e97 100644 --- a/Telegram/SourceFiles/data/data_chat_filters.cpp +++ b/Telegram/SourceFiles/data/data_chat_filters.cpp @@ -216,7 +216,7 @@ bool ChatFilter::contains(not_null history) const { } ChatFilters::ChatFilters(not_null owner) : _owner(owner) { - load(); + crl::on_main(&owner->session(), [=] { load(); }); } ChatFilters::~ChatFilters() = default; @@ -232,6 +232,16 @@ not_null ChatFilters::chatsList(FilterId filterId) { return pointer.get(); } +void ChatFilters::setPreloaded(const QVector &result) { + _loadRequestId = -1; + received(result); + crl::on_main(&_owner->session(), [=] { + if (_loadRequestId == -1) { + _loadRequestId = 0; + } + }); +} + void ChatFilters::load() { load(false); } @@ -244,40 +254,44 @@ void ChatFilters::load(bool force) { api.request(_loadRequestId).cancel(); _loadRequestId = api.request(MTPmessages_GetDialogFilters( )).done([=](const MTPVector &result) { - auto position = 0; - auto changed = false; - for (const auto &filter : result.v) { - auto parsed = ChatFilter::FromTL(filter, _owner); - const auto b = begin(_list) + position, e = end(_list); - const auto i = ranges::find(b, e, parsed.id(), &ChatFilter::id); - if (i == e) { - applyInsert(std::move(parsed), position); - changed = true; - } else if (i == b) { - if (applyChange(*b, std::move(parsed))) { - changed = true; - } - } else { - std::swap(*i, *b); - applyChange(*b, std::move(parsed)); - changed = true; - } - ++position; - } - while (position < _list.size()) { - applyRemove(position); - changed = true; - } - if (changed || !_loaded) { - _loaded = true; - _listChanged.fire({}); - } + received(result.v); _loadRequestId = 0; }).fail([=](const RPCError &error) { _loadRequestId = 0; }).send(); } +void ChatFilters::received(const QVector &list) { + auto position = 0; + auto changed = false; + for (const auto &filter : list) { + auto parsed = ChatFilter::FromTL(filter, _owner); + const auto b = begin(_list) + position, e = end(_list); + const auto i = ranges::find(b, e, parsed.id(), &ChatFilter::id); + if (i == e) { + applyInsert(std::move(parsed), position); + changed = true; + } else if (i == b) { + if (applyChange(*b, std::move(parsed))) { + changed = true; + } + } else { + std::swap(*i, *b); + applyChange(*b, std::move(parsed)); + changed = true; + } + ++position; + } + while (position < _list.size()) { + applyRemove(position); + changed = true; + } + if (changed || !_loaded) { + _loaded = true; + _listChanged.fire({}); + } +} + void ChatFilters::apply(const MTPUpdate &update) { update.match([&](const MTPDupdateDialogFilter &data) { if (const auto filter = data.vfilter()) { diff --git a/Telegram/SourceFiles/data/data_chat_filters.h b/Telegram/SourceFiles/data/data_chat_filters.h index 04ced87a5..43cb0d581 100644 --- a/Telegram/SourceFiles/data/data_chat_filters.h +++ b/Telegram/SourceFiles/data/data_chat_filters.h @@ -95,6 +95,8 @@ public: explicit ChatFilters(not_null owner); ~ChatFilters(); + void setPreloaded(const QVector &result); + void load(); void apply(const MTPUpdate &update); void set(ChatFilter filter); @@ -125,6 +127,7 @@ public: private: void load(bool force); + void received(const QVector &list); bool applyOrder(const QVector &order); bool applyChange(ChatFilter &filter, ChatFilter &&updated); void applyInsert(ChatFilter filter, int position); diff --git a/Telegram/SourceFiles/intro/intro_step.cpp b/Telegram/SourceFiles/intro/intro_step.cpp index b87370bbc..ad5b818a2 100644 --- a/Telegram/SourceFiles/intro/intro_step.cpp +++ b/Telegram/SourceFiles/intro/intro_step.cpp @@ -27,6 +27,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/effects/slide_animation.h" #include "data/data_user.h" #include "data/data_auto_download.h" +#include "data/data_session.h" +#include "data/data_chat_filters.h" #include "window/window_controller.h" #include "window/themes/window_theme.h" #include "app.h" @@ -160,6 +162,18 @@ void Step::finish(const MTPUser &user, QImage &&photo) { } } + api().request(MTPmessages_GetDialogFilters( + )).done([=](const MTPVector &result) { + createSession(user, photo, result.v); + }).fail([=](const RPCError &error) { + createSession(user, photo, QVector()); + }).send(); +} + +void Step::createSession( + const MTPUser &user, + QImage photo, + const QVector &filters) { // Save the default language if we've suggested some other and user ignored it. const auto currentId = Lang::Current().id(); const auto defaultId = Lang::DefaultLanguageId(); @@ -168,12 +182,19 @@ void Step::finish(const MTPUser &user, QImage &&photo) { Lang::Current().switchToId(Lang::DefaultLanguage()); Local::writeLangPack(); } + + auto settings = std::make_unique(); + settings->setDialogsFiltersEnabled(!filters.isEmpty()); + const auto account = _account; - account->createSession(user); + account->createSession(user, std::move(settings)); // "this" is already deleted here by creating the main widget. account->local().writeMtpData(); auto &session = account->session(); + if (!filters.isEmpty()) { + session.data().chatsFilters().setPreloaded(filters); + } if (!photo.isNull()) { session.api().uploadPeerPhoto(session.user(), std::move(photo)); } diff --git a/Telegram/SourceFiles/intro/intro_step.h b/Telegram/SourceFiles/intro/intro_step.h index bc9548800..b98349a44 100644 --- a/Telegram/SourceFiles/intro/intro_step.h +++ b/Telegram/SourceFiles/intro/intro_step.h @@ -106,6 +106,10 @@ protected: return _data; } void finish(const MTPUser &user, QImage &&photo = QImage()); + void createSession( + const MTPUser &user, + QImage photo, + const QVector &filters); void goBack(); diff --git a/Telegram/SourceFiles/main/main_account.cpp b/Telegram/SourceFiles/main/main_account.cpp index c2e9958d4..a4b2eb8fb 100644 --- a/Telegram/SourceFiles/main/main_account.cpp +++ b/Telegram/SourceFiles/main/main_account.cpp @@ -131,8 +131,14 @@ uint64 Account::willHaveSessionUniqueId(MTP::Config *config) const { | (config && config->isTestMode() ? 0x0100'0000'0000'0000ULL : 0ULL); } -void Account::createSession(const MTPUser &user) { - createSession(user, QByteArray(), 0, std::make_unique()); +void Account::createSession( + const MTPUser &user, + std::unique_ptr settings) { + createSession( + user, + QByteArray(), + 0, + settings ? std::move(settings) : std::make_unique()); } void Account::createSession( diff --git a/Telegram/SourceFiles/main/main_account.h b/Telegram/SourceFiles/main/main_account.h index d63eab11a..8c14b1793 100644 --- a/Telegram/SourceFiles/main/main_account.h +++ b/Telegram/SourceFiles/main/main_account.h @@ -49,7 +49,9 @@ public: void start(std::unique_ptr config); [[nodiscard]] uint64 willHaveSessionUniqueId(MTP::Config *config) const; - void createSession(const MTPUser &user); + void createSession( + const MTPUser &user, + std::unique_ptr settings = nullptr); void createSession( UserId id, QByteArray serialized, From dfc1712043ab5a5115d024ab5f31c473bda5ff81 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 11:16:47 +0400 Subject: [PATCH 04/37] Fix loading locally stored self data. --- Telegram/SourceFiles/storage/serialize_peer.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/storage/serialize_peer.cpp b/Telegram/SourceFiles/storage/serialize_peer.cpp index e888b7cac..81fed5dd7 100644 --- a/Telegram/SourceFiles/storage/serialize_peer.cpp +++ b/Telegram/SourceFiles/storage/serialize_peer.cpp @@ -204,8 +204,9 @@ PeerData *readPeer( const auto loaded = (peerId == selfId) ? session->user().get() : session->data().peerLoaded(peerId); + const auto apply = (loaded->loadedStatus != PeerData::FullLoaded); const auto result = loaded ? loaded : session->data().peer(peerId).get(); - if (!loaded) { + if (apply) { result->loadedStatus = PeerData::FullLoaded; } if (const auto user = result->asUser()) { @@ -230,7 +231,7 @@ PeerData *readPeer( ? App::formatPhone(phone) : QString(); - if (!loaded) { + if (apply) { user->setPhone(phone); user->setName(first, last, pname, username); @@ -268,7 +269,7 @@ PeerData *readPeer( if (oldForbidden) { flags |= quint32(MTPDchat_ClientFlag::f_forbidden); } - if (!loaded) { + if (apply) { chat->setName(name); chat->count = count; chat->date = date; @@ -296,7 +297,7 @@ PeerData *readPeer( if (oldForbidden) { flags |= quint32(MTPDchannel_ClientFlag::f_forbidden); } - if (!loaded) { + if (apply) { channel->setName(name, QString()); channel->access = access; channel->date = date; @@ -312,7 +313,7 @@ PeerData *readPeer( channel->inputChannel = MTP_inputChannel(MTP_int(peerToChannel(channel->id)), MTP_long(access)); } } - if (!loaded) { + if (apply) { using LocationType = StorageFileLocation::Type; const auto location = (userpic->valid() && userpic->isLegacy()) ? userpic->convertToModern( From ab33af3f738e93cebff18eb2c8df92af12d87e99 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 11:18:35 +0400 Subject: [PATCH 05/37] Save preloaded filters info. --- Telegram/SourceFiles/intro/intro_step.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/intro/intro_step.cpp b/Telegram/SourceFiles/intro/intro_step.cpp index ad5b818a2..47de864e4 100644 --- a/Telegram/SourceFiles/intro/intro_step.cpp +++ b/Telegram/SourceFiles/intro/intro_step.cpp @@ -192,8 +192,9 @@ void Step::createSession( // "this" is already deleted here by creating the main widget. account->local().writeMtpData(); auto &session = account->session(); + session.data().chatsFilters().setPreloaded(filters); if (!filters.isEmpty()) { - session.data().chatsFilters().setPreloaded(filters); + session.saveSettingsDelayed(); } if (!photo.isNull()) { session.api().uploadPeerPhoto(session.user(), std::move(photo)); From 9211b4d42163e697de03947af6009cb5f3bdaa78 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 11:31:52 +0400 Subject: [PATCH 06/37] Remove duplicate accounts toggle subscription. --- Telegram/SourceFiles/window/window_main_menu.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index 95b1cfae7..a85f4c963 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -690,7 +690,6 @@ void MainMenu::setupAccounts() { rebuildAccounts(); }, lifetime()); - _accounts->toggleOn(Core::App().settings().mainMenuAccountsShownValue()); _accounts->toggleOn(Core::App().settings().mainMenuAccountsShownValue()); _accounts->finishAnimating(); From 0db6fc4ffbac2164216f890747de5619c00710e1 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 11:34:02 +0400 Subject: [PATCH 07/37] Toggle accounts by userpic in Main Menu. --- .../SourceFiles/window/window_main_menu.cpp | 20 +++++++++---------- .../SourceFiles/window/window_main_menu.h | 1 + 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index a85f4c963..327a77724 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -644,14 +644,17 @@ void MainMenu::setupCloudButton() { } void MainMenu::setupUserpicButton() { - _userpicButton->setClickedCallback([=] { - _controller->content()->choosePeer( - _controller->session().userPeerId(), - ShowAtUnreadMsgId); - }); + _userpicButton->setClickedCallback([=] { toggleAccounts(); }); _userpicButton->show(); } +void MainMenu::toggleAccounts() { + auto &settings = Core::App().settings(); + const auto shown = !settings.mainMenuAccountsShown(); + settings.setMainMenuAccountsShown(shown); + Core::App().saveSettingsDelayed(); +} + void MainMenu::setupAccounts() { const auto inner = _accounts->entity(); @@ -813,12 +816,7 @@ not_null*> MainMenu::setupAddAccount( void MainMenu::setupAccountsToggle() { _toggleAccounts->show(); - _toggleAccounts->setClickedCallback([=] { - auto &settings = Core::App().settings(); - const auto shown = !settings.mainMenuAccountsShown(); - settings.setMainMenuAccountsShown(shown); - Core::App().saveSettingsDelayed(); - }); + _toggleAccounts->setClickedCallback([=] { toggleAccounts(); }); } void MainMenu::parentResized() { diff --git a/Telegram/SourceFiles/window/window_main_menu.h b/Telegram/SourceFiles/window/window_main_menu.h index 51e10a9bf..661364ab2 100644 --- a/Telegram/SourceFiles/window/window_main_menu.h +++ b/Telegram/SourceFiles/window/window_main_menu.h @@ -68,6 +68,7 @@ private: void initResetScaleButton(); void refreshMenu(); void refreshBackground(); + void toggleAccounts(); const not_null _controller; object_ptr _userpicButton; From c3fa300b5cf49c09d074343119f37cda1b19590a Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 11:44:32 +0400 Subject: [PATCH 08/37] Create notifications manager after reading settings. --- Telegram/SourceFiles/core/application.cpp | 1 + Telegram/SourceFiles/main/main_domain.cpp | 2 + .../window/notifications_manager.cpp | 38 ++++++++++++++----- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 61e1504a0..cfeaf930f 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -183,6 +183,7 @@ void Application::run() { refreshGlobalProxy(); // Depends on Global::start(). // Depends on OpenSSL on macOS, so on ThirdParty::start(). + // Depends on notifications settings. _notifications = std::make_unique(); startLocalStorage(); diff --git a/Telegram/SourceFiles/main/main_domain.cpp b/Telegram/SourceFiles/main/main_domain.cpp index 6b8fd61cc..5f139504f 100644 --- a/Telegram/SourceFiles/main/main_domain.cpp +++ b/Telegram/SourceFiles/main/main_domain.cpp @@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/storage_account.h" #include "storage/localstorage.h" #include "export/export_settings.h" +#include "window/notifications_manager.h" #include "facades.h" namespace Main { @@ -28,6 +29,7 @@ Domain::Domain(const QString &dataName) _active.changes( ) | rpl::take(1) | rpl::start_with_next([] { Local::rewriteSettingsIfNeeded(); + Core::App().notifications().createManager(); }, _lifetime); } diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index 73d428cb2..e542e5ee0 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -52,8 +52,6 @@ constexpr auto kSystemAlertDuration = crl::time(0); System::System() : _waitTimer([=] { showNext(); }) , _waitForAllGroupedTimer([=] { showGrouped(); }) { - createManager(); - subscribe(settingsChanged(), [=](ChangeType type) { if (type == ChangeType::DesktopEnabled) { App::wnd()->updateTrayMenu(); @@ -174,7 +172,9 @@ void System::schedule(not_null item) { } void System::clearAll() { - _manager->clearAll(); + if (_manager) { + _manager->clearAll(); + } for (auto i = _whenMaps.cbegin(), e = _whenMaps.cend(); i != e; ++i) { i->first->clearNotifications(); @@ -186,7 +186,9 @@ void System::clearAll() { } void System::clearFromHistory(not_null history) { - _manager->clearFromHistory(history); + if (_manager) { + _manager->clearFromHistory(history); + } history->clearNotifications(); _whenMaps.remove(history); @@ -199,7 +201,9 @@ void System::clearFromHistory(not_null history) { } void System::clearFromSession(not_null session) { - _manager->clearFromSession(session); + if (_manager) { + _manager->clearFromSession(session); + } for (auto i = _whenMaps.begin(); i != _whenMaps.end();) { const auto history = i->first; @@ -228,17 +232,23 @@ void System::clearFromSession(not_null session) { } void System::clearIncomingFromHistory(not_null history) { - _manager->clearFromHistory(history); + if (_manager) { + _manager->clearFromHistory(history); + } history->clearIncomingNotifications(); _whenAlerts.remove(history); } void System::clearFromItem(not_null item) { - _manager->clearFromItem(item); + if (_manager) { + _manager->clearFromItem(item); + } } void System::clearAllFast() { - _manager->clearAllFast(); + if (_manager) { + _manager->clearAllFast(); + } _whenMaps.clear(); _whenAlerts.clear(); @@ -293,6 +303,8 @@ void System::checkDelayed() { } void System::showGrouped() { + Expects(_manager != nullptr); + if (const auto session = findSession(_lastHistorySessionId)) { if (const auto lastItem = session->data().message(_lastHistoryItemId)) { _waitForAllGroupedTimer.cancel(); @@ -305,7 +317,11 @@ void System::showGrouped() { } void System::showNext() { - if (App::quitting()) return; + Expects(_manager != nullptr); + + if (App::quitting()) { + return; + } const auto isSameGroup = [=](HistoryItem *item) { if (!_lastHistorySessionId || !_lastHistoryItemId || !item) { @@ -536,7 +552,9 @@ void System::ensureSoundCreated() { } void System::updateAll() { - _manager->updateAll(); + if (_manager) { + _manager->updateAll(); + } } Manager::DisplayOptions Manager::GetNotificationOptions(HistoryItem *item) { From 613a2f358a77df72ce401e197af5d496207984dc Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 11:52:59 +0400 Subject: [PATCH 09/37] Fix clearing session notifications. --- .../linux/notifications_manager_linux.cpp | 34 +++++++++++++------ .../win/notifications_manager_win.cpp | 26 +++++++++----- .../window/notifications_manager.cpp | 14 ++++---- 3 files changed, 47 insertions(+), 27 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index cf12821ce..62463eb7a 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -582,7 +582,9 @@ void Manager::Private::showNotification( const QString &msg, bool hideNameAndPhoto, bool hideReplyButton) { - if (!Supported()) return; + if (!Supported()) { + return; + } const auto key = FullPeer{ .sessionId = peer->session().uniqueId(), @@ -630,7 +632,9 @@ void Manager::Private::showNotification( } void Manager::Private::clearAll() { - if (!Supported()) return; + if (!Supported()) { + return; + } for (const auto &[key, notifications] : base::take(_notifications)) { for (const auto &[msgId, notification] : notifications) { @@ -640,7 +644,9 @@ void Manager::Private::clearAll() { } void Manager::Private::clearFromHistory(not_null history) { - if (!Supported()) return; + if (!Supported()) { + return; + } const auto key = FullPeer{ .sessionId = history->session().uniqueId(), @@ -658,23 +664,29 @@ void Manager::Private::clearFromHistory(not_null history) { } void Manager::Private::clearFromSession(not_null session) { - if (!Supported()) return; + if (!Supported()) { + return; + } const auto sessionId = session->uniqueId(); for (auto i = _notifications.begin(); i != _notifications.end();) { - if (i->first.sessionId == sessionId) { - const auto temp = base::take(i->second); - i = _notifications.erase(i); + if (i->first.sessionId != sessionId) { + ++i; + continue; + } + const auto temp = base::take(i->second); + i = _notifications.erase(i); - for (const auto &[msgId, notification] : temp) { - notification->close(); - } + for (const auto &[msgId, notification] : temp) { + notification->close(); } } } void Manager::Private::clearNotification(NotificationId id) { - if (!Supported()) return; + if (!Supported()) { + return; + } auto i = _notifications.find(id.full); if (i != _notifications.cend()) { diff --git a/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp b/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp index f5cfdf51d..5fd6c591f 100644 --- a/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp +++ b/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp @@ -415,7 +415,9 @@ Manager::Private::~Private() { } void Manager::Private::clearAll() { - if (!_notifier) return; + if (!_notifier) { + return; + } auto temp = base::take(_notifications); for (const auto &[key, notifications] : base::take(_notifications)) { @@ -426,7 +428,9 @@ void Manager::Private::clearAll() { } void Manager::Private::clearFromHistory(not_null history) { - if (!_notifier) return; + if (!_notifier) { + return; + } auto i = _notifications.find(FullPeer{ .sessionId = history->session().uniqueId(), @@ -443,17 +447,21 @@ void Manager::Private::clearFromHistory(not_null history) { } void Manager::Private::clearFromSession(not_null session) { - if (!_notifier) return; + if (!_notifier) { + return; + } const auto sessionId = session->uniqueId(); for (auto i = _notifications.begin(); i != _notifications.end();) { - if (i->first.sessionId == sessionId) { - const auto temp = base::take(i->second); - _notifications.erase(i); + if (i->first.sessionId != sessionId) { + ++i; + continue; + } + const auto temp = base::take(i->second); + _notifications.erase(i); - for (const auto &[msgId, notification] : temp) { - _notifier->Hide(notification.p.Get()); - } + for (const auto &[msgId, notification] : temp) { + _notifier->Hide(notification.p.Get()); } } } diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index e542e5ee0..9ab2fe022 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -207,15 +207,15 @@ void System::clearFromSession(not_null session) { for (auto i = _whenMaps.begin(); i != _whenMaps.end();) { const auto history = i->first; - if (&history->session() == session) { - history->clearNotifications(); - i = _whenMaps.erase(i); - _whenAlerts.remove(history); - _waiters.remove(history); - _settingWaiters.remove(history); - } else { + if (&history->session() != session) { ++i; + continue; } + history->clearNotifications(); + i = _whenMaps.erase(i); + _whenAlerts.remove(history); + _waiters.remove(history); + _settingWaiters.remove(history); } const auto clearFrom = [&](auto &map) { for (auto i = map.begin(); i != map.end();) { From 06c9e55c2609d39ea26fca4434f06c7ab839b2d3 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 12:03:42 +0400 Subject: [PATCH 10/37] Fix notification receiver name. --- .../SourceFiles/window/notifications_manager.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index 9ab2fe022..f9f78850f 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -577,7 +577,17 @@ Manager::DisplayOptions Manager::GetNotificationOptions(HistoryItem *item) { QString Manager::addTargetAccountName( const QString &title, not_null session) { - return (Core::App().domain().accounts().size() > 1) + const auto add = [&] { + for (const auto &[index, account] : Core::App().domain().accounts()) { + if (const auto other = account->maybeSession()) { + if (other != session) { + return true; + } + } + } + return false; + }(); + return add ? (title + accountNameSeparator() + (session->user()->username.isEmpty() From 4b1e9e3b9d64556fbdd817d9a7c8a8f4f31c5e63 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 12:25:06 +0400 Subject: [PATCH 11/37] Fix proxies list box. --- Telegram/SourceFiles/boxes/connection_box.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/boxes/connection_box.cpp b/Telegram/SourceFiles/boxes/connection_box.cpp index 579516eed..69cfea8f2 100644 --- a/Telegram/SourceFiles/boxes/connection_box.cpp +++ b/Telegram/SourceFiles/boxes/connection_box.cpp @@ -693,8 +693,8 @@ void ProxiesBox::applyView(View &&view) { setupButtons(id, i->second.get()); if (_noRows) { _noRows.reset(); - wrap->resizeToWidth(width()); } + wrap->resizeToWidth(width()); } else if (view.host.isEmpty()) { _rows.erase(i); } else { From 5d32ba586770f96cbf130253e275bd67bdb95e86 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 12:56:06 +0400 Subject: [PATCH 12/37] Accept IPv4:port in proxy host input field. --- Telegram/SourceFiles/boxes/connection_box.cpp | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/boxes/connection_box.cpp b/Telegram/SourceFiles/boxes/connection_box.cpp index 69cfea8f2..7db93ead2 100644 --- a/Telegram/SourceFiles/boxes/connection_box.cpp +++ b/Telegram/SourceFiles/boxes/connection_box.cpp @@ -171,7 +171,7 @@ private: }; -class ProxyBox : public Ui::BoxContent { +class ProxyBox final : public Ui::BoxContent { public: ProxyBox( QWidget*, @@ -179,12 +179,14 @@ public: Fn callback, Fn shareCallback); -protected: - void prepare() override; - private: using Type = ProxyData::Type; + void prepare() override; + void setInnerFocus() override { + _host->setFocusFast(); + } + void refreshButtons(); ProxyData collectData(); void save(); @@ -765,6 +767,31 @@ ProxyBox::ProxyBox( void ProxyBox::prepare() { setTitle(tr::lng_proxy_edit()); + connect(_host.data(), &Ui::InputField::changed, [=] { + Ui::PostponeCall(_host, [=] { + const auto host = _host->getLastText().trimmed(); + static const auto mask = u"^\\d+\\.\\d+\\.\\d+\\.\\d+:(\\d*)$"_q; + const auto match = QRegularExpression(mask).match(host); + if (_host->textCursor().position() == host.size() + && match.hasMatch()) { + const auto port = match.captured(1); + _port->setText(port); + _port->setCursorPosition(port.size()); + _port->setFocus(); + _host->setText(host.mid(0, host.size() - port.size() - 1)); + } + }); + }); + _port.data()->events( + ) | rpl::start_with_next([=](not_null e) { + if (e->type() == QEvent::KeyPress + && (static_cast(e.get())->key() == Qt::Key_Backspace) + && _port->cursorPosition() == 0) { + _host->setCursorPosition(_host->getLastText().size()); + _host->setFocus(); + } + }, _port->lifetime()); + refreshButtons(); setDimensionsToContent(st::boxWideWidth, _content); } From e6f3cd1d56add88747d02d21ddb8a491c78abf0d Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 13:01:59 +0400 Subject: [PATCH 13/37] Refresh appconfig after login. --- Telegram/SourceFiles/main/main_app_config.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Telegram/SourceFiles/main/main_app_config.cpp b/Telegram/SourceFiles/main/main_app_config.cpp index 4f86f2bcf..077c97e0a 100644 --- a/Telegram/SourceFiles/main/main_app_config.cpp +++ b/Telegram/SourceFiles/main/main_app_config.cpp @@ -24,6 +24,13 @@ AppConfig::AppConfig(not_null account) : _account(account) { _api.emplace(instance); refresh(); }, _lifetime); + + account->sessionChanges( + ) | rpl::filter([=](Session *session) { + return (session != nullptr); + }) | rpl::start_with_next([=] { + refresh(); + }, _lifetime); } void AppConfig::refresh() { From d2615dda63bd50400039cbf84bf44a04afb873c0 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 30 Jun 2020 11:37:15 +0300 Subject: [PATCH 14/37] Updated Github Actions Cache version. --- .github/workflows/linux.yml | 10 +++++----- .github/workflows/mac.yml | 12 ++++++------ .github/workflows/win.yml | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index b350b487a..a3a2744d0 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -157,7 +157,7 @@ jobs: - name: Opus cache. id: cache-opus - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/opus key: ${{ runner.OS }}-opus-${{ env.CACHE_KEY }} @@ -202,7 +202,7 @@ jobs: - name: FFmpeg cache. id: cache-ffmpeg - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/ffmpeg-cache key: ${{ runner.OS }}-ffmpeg-${{ env.CACHE_KEY }} @@ -356,7 +356,7 @@ jobs: - name: OpenSSL cache. id: cache-openssl - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/openssl-cache key: ${{ runner.OS }}-${{ env.OPENSSL_VER }}-${{ env.CACHE_KEY }} @@ -412,7 +412,7 @@ jobs: - name: Qt 5.12.8 cache. id: cache-qt - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/qt-cache key: ${{ runner.OS }}-qt-${{ env.CACHE_KEY }}-${{ hashFiles('**/qt*_5_12_8/*') }} @@ -461,7 +461,7 @@ jobs: - name: Breakpad cache. id: cache-breakpad - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/breakpad-cache key: ${{ runner.OS }}-breakpad-${{ env.CACHE_KEY }} diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index dd6f9e04e..0b4cecb3b 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -133,7 +133,7 @@ jobs: - name: OpenSSL cache. id: cache-openssl - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/openssl_${{ env.OPENSSL_VER }} key: ${{ runner.OS }}-${{ env.OPENSSL_VER }}-${{ env.CACHE_KEY }} @@ -163,7 +163,7 @@ jobs: - name: Opus cache. id: cache-opus - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/opus key: ${{ runner.OS }}-opus-${{ env.CACHE_KEY }} @@ -185,7 +185,7 @@ jobs: - name: Libiconv cache. id: cache-libiconv - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/${{ env.LIBICONV_VER }} key: ${{ runner.OS }}-${{ env.LIBICONV_VER }}-${{ env.CACHE_KEY }} @@ -206,7 +206,7 @@ jobs: - name: FFmpeg cache. id: cache-ffmpeg - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/ffmpeg-cache key: ${{ runner.OS }}-ffmpeg-${{ env.CACHE_KEY }} @@ -362,7 +362,7 @@ jobs: - name: Crashpad cache. id: cache-crashpad - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/crashpad key: ${{ runner.OS }}-crashpad-${{ env.CACHE_KEY }}-${{ hashFiles('**/crashpad.diff') }}-${{ hashFiles('**/mini_chromium.diff') }} @@ -401,7 +401,7 @@ jobs: - name: Qt 5.12.8 cache. id: cache-qt - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/qt-cache key: ${{ runner.OS }}-qt-${{ env.CACHE_KEY }}-${{ hashFiles('**/qtbase_5_12_8/*') }} diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml index 763feb260..be382a6a8 100644 --- a/.github/workflows/win.yml +++ b/.github/workflows/win.yml @@ -133,7 +133,7 @@ jobs: - name: OpenSSL cache. id: cache-openssl - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/openssl_${{ env.OPENSSL_VER }} key: ${{ runner.OS }}-${{ env.CACHE_KEY }}-${{ env.OPENSSL_VER }} @@ -177,7 +177,7 @@ jobs: - name: OpenAL Soft cache. id: cache-openal - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/openal-soft key: ${{ runner.OS }}-openal-soft-${{ env.CACHE_KEY }} @@ -201,7 +201,7 @@ jobs: - name: Breakpad cache. id: cache-breakpad - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/breakpad key: ${{ runner.OS }}-breakpad-${{ env.CACHE_KEY }}-${{ hashFiles('**/breakpad.diff') }} @@ -250,7 +250,7 @@ jobs: - name: Opus cache. id: cache-opus - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/opus key: ${{ runner.OS }}-opus-${{ env.CACHE_KEY }} @@ -269,7 +269,7 @@ jobs: - name: FFmpeg cache. id: cache-ffmpeg - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/ffmpeg key: ${{ runner.OS }}-ffmpeg-${{ env.CACHE_KEY }}-2-${{ hashFiles('**/build_ffmpeg_win.sh') }} @@ -291,7 +291,7 @@ jobs: - name: Qt 5.12.8 cache. id: cache-qt - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: ${{ env.LibrariesPath }}/Qt-5.12.8 key: ${{ runner.OS }}-qt-${{ env.CACHE_KEY }}-${{ hashFiles('**/qtbase_5_12_8/*') }} From a95b756111eafa83886732c9ce17eed8d5251056 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 13:49:22 +0400 Subject: [PATCH 15/37] Fix settings saving. Regression was introduced in 5d6a494934. Fixes #8168. --- Telegram/SourceFiles/core/core_settings.cpp | 52 ++++++++++++++++++- .../player/media_player_volume_controller.cpp | 2 +- .../media/player/media_player_widget.cpp | 1 + .../media/view/media_view_overlay_widget.cpp | 4 +- .../SourceFiles/settings/settings_calls.cpp | 6 +-- 5 files changed, 57 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/core/core_settings.cpp b/Telegram/SourceFiles/core/core_settings.cpp index c88373baf..41be395df 100644 --- a/Telegram/SourceFiles/core/core_settings.cpp +++ b/Telegram/SourceFiles/core/core_settings.cpp @@ -94,7 +94,17 @@ QByteArray Settings::serialize() const { } stream << qint32(_autoDownloadDictionaries.current() ? 1 : 0) - << qint32(_mainMenuAccountsShown.current() ? 1 : 0); + << qint32(_mainMenuAccountsShown.current() ? 1 : 0) + << qint32(_tabbedSelectorSectionEnabled ? 1 : 0) + << qint32(_floatPlayerColumn) + << qint32(_floatPlayerCorner) + << qint32(_thirdSectionInfoEnabled ? 1 : 0) + << qint32(snap( + qRound(_dialogsWidthRatio.current() * 1000000), + 0, + 1000000)) + << qint32(_thirdColumnWidth.current()) + << qint32(_thirdSectionExtendedBy); } return result; } @@ -150,6 +160,13 @@ void Settings::addFromSerialized(const QByteArray &serialized) { std::vector dictionariesEnabled; qint32 autoDownloadDictionaries = _autoDownloadDictionaries.current() ? 1 : 0; qint32 mainMenuAccountsShown = _mainMenuAccountsShown.current() ? 1 : 0; + qint32 tabbedSelectorSectionEnabled = 1; + qint32 floatPlayerColumn = static_cast(Window::Column::Second); + qint32 floatPlayerCorner = static_cast(RectPart::TopRight); + qint32 thirdSectionInfoEnabled = 0; + float64 dialogsWidthRatio = _dialogsWidthRatio.current(); + qint32 thirdColumnWidth = _thirdColumnWidth.current(); + qint32 thirdSectionExtendedBy = _thirdSectionExtendedBy; stream >> themesAccentColors; if (!stream.atEnd()) { @@ -211,6 +228,18 @@ void Settings::addFromSerialized(const QByteArray &serialized) { >> autoDownloadDictionaries >> mainMenuAccountsShown; } + if (!stream.atEnd()) { + auto dialogsWidthRatioInt = qint32(); + stream + >> tabbedSelectorSectionEnabled + >> floatPlayerColumn + >> floatPlayerCorner + >> thirdSectionInfoEnabled + >> dialogsWidthRatioInt + >> thirdColumnWidth + >> thirdSectionExtendedBy; + dialogsWidthRatio = snap(dialogsWidthRatioInt / 1000000., 0., 1.); + } if (stream.status() != QDataStream::Ok) { LOG(("App Error: " "Bad data for Core::Settings::constructFromSerialized()")); @@ -281,6 +310,27 @@ void Settings::addFromSerialized(const QByteArray &serialized) { _dictionariesEnabled = std::move(dictionariesEnabled); _autoDownloadDictionaries = (autoDownloadDictionaries == 1); _mainMenuAccountsShown = (mainMenuAccountsShown == 1); + _tabbedSelectorSectionEnabled = (tabbedSelectorSectionEnabled == 1); + auto uncheckedColumn = static_cast(floatPlayerColumn); + switch (uncheckedColumn) { + case Window::Column::First: + case Window::Column::Second: + case Window::Column::Third: _floatPlayerColumn = uncheckedColumn; break; + } + auto uncheckedCorner = static_cast(floatPlayerCorner); + switch (uncheckedCorner) { + case RectPart::TopLeft: + case RectPart::TopRight: + case RectPart::BottomLeft: + case RectPart::BottomRight: _floatPlayerCorner = uncheckedCorner; break; + } + _thirdSectionInfoEnabled = thirdSectionInfoEnabled; + _dialogsWidthRatio = dialogsWidthRatio; + _thirdColumnWidth = thirdColumnWidth; + _thirdSectionExtendedBy = thirdSectionExtendedBy; + if (_thirdSectionInfoEnabled) { + _tabbedSelectorSectionEnabled = false; + } } bool Settings::chatWide() const { diff --git a/Telegram/SourceFiles/media/player/media_player_volume_controller.cpp b/Telegram/SourceFiles/media/player/media_player_volume_controller.cpp index 135453ba5..d21a1fbdc 100644 --- a/Telegram/SourceFiles/media/player/media_player_volume_controller.cpp +++ b/Telegram/SourceFiles/media/player/media_player_volume_controller.cpp @@ -39,7 +39,7 @@ VolumeController::VolumeController( Core::App().settings().setRememberedSongVolume(volume); } applyVolumeChange(volume); - controller->session().saveSettingsDelayed(); + Core::App().saveSettingsDelayed(); }); Core::App().settings().songVolumeChanges( ) | rpl::start_with_next([=](float64 volume) { diff --git a/Telegram/SourceFiles/media/player/media_player_widget.cpp b/Telegram/SourceFiles/media/player/media_player_widget.cpp index 0bc26ebf4..f7fa56b8b 100644 --- a/Telegram/SourceFiles/media/player/media_player_widget.cpp +++ b/Telegram/SourceFiles/media/player/media_player_widget.cpp @@ -132,6 +132,7 @@ Widget::Widget(QWidget *parent, not_null session) ? 0. : Core::App().settings().rememberedSongVolume(); Core::App().settings().setSongVolume(volume); + Core::App().saveSettingsDelayed(); mixer()->setSongVolume(volume); }); Core::App().settings().songVolumeChanges( diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index 322f606f9..1700cba3d 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -2653,10 +2653,8 @@ void OverlayWidget::playbackControlsSeekFinished(crl::time position) { void OverlayWidget::playbackControlsVolumeChanged(float64 volume) { Core::App().settings().setVideoVolume(volume); + Core::App().saveSettingsDelayed(); updateMixerVideoVolume(); - if (_document) { - _document->session().saveSettingsDelayed(); - } } float64 OverlayWidget::playbackControlsCurrentVolume() { diff --git a/Telegram/SourceFiles/settings/settings_calls.cpp b/Telegram/SourceFiles/settings/settings_calls.cpp index ddfbef47c..01b1bf5fd 100644 --- a/Telegram/SourceFiles/settings/settings_calls.cpp +++ b/Telegram/SourceFiles/settings/settings_calls.cpp @@ -52,7 +52,7 @@ Calls::Calls( Calls::~Calls() { if (_needWriteSettings) { - _controller->session().saveSettingsDelayed(); + Core::App().saveSettingsDelayed(); } } @@ -134,7 +134,7 @@ void Calls::setupContent() { : "default"; Core::App().settings().setCallOutputDeviceID( QString::fromStdString(deviceId)); - _controller->session().saveSettingsDelayed(); + Core::App().saveSettingsDelayed(); if (const auto call = Core::App().calls().currentCall()) { call->setCurrentAudioDevice(false, deviceId); } @@ -210,7 +210,7 @@ void Calls::setupContent() { : "default"; Core::App().settings().setCallInputDeviceID( QString::fromStdString(deviceId)); - _controller->session().saveSettingsDelayed(); + Core::App().saveSettingsDelayed(); if (_micTester) { stopTestingMicrophone(); } From 2ef47222f45d95b021f67475ddc7916f5b779557 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 17:17:07 +0400 Subject: [PATCH 16/37] Fix crash in update online on logout. --- Telegram/SourceFiles/window/window_controller.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Telegram/SourceFiles/window/window_controller.cpp b/Telegram/SourceFiles/window/window_controller.cpp index 6a30f7be8..586868027 100644 --- a/Telegram/SourceFiles/window/window_controller.cpp +++ b/Telegram/SourceFiles/window/window_controller.cpp @@ -85,9 +85,6 @@ void Controller::showAccount(not_null account) { setupIntro(); _widget.updateGlobalMenu(); } - if (was) { - was->session().updates().updateOnline(); - } }, _accountLifetime); } From 10ced1984143b3bc60f94e8b498830f322ae0640 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 17:23:21 +0400 Subject: [PATCH 17/37] Fix crash in redundant checkStartUrl call. --- Telegram/SourceFiles/core/local_url_handlers.cpp | 15 ++++++--------- Telegram/SourceFiles/mainwidget.cpp | 2 -- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index e1d2f4ac0..0958c4995 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -298,15 +298,12 @@ bool ResolveUsername( post = ShowAtGameShareMsgId; } const auto clickFromMessageId = context.value(); - if (const auto controller = App::wnd()->sessionController()) { - controller->content()->openPeerByName( - domain, - post, - startToken, - clickFromMessageId); - return true; - } - return false; + controller->content()->openPeerByName( + domain, + post, + startToken, + clickFromMessageId); + return true; } bool ResolvePrivatePost( diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index cb4b08f3b..6f27ebba4 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -370,8 +370,6 @@ MainWidget::MainWidget( cSetOtherOnline(0); _history->start(); - - Core::App().checkStartUrl(); } MainWidget::~MainWidget() = default; From b7707a8a89e46a498b1ad5f711e9c3d74bede8dd Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 17:41:55 +0400 Subject: [PATCH 18/37] Fix event loop tracking crash. --- Telegram/SourceFiles/platform/mac/main_window_mac.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.mm b/Telegram/SourceFiles/platform/mac/main_window_mac.mm index 4f864f0a2..4e1b73baa 100644 --- a/Telegram/SourceFiles/platform/mac/main_window_mac.mm +++ b/Telegram/SourceFiles/platform/mac/main_window_mac.mm @@ -197,7 +197,9 @@ private: } - (void) darkModeChanged:(NSNotification *)aNotification { - Core::App().domain().notifyUnreadBadgeChanged(); + Core::Sandbox::Instance().customEnterFromEventLoop([&] { + Core::App().domain().notifyUnreadBadgeChanged(); + }); } - (void) screenIsLocked:(NSNotification *)aNotification { From 09aff23ac97f7085308450de235f571ea39f9471 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 18:14:05 +0400 Subject: [PATCH 19/37] Fix crashes in HistoryWidget. --- .../SourceFiles/history/history_widget.cpp | 134 ++++++++++-------- Telegram/SourceFiles/history/history_widget.h | 13 +- 2 files changed, 87 insertions(+), 60 deletions(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 1f0148fbb..eed9a4a08 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -259,6 +259,7 @@ HistoryWidget::HistoryWidget( QWidget *parent, not_null controller) : Window::AbstractSectionWidget(parent, controller) +, _api(&controller->session().mtp()) , _updateEditTimeLeftDisplay([=] { updateField(); }) , _fieldBarCancel(this, st::historyReplyCancel) , _previewTimer([=] { requestPreview(); }) @@ -1143,14 +1144,14 @@ void HistoryWidget::updateInlineBotQuery() { if (_inlineBotUsername != query.username) { _inlineBotUsername = query.username; if (_inlineBotResolveRequestId) { - session().api().request(_inlineBotResolveRequestId).cancel(); + _api.request(_inlineBotResolveRequestId).cancel(); _inlineBotResolveRequestId = 0; } if (query.lookingUpBot) { _inlineBot = nullptr; _inlineLookingUpBot = true; const auto username = _inlineBotUsername; - _inlineBotResolveRequestId = session().api().request(MTPcontacts_ResolveUsername( + _inlineBotResolveRequestId = _api.request(MTPcontacts_ResolveUsername( MTP_string(username) )).done([=](const MTPcontacts_ResolvedPeer &result) { inlineBotResolveDone(result); @@ -1401,7 +1402,7 @@ void HistoryWidget::cancelSendAction( SendAction::Type type) { const auto i = _sendActionRequests.find({ history, type }); if (i != _sendActionRequests.end()) { - session().api().request(i->second).cancel(); + _api.request(i->second).cancel(); _sendActionRequests.erase(i); } } @@ -1442,7 +1443,7 @@ void HistoryWidget::updateSendAction( case Type::ChooseContact: action = MTP_sendMessageChooseContactAction(); break; case Type::PlayGame: action = MTP_sendMessageGamePlayAction(); break; } - const auto requestId = session().api().request(MTPmessages_SetTyping( + const auto requestId = _api.request(MTPmessages_SetTyping( peer->input, action )).done([=](const MTPBool &result, mtpRequestId requestId) { @@ -3058,6 +3059,7 @@ void HistoryWidget::saveEditMsg() { sendFlags |= MTPmessages_EditMessage::Flag::f_entities; } + const auto weak = Ui::MakeWeak(this); const auto history = _history; _saveEditMsgRequestId = history->session().api().request( MTPmessages_EditMessage( @@ -3069,55 +3071,60 @@ void HistoryWidget::saveEditMsg() { MTPReplyMarkup(), sentEntities, MTP_int(0) - )).done([=](const MTPUpdates &result, mtpRequestId requestId) { - saveEditMsgDone(history, result, requestId); - }).fail([=](const RPCError &error, mtpRequestId requestId) { - saveEditMsgFail(history, error, requestId); + )).done([history, weak](const MTPUpdates &result, mtpRequestId requestId) { + SaveEditMsgDone(history, result, requestId); + if (const auto strong = weak.data()) { + if (requestId == strong->_saveEditMsgRequestId) { + strong->_saveEditMsgRequestId = 0; + strong->cancelEdit(); + } + } + }).fail([history, weak](const RPCError &error, mtpRequestId requestId) { + SaveEditMsgFail(history, error, requestId); + if (const auto strong = weak.data()) { + if (requestId == strong->_saveEditMsgRequestId) { + strong->_saveEditMsgRequestId = 0; + } + const auto &err = error.type(); + if (err == qstr("MESSAGE_ID_INVALID") + || err == qstr("CHAT_ADMIN_REQUIRED") + || err == qstr("MESSAGE_EDIT_TIME_EXPIRED")) { + Ui::show(Box(tr::lng_edit_error(tr::now))); + } else if (err == qstr("MESSAGE_NOT_MODIFIED")) { + strong->cancelEdit(); + } else if (err == qstr("MESSAGE_EMPTY")) { + strong->_field->selectAll(); + strong->_field->setFocus(); + } else { + Ui::show(Box(tr::lng_edit_error(tr::now))); + } + strong->update(); + } }).send(); } -void HistoryWidget::saveEditMsgDone( +void HistoryWidget::SaveEditMsgDone( not_null history, const MTPUpdates &updates, mtpRequestId requestId) { - session().api().applyUpdates(updates); - if (requestId == _saveEditMsgRequestId) { - _saveEditMsgRequestId = 0; - cancelEdit(); - } + history->session().api().applyUpdates(updates); if (auto editDraft = history->editDraft()) { if (editDraft->saveRequestId == requestId) { history->clearEditDraft(); - session().local().writeDrafts(history); + history->session().local().writeDrafts(history); } } } -void HistoryWidget::saveEditMsgFail( +void HistoryWidget::SaveEditMsgFail( not_null history, const RPCError &error, mtpRequestId requestId) { - if (requestId == _saveEditMsgRequestId) { - _saveEditMsgRequestId = 0; - } if (auto editDraft = history->editDraft()) { if (editDraft->saveRequestId == requestId) { editDraft->saveRequestId = 0; } } - - const auto &err = error.type(); - if (err == qstr("MESSAGE_ID_INVALID") || err == qstr("CHAT_ADMIN_REQUIRED") || err == qstr("MESSAGE_EDIT_TIME_EXPIRED")) { - Ui::show(Box(tr::lng_edit_error(tr::now))); - } else if (err == qstr("MESSAGE_NOT_MODIFIED")) { - cancelEdit(); - } else if (err == qstr("MESSAGE_EMPTY")) { - _field->selectAll(); - _field->setFocus(); - } else { - Ui::show(Box(tr::lng_edit_error(tr::now))); - } - update(); } void HistoryWidget::hideSelectorControlsAnimated() { @@ -3674,6 +3681,7 @@ void HistoryWidget::app_sendBotCallback( using ButtonType = HistoryMessageMarkupButton::Type; BotCallbackInfo info = { + &session(), bot, msg->fullId(), row, @@ -3688,15 +3696,24 @@ void HistoryWidget::app_sendBotCallback( flags |= MTPmessages_GetBotCallbackAnswer::Flag::f_data; sendData = button->data; } + const auto weak = Ui::MakeWeak(this); button->requestId = session().api().request(MTPmessages_GetBotCallbackAnswer( MTP_flags(flags), _peer->input, MTP_int(msg->id), MTP_bytes(sendData) - )).done([=](const MTPmessages_BotCallbackAnswer &result, mtpRequestId requestId) { - botCallbackDone(info, result, requestId); - }).fail([=](const RPCError &error, mtpRequestId requestId) { - botCallbackFail(info, error, requestId); + )).done([info, weak](const MTPmessages_BotCallbackAnswer &result, mtpRequestId requestId) { + BotCallbackDone(info, result, requestId); + result.match([&](const MTPDmessages_botCallbackAnswer &data) { + const auto item = info.session->data().message(info.msgId); + if (!data.vmessage() && data.vurl() && info.game && item) { + if (const auto strong = weak.data()) { + strong->updateSendAction(item->history(), SendAction::Type::PlayGame); + } + } + }); + }).fail([info](const RPCError &error, mtpRequestId requestId) { + BotCallbackFail(info, error, requestId); }).send(); session().data().requestItemRepaint(msg); @@ -3709,19 +3726,20 @@ void HistoryWidget::app_sendBotCallback( } } -void HistoryWidget::botCallbackDone( +void HistoryWidget::BotCallbackDone( BotCallbackInfo info, const MTPmessages_BotCallbackAnswer &answer, mtpRequestId req) { - const auto item = session().data().message(info.msgId); + const auto session = info.session; + const auto item = session->data().message(info.msgId); const auto button = HistoryMessageMarkupButton::Get( - &session().data(), + &session->data(), info.msgId, info.row, info.col); if (button && button->requestId == req) { button->requestId = 0; - session().data().requestItemRepaint(item); + session->data().requestItemRepaint(item); } answer.match([&](const MTPDmessages_botCallbackAnswer &data) { if (const auto message = data.vmessage()) { @@ -3733,11 +3751,8 @@ void HistoryWidget::botCallbackDone( } else if (const auto url = data.vurl()) { auto link = qs(*url); if (info.game) { - link = AppendShareGameScoreUrl(&session(), link, info.msgId); + link = AppendShareGameScoreUrl(session, link, info.msgId); BotGameUrlClickHandler(info.bot, link).onClick({}); - if (item) { - updateSendAction(item->history(), SendAction::Type::PlayGame); - } } else { UrlClickHandler::Open(link); } @@ -3745,21 +3760,21 @@ void HistoryWidget::botCallbackDone( }); } -bool HistoryWidget::botCallbackFail( +void HistoryWidget::BotCallbackFail( BotCallbackInfo info, const RPCError &error, mtpRequestId req) { // show error? + const auto owner = &info.session->data(); const auto button = HistoryMessageMarkupButton::Get( - &session().data(), + owner, info.msgId, info.row, info.col); if (button && button->requestId == req) { button->requestId = 0; - session().data().requestItemRepaint(session().data().message(info.msgId)); + owner->requestItemRepaint(owner->message(info.msgId)); } - return true; } bool HistoryWidget::insertBotCommand(const QString &cmd) { @@ -5982,21 +5997,28 @@ void HistoryWidget::pinMessage(FullMsgId itemId) { } void HistoryWidget::unpinMessage(FullMsgId itemId) { - const auto peer = _peer; + if (!_peer) { + return; + } + UnpinMessage(_peer); +} + +void HistoryWidget::UnpinMessage(not_null peer) { if (!peer) { return; } - Ui::show(Box(tr::lng_pinned_unpin_sure(tr::now), tr::lng_pinned_unpin(tr::now), crl::guard(this, [=] { + const auto session = &peer->session(); + Ui::show(Box(tr::lng_pinned_unpin_sure(tr::now), tr::lng_pinned_unpin(tr::now), crl::guard(session, [=] { peer->clearPinnedMessage(); Ui::hideLayer(); - session().api().request(MTPmessages_UpdatePinnedMessage( + session->api().request(MTPmessages_UpdatePinnedMessage( MTP_flags(0), peer->input, MTP_int(0) )).done([=](const MTPUpdates &result) { - session().api().applyUpdates(result); + session->api().applyUpdates(result); }).send(); }))); } @@ -6155,7 +6177,7 @@ void HistoryWidget::cancelFieldAreaState() { } void HistoryWidget::previewCancel() { - session().api().request(base::take(_previewRequest)).cancel(); + _api.request(base::take(_previewRequest)).cancel(); _previewData = nullptr; _previewLinks.clear(); updatePreview(); @@ -6171,7 +6193,7 @@ void HistoryWidget::checkPreview() { } const auto links = _parsedLinks.join(' '); if (_previewLinks != links) { - session().api().request(base::take(_previewRequest)).cancel(); + _api.request(base::take(_previewRequest)).cancel(); _previewLinks = links; if (_previewLinks.isEmpty()) { if (_previewData && _previewData->pendingTill >= 0) { @@ -6180,7 +6202,7 @@ void HistoryWidget::checkPreview() { } else { const auto i = _previewCache.constFind(links); if (i == _previewCache.cend()) { - _previewRequest = session().api().request(MTPmessages_GetWebPagePreview( + _previewRequest = _api.request(MTPmessages_GetWebPagePreview( MTP_flags(0), MTP_string(links), MTPVector() @@ -6204,7 +6226,7 @@ void HistoryWidget::requestPreview() { return; } const auto links = _previewLinks; - _previewRequest = session().api().request(MTPmessages_GetWebPagePreview( + _previewRequest = _api.request(MTPmessages_GetWebPagePreview( MTP_flags(0), MTP_string(links), MTPVector() diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index 7f4ada7a6..baa297a82 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/input_fields.h" #include "ui/effects/animations.h" #include "ui/rp_widget.h" +#include "mtproto/sender.h" #include "base/flags.h" #include "base/timer.h" @@ -335,6 +336,7 @@ private: using TabbedSelector = ChatHelpers::TabbedSelector; using DragState = Storage::MimeDataState; struct BotCallbackInfo { + not_null session; UserData *bot; FullMsgId msgId; int row, col; @@ -567,8 +569,8 @@ private: void createUnreadBarAndResize(); void saveEditMsg(); - void saveEditMsgDone(not_null history, const MTPUpdates &updates, mtpRequestId requestId); - void saveEditMsgFail(not_null history, const RPCError &error, mtpRequestId requestId); + static void SaveEditMsgDone(not_null history, const MTPUpdates &updates, mtpRequestId requestId); + static void SaveEditMsgFail(not_null history, const RPCError &error, mtpRequestId requestId); void checkPreview(); void requestPreview(); @@ -578,8 +580,10 @@ private: void addMessagesToFront(PeerData *peer, const QVector &messages); void addMessagesToBack(PeerData *peer, const QVector &messages); - void botCallbackDone(BotCallbackInfo info, const MTPmessages_BotCallbackAnswer &answer, mtpRequestId req); - bool botCallbackFail(BotCallbackInfo info, const RPCError &error, mtpRequestId req); + static void UnpinMessage(not_null peer); + + static void BotCallbackDone(BotCallbackInfo info, const MTPmessages_BotCallbackAnswer &answer, mtpRequestId req); + static void BotCallbackFail(BotCallbackInfo info, const RPCError &error, mtpRequestId req); void updateHistoryGeometry(bool initial = false, bool loadedDown = false, const ScrollChange &change = { ScrollChangeNone, 0 }); void updateListSize(); @@ -644,6 +648,7 @@ private: void setupScheduledToggle(); void refreshScheduledToggle(); + MTP::Sender _api; MsgId _replyToId = 0; Ui::Text::String _replyToName; int _replyToNameVersion = 0; From c15019dee6110c84cd1e182dd617f6d7deb2e78d Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 18:26:44 +0400 Subject: [PATCH 20/37] Fix crashes in MainWidget and ApiWrap. --- Telegram/SourceFiles/apiwrap.h | 1 - Telegram/SourceFiles/boxes/background_preview_box.cpp | 4 ++-- Telegram/SourceFiles/core/local_url_handlers.cpp | 10 +++++----- Telegram/SourceFiles/mainwidget.cpp | 6 +++--- Telegram/SourceFiles/mainwidget.h | 2 ++ Telegram/SourceFiles/window/window_peer_menu.cpp | 4 ++-- .../SourceFiles/window/window_session_controller.h | 7 ++----- 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.h b/Telegram/SourceFiles/apiwrap.h index f88e2ac3b..b3dd94624 100644 --- a/Telegram/SourceFiles/apiwrap.h +++ b/Telegram/SourceFiles/apiwrap.h @@ -368,7 +368,6 @@ public: not_null peer, const std::vector> &users); - rpl::producer sendActions() const { return _sendActions.events(); } diff --git a/Telegram/SourceFiles/boxes/background_preview_box.cpp b/Telegram/SourceFiles/boxes/background_preview_box.cpp index 8de1d447a..e3f45eae5 100644 --- a/Telegram/SourceFiles/boxes/background_preview_box.cpp +++ b/Telegram/SourceFiles/boxes/background_preview_box.cpp @@ -781,12 +781,12 @@ bool BackgroundPreviewBox::Start( Ui::show(Box(tr::lng_background_bad_link(tr::now))); return false; } - controller->session().api().requestWallPaper(slug, [=]( + controller->session().api().requestWallPaper(slug, crl::guard(controller, [=]( const Data::WallPaper &result) { Ui::show(Box( controller, result.withUrlParams(params))); - }, [](const RPCError &error) { + }), [](const RPCError &error) { Ui::show(Box(tr::lng_background_bad_link(tr::now))); }); return true; diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index 0958c4995..d70f75e4a 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -321,12 +321,12 @@ bool ResolvePrivatePost( if (!channelId || !IsServerMsgId(msgId)) { return false; } - const auto done = [=](not_null peer) { - App::wnd()->sessionController()->showPeerHistory( + const auto done = crl::guard(controller, [=](not_null peer) { + controller->showPeerHistory( peer->id, Window::SectionShow::Way::Forward, msgId); - }; + }); const auto fail = [=] { Ui::show(Box(tr::lng_error_post_link_invalid(tr::now))); }; @@ -388,7 +388,7 @@ bool HandleUnknown( return false; } const auto request = match->captured(1); - const auto callback = [=](const MTPDhelp_deepLinkInfo &result) { + const auto callback = crl::guard(controller, [=](const MTPDhelp_deepLinkInfo &result) { const auto text = TextWithEntities{ qs(result.vmessage()), Api::EntitiesFromMTP( @@ -408,7 +408,7 @@ bool HandleUnknown( } else { Ui::show(Box(text)); } - }; + }); controller->session().api().requestDeepLinkInfo(request, callback); return true; } diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 6f27ebba4..2d3214403 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -230,6 +230,7 @@ MainWidget::MainWidget( not_null controller) : RpWidget(parent) , _controller(controller) +, _api(&controller->session().mtp()) , _dialogsWidth(st::columnMinimalWidthLeft) , _thirdColumnWidth(st::columnMinimalWidthThird) , _sideShadow(this) @@ -1264,7 +1265,6 @@ void MainWidget::scheduleViewIncrement(HistoryItem *item) { } void MainWidget::viewsIncrement() { - const auto api = &session().api(); for (auto i = _viewsToIncrement.begin(); i != _viewsToIncrement.cend();) { if (_viewsIncrementRequests.contains(i->first)) { ++i; @@ -1276,7 +1276,7 @@ void MainWidget::viewsIncrement() { for (const auto msgId : i->second) { ids.push_back(MTP_int(msgId)); } - const auto requestId = api->request(MTPmessages_GetMessagesViews( + const auto requestId = _api.request(MTPmessages_GetMessagesViews( i->first->input, MTP_vector(ids), MTP_bool(true) @@ -2624,7 +2624,7 @@ void MainWidget::openPeerByName( }); } } else { - session().api().request(MTPcontacts_ResolveUsername( + _api.request(MTPcontacts_ResolveUsername( MTP_string(username) )).done([=](const MTPcontacts_ResolvedPeer &result) { usernameResolveDone(result, msgId, startToken); diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index ccf8b650e..97a6116cb 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/rp_widget.h" #include "ui/effects/animations.h" #include "media/player/media_player_float.h" +#include "mtproto/sender.h" #include "data/data_pts_waiter.h" class RPCError; @@ -350,6 +351,7 @@ private: void handleHistoryBack(); const not_null _controller; + MTP::Sender _api; Ui::Animations::Simple _a_show; bool _showBack = false; diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index fbbacdd83..cc736bc86 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -1023,7 +1023,7 @@ void PeerMenuAddChannelMembers( return; } const auto api = &channel->session().api(); - api->requestChannelMembersForAdd(channel, [=]( + api->requestChannelMembersForAdd(channel, crl::guard(navigation, [=]( const MTPchannels_ChannelParticipants &result) { api->parseChannelParticipants(channel, result, [&]( int availableCount, @@ -1045,7 +1045,7 @@ void PeerMenuAddChannelMembers( channel, { already.begin(), already.end() }); }); - }); + })); } void PeerMenuAddMuteAction( diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index 6078f8f09..e0520ebee 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -116,7 +116,7 @@ struct SectionShow { class SessionController; -class SessionNavigation { +class SessionNavigation : public base::has_weak_ptr { public: explicit SessionNavigation(not_null session); @@ -156,10 +156,7 @@ private: }; -class SessionController - : public SessionNavigation - , public base::has_weak_ptr - , private base::Subscriber { +class SessionController : public SessionNavigation, private base::Subscriber { public: SessionController( not_null session, From 47c8b852b89109fb17e9edee9a9316dc973152ce Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 18:34:37 +0400 Subject: [PATCH 21/37] Fix possible crash in Dialogs::Widget. --- Telegram/SourceFiles/dialogs/dialogs_widget.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 51da21c0f..46ee3f826 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -1779,6 +1779,8 @@ void Widget::onDialogMoved(int movedFrom, int movedTo) { } } -Widget::~Widget() = default; +Widget::~Widget() { + cancelSearchRequest(); +} } // namespace Dialogs From 3c028590b160e17471d3c6fc11f7a05082c58c53 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 19:04:52 +0400 Subject: [PATCH 22/37] Fix crash in StickersListWidget. --- .../SourceFiles/chat_helpers/stickers_list_widget.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index 85f9b2e75..101ce96c8 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -2508,7 +2508,11 @@ void StickersListWidget::refreshRecentStickers(bool performResize) { externalLayout, std::move(recentPack)); if (recentIt == _mySets.end()) { - _mySets.push_back(std::move(set)); + const auto where = (_mySets.empty() + || _mySets.begin()->id != Data::Stickers::FavedSetId) + ? _mySets.begin() + : (_mySets.begin() + 1); + _mySets.insert(where, std::move(set)); } else { std::swap(*recentIt, set); takeHeavyData(*recentIt, set); @@ -2533,7 +2537,7 @@ void StickersListWidget::refreshFavedStickers() { const auto set = it->second.get(); const auto externalLayout = false; const auto shortName = QString(); - _mySets.emplace_back( + _mySets.insert(_mySets.begin(), Set{ Data::Stickers::FavedSetId, nullptr, (MTPDstickerSet::Flag::f_official @@ -2542,7 +2546,8 @@ void StickersListWidget::refreshFavedStickers() { shortName, set->count, externalLayout, - PrepareStickers(set->stickers)); + PrepareStickers(set->stickers) + }); _favedStickersMap = base::flat_set> { set->stickers.begin(), set->stickers.end() From 7d0eb3ba8ea8017fa697664306af5745efeff30b Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 19:05:12 +0400 Subject: [PATCH 23/37] Fix crash in MainWidget setup with audio player. --- .../SourceFiles/dialogs/dialogs_inner_widget.cpp | 2 +- Telegram/SourceFiles/dialogs/dialogs_widget.cpp | 12 ++++++------ Telegram/SourceFiles/mainwidget.cpp | 5 +++++ .../SourceFiles/window/window_session_controller.h | 10 ++++++++++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 47159854e..a64d7f9bb 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -3016,7 +3016,7 @@ void InnerWidget::setupShortcuts() { }) | rpl::start_with_next([=](not_null request) { using Command = Shortcuts::Command; - if (_controller->content()->selectingPeer()) { + if (_controller->selectingPeer()) { return; } const auto row = _controller->activeChatEntryCurrent(); diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 46ee3f826..4086eeafb 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -212,7 +212,7 @@ Widget::Widget( }); _inner->chosenRow( ) | rpl::start_with_next([=](const ChosenRow &row) { - const auto openSearchResult = !controller->content()->selectingPeer() + const auto openSearchResult = !controller->selectingPeer() && row.filteredRow; if (const auto history = row.key.history()) { controller->content()->choosePeer( @@ -701,7 +701,7 @@ void Widget::escape() { } else if (controller()->activeChatsFilterCurrent()) { controller()->setActiveChatsFilter(FilterId(0)); } - } else if (!_searchInChat && !controller()->content()->selectingPeer()) { + } else if (!_searchInChat && !controller()->selectingPeer()) { if (controller()->activeChatEntryCurrent().key) { emit cancelled(); } @@ -1260,7 +1260,7 @@ void Widget::peopleFailed(const RPCError &error, mtpRequestId requestId) { void Widget::dragEnterEvent(QDragEnterEvent *e) { using namespace Storage; - if (controller()->content()->selectingPeer()) { + if (controller()->selectingPeer()) { return; } @@ -1609,7 +1609,7 @@ void Widget::updateControlsGeometry() { } void Widget::updateForwardBar() { - auto selecting = controller()->content()->selectingPeer(); + auto selecting = controller()->selectingPeer(); auto oneColumnSelecting = (Adaptive::OneColumn() && selecting); if (!oneColumnSelecting == !_forwardCancel) { return; @@ -1752,7 +1752,7 @@ bool Widget::onCancelSearch() { void Widget::onCancelSearchInChat() { cancelSearchRequest(); if (_searchInChat) { - if (Adaptive::OneColumn() && !controller()->content()->selectingPeer()) { + if (Adaptive::OneColumn() && !controller()->selectingPeer()) { if (const auto peer = _searchInChat.peer()) { Ui::showPeerHistory(peer, ShowAtUnreadMsgId); //} else if (const auto feed = _searchInChat.feed()) { // #feed @@ -1767,7 +1767,7 @@ void Widget::onCancelSearchInChat() { _filter->clear(); _filter->updatePlaceholder(); applyFilterUpdate(); - if (!Adaptive::OneColumn() && !controller()->content()->selectingPeer()) { + if (!Adaptive::OneColumn() && !controller()->selectingPeer()) { emit cancelled(); } } diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 2d3214403..a6f20da2f 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -612,6 +612,8 @@ void MainWidget::clearHider(not_null instance) { return; } _hider.release(); + controller()->setSelectingPeer(false); + if (Adaptive::OneColumn()) { if (_mainSection || (_history->peer() && _history->peer()->id)) { auto animationParams = ([=] { @@ -637,6 +639,8 @@ void MainWidget::hiderLayer(base::unique_qptr hider) { } _hider = std::move(hider); + controller()->setSelectingPeer(true); + _hider->setParent(this); _hider->hidden( @@ -1407,6 +1411,7 @@ void MainWidget::ui_showPeerHistory( if (_hider) { _hider->startHide(); _hider.release(); + controller()->setSelectingPeer(false); } auto animatedShow = [&] { diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index e0520ebee..16ea70d44 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -168,6 +168,15 @@ public: [[nodiscard]] not_null<::MainWindow*> widget() const; [[nodiscard]] not_null content() const; + // We need access to this from MainWidget::MainWidget, where + // we can't call content() yet. + void setSelectingPeer(bool selecting) { + _selectingPeer = selecting; + } + [[nodiscard]] bool selectingPeer() const { + return _selectingPeer; + } + [[nodiscard]] auto tabbedSelector() const -> not_null; void takeTabbedSelectorOwnershipFrom(not_null parent); @@ -331,6 +340,7 @@ private: base::Variable _dialogsListDisplayForced = { false }; std::deque _chatEntryHistory; int _chatEntryHistoryPosition = -1; + bool _selectingPeer = false; rpl::variable _activeChatsFilter; From d529c60081f87a6190e8e8dab399690dbfa93cf2 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 19:13:57 +0400 Subject: [PATCH 24/37] Fix crash in MainMenu hiding on external logout. --- .../SourceFiles/window/window_main_menu.cpp | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index 327a77724..158c68863 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -101,7 +101,7 @@ private: void paintEvent(QPaintEvent *e) override; void paintUserpic(Painter &p); - const not_null _account; + const not_null _session; const style::Menu &_st; std::shared_ptr _userpicView; InMemoryKey _userpicKey = {}; @@ -153,7 +153,7 @@ MainMenu::AccountButton::AccountButton( QWidget *parent, not_null account) : RippleButton(parent, st::defaultRippleAnimation) -, _account(account) +, _session(&account->session()) , _st(st::mainMenu){ const auto height = _st.itemPadding.top() + _st.itemStyle.font->height @@ -167,33 +167,27 @@ MainMenu::AccountButton::AccountButton( } }); - _account->sessionValue( - ) | rpl::filter([=](Main::Session *session) { - return (session != nullptr); - }) | rpl::start_with_next([=](not_null session) { - rpl::single( - rpl::empty_value() - ) | rpl::then( - session->data().unreadBadgeChanges() - ) | rpl::start_with_next([=] { - _unreadBadge = session->data().unreadBadge(); - _unreadBadgeMuted = session->data().unreadBadgeMuted(); - update(); - }, lifetime()); + rpl::single( + rpl::empty_value() + ) | rpl::then( + _session->data().unreadBadgeChanges() + ) | rpl::start_with_next([=] { + _unreadBadge = _session->data().unreadBadge(); + _unreadBadgeMuted = _session->data().unreadBadgeMuted(); + update(); }, lifetime()); } void MainMenu::AccountButton::paintUserpic(Painter &p) { - Expects(_account->sessionExists()); - const auto size = st::mainMenuAccountSize; const auto iconSize = height() - 2 * _st.itemIconPosition.y(); const auto shift = (size - iconSize) / 2; const auto x = _st.itemIconPosition.x() - shift; const auto y = (height() - size) / 2; - const auto check = (_account == &Core::App().domain().active()); - const auto user = _account->session().user(); + const auto check = (&_session->account() + == &Core::App().domain().active()); + const auto user = _session->user(); if (!check) { user->paintUserpicLeft(p, _userpicView, x, y, width(), size); return; @@ -234,8 +228,6 @@ void MainMenu::AccountButton::paintUserpic(Painter &p) { } void MainMenu::AccountButton::paintEvent(QPaintEvent *e) { - Expects(_account->sessionExists()); - auto p = Painter(this); const auto over = isOver(); p.fillRect(rect(), over ? _st.itemBgOver : _st.itemBg); @@ -244,7 +236,8 @@ void MainMenu::AccountButton::paintEvent(QPaintEvent *e) { paintUserpic(p); auto available = width() - _st.itemPadding.left(); - if (_unreadBadge && _account != &Core::App().activeAccount()) { + if (_unreadBadge + && (&_session->account() != &Core::App().activeAccount())) { _unreadSt.muted = _unreadBadgeMuted; const auto string = (_unreadBadge > 99) ? "99+" @@ -267,7 +260,7 @@ void MainMenu::AccountButton::paintEvent(QPaintEvent *e) { } p.setPen(over ? _st.itemFgOver : _st.itemFg); - _account->session().user()->nameText().drawElided( + _session->user()->nameText().drawElided( p, _st.itemPadding.left(), _st.itemPadding.top(), From 41f2cc6d81c8d874dd55cd4ee491bec15d7dc324 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 19:33:22 +0400 Subject: [PATCH 25/37] Fix crash in notifications clearing. --- Telegram/SourceFiles/core/application.cpp | 1 + Telegram/SourceFiles/core/application.h | 9 +++++---- .../SourceFiles/window/notifications_manager_default.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index cfeaf930f..19bd5000c 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -153,6 +153,7 @@ Application::~Application() { _window = nullptr; _mediaView = nullptr; + _notifications->clearAllFast(); _domain->finish(); Local::finish(); diff --git a/Telegram/SourceFiles/core/application.h b/Telegram/SourceFiles/core/application.h index da79b9b7f..4215a9828 100644 --- a/Telegram/SourceFiles/core/application.h +++ b/Telegram/SourceFiles/core/application.h @@ -331,6 +331,11 @@ private: base::Timer _clearEmojiImageLoaderTimer; const std::unique_ptr _audio; mutable std::unique_ptr _fallbackProductionConfig; + + // Notifications should be destroyed before _audio, after _domain. + // Mutable because is created in run() after OpenSSL is inited. + std::unique_ptr _notifications; + const std::unique_ptr _domain; const std::unique_ptr _exportManager; const std::unique_ptr _calls; @@ -347,10 +352,6 @@ private: Media::Player::FloatDelegate *_defaultFloatPlayerDelegate = nullptr; Media::Player::FloatDelegate *_replacementFloatPlayerDelegate = nullptr; - // Notifications should be destroyed before _audio. - // Mutable because is created in run() after OpenSSL is inited. - std::unique_ptr _notifications; - const QImage _logo; const QImage _logoNoMargin; diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp index d9eba08a3..2932e89ae 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.cpp +++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp @@ -192,7 +192,7 @@ void Manager::showNextFromQueue() { return; } int count = Core::App().settings().notificationsCount(); - for_const (auto ¬ification, _notifications) { + for (const auto ¬ification : _notifications) { if (notification->isUnlinked()) continue; --count; } From 20ea3af2f0bb6485cc2dba708c7ddc6b71607e83 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 20:01:17 +0400 Subject: [PATCH 26/37] Fix crash in edited and replied message destruction. --- Telegram/SourceFiles/history/history_widget.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index eed9a4a08..5391be57c 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -4943,12 +4943,11 @@ void HistoryWidget::updateControlsGeometry() { } void HistoryWidget::itemRemoved(not_null item) { - if (item == _replyEditMsg) { - if (_editMsgId) { - cancelEdit(); - } else { - cancelReply(); - } + if (item == _replyEditMsg && _editMsgId) { + cancelEdit(); + } + if (item == _replyEditMsg && _replyToId) { + cancelReply(); } while (item == _replyReturn) { calcNextReplyReturn(); From 5ea5d3c60db9ccbb929f89378128648f47ae83aa Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 20:22:47 +0400 Subject: [PATCH 27/37] Fix empty web page preview removing. --- Telegram/SourceFiles/data/data_session.cpp | 1 + Telegram/SourceFiles/data/stickers/data_stickers.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index a9c32d861..22d16d5bf 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -2559,6 +2559,7 @@ not_null Session::processWebpage(const MTPWebPage &data) { const auto result = webpage(data.c_webPageEmpty().vid().v); if (result->pendingTill > 0) { result->pendingTill = -1; // failed + notifyWebPageUpdateDelayed(result); } return result; } break; diff --git a/Telegram/SourceFiles/data/stickers/data_stickers.cpp b/Telegram/SourceFiles/data/stickers/data_stickers.cpp index 08ef4297c..c60c3db5c 100644 --- a/Telegram/SourceFiles/data/stickers/data_stickers.cpp +++ b/Telegram/SourceFiles/data/stickers/data_stickers.cpp @@ -892,7 +892,7 @@ void Stickers::gifsReceived(const QVector &items, int32 hash) { const auto document = owner().processDocument(item); if (!document->isGifv()) { LOG(("API Error: " - "bad document returned in HistoryWidget::savedGifsGot!")); + "bad document returned in Stickers::gifsReceived!")); continue; } From 9fb12b609346c5ff32a951c173743c681e1cfaed Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 20:41:25 +0400 Subject: [PATCH 28/37] Set correct username to crash annotations. --- Telegram/SourceFiles/data/data_session.cpp | 3 --- Telegram/SourceFiles/main/main_domain.cpp | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 22d16d5bf..2dfcc24a9 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -462,9 +462,6 @@ not_null Session::processUser(const MTPUser &data) { : QString()) : result->nameOrPhone; - if (!minimal && data.is_self() && uname != result->username) { - CrashReports::SetAnnotation("Username", uname); - } result->setName(fname, lname, pname, uname); if (const auto photo = data.vphoto()) { result->setPhoto(*photo); diff --git a/Telegram/SourceFiles/main/main_domain.cpp b/Telegram/SourceFiles/main/main_domain.cpp index 5f139504f..4badf2727 100644 --- a/Telegram/SourceFiles/main/main_domain.cpp +++ b/Telegram/SourceFiles/main/main_domain.cpp @@ -9,9 +9,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/application.h" #include "core/shortcuts.h" +#include "core/crash_reports.h" #include "main/main_account.h" #include "main/main_session.h" #include "data/data_session.h" +#include "data/data_changes.h" +#include "data/data_user.h" #include "mtproto/mtproto_config.h" #include "mtproto/mtproto_dc_options.h" #include "storage/storage_domain.h" @@ -31,6 +34,21 @@ Domain::Domain(const QString &dataName) Local::rewriteSettingsIfNeeded(); Core::App().notifications().createManager(); }, _lifetime); + + _active.changes( + ) | rpl::map([](Main::Account *account) { + return account ? account->sessionValue() : rpl::never(); + }) | rpl::flatten_latest( + ) | rpl::map([](Main::Session *session) { + return session + ? session->changes().peerFlagsValue( + session->user(), + Data::PeerUpdate::Flag::Username) + : rpl::never(); + }) | rpl::flatten_latest( + ) | rpl::start_with_next([](const Data::PeerUpdate &update) { + CrashReports::SetAnnotation("Username", update.peer->userName()); + }, _lifetime); } Domain::~Domain() = default; From dd0e0a10cd9d96f3bf985c0c82a043a23be108af Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 21:15:35 +0400 Subject: [PATCH 29/37] Add Activate/Logout context menu in accounts list. --- Telegram/Resources/langs/lang.strings | 1 + .../SourceFiles/window/window_main_menu.cpp | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 836f4d786..acc9ba08d 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_menu_back" = "Back"; "lng_menu_night_mode" = "Night Mode"; "lng_menu_add_account" = "Add Account"; +"lng_menu_activate" = "Activate"; "lng_disable_notifications_from_tray" = "Disable notifications"; "lng_enable_notifications_from_tray" = "Enable notifications"; diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index 158c68863..a9f2e65a2 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "settings/settings_common.h" #include "base/qt_signal_producer.h" #include "boxes/about_box.h" +#include "boxes/confirm_box.h" #include "boxes/peer_list_controllers.h" #include "calls/calls_box_controller.h" #include "lang/lang_keys.h" @@ -52,6 +53,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_dialogs.h" #include "styles/style_settings.h" #include "styles/style_boxes.h" +#include "styles/style_layers.h" #include #include @@ -99,6 +101,7 @@ public: private: void paintEvent(QPaintEvent *e) override; + void contextMenuEvent(QContextMenuEvent *e) override; void paintUserpic(Painter &p); const not_null _session; @@ -106,6 +109,7 @@ private: std::shared_ptr _userpicView; InMemoryKey _userpicKey = {}; QImage _userpicCache; + base::unique_qptr _menu; Dialogs::Layout::UnreadBadgeStyle _unreadSt; int _unreadBadge = 0; @@ -267,6 +271,32 @@ void MainMenu::AccountButton::paintEvent(QPaintEvent *e) { available); } +void MainMenu::AccountButton::contextMenuEvent(QContextMenuEvent *e) { + if (&_session->account() == &Core::App().activeAccount() || _menu) { + return; + } + _menu = base::make_unique_q(this); + _menu->addAction(tr::lng_menu_activate(tr::now), crl::guard(this, [=] { + Core::App().domain().activate(&_session->account()); + })); + _menu->addAction(tr::lng_settings_logout(tr::now), crl::guard(this, [=] { + const auto session = _session; + const auto box = std::make_shared>(); + const auto callback = [=] { + if (*box) { + (*box)->closeBox(); + } + Core::App().logout(&session->account()); + }; + *box = Ui::show(Box( + tr::lng_sure_logout(tr::now), + tr::lng_settings_logout(tr::now), + st::attentionBoxButton, + crl::guard(session, callback))); + })); + _menu->popup(QCursor::pos()); +} + MainMenu::ToggleAccountsButton::ToggleAccountsButton(QWidget *parent) : AbstractButton(parent) { rpl::single( From 5cc7c2b6c6ecdce1ab4067549c4e7acd299dd5d5 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 21:16:05 +0400 Subject: [PATCH 30/37] Add account from settings three-dot menu. --- Telegram/SourceFiles/main/main_domain.cpp | 14 ++++++++++++++ Telegram/SourceFiles/main/main_domain.h | 1 + Telegram/SourceFiles/settings/settings_common.cpp | 8 ++++++++ Telegram/SourceFiles/window/window_main_menu.cpp | 13 +------------ 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Telegram/SourceFiles/main/main_domain.cpp b/Telegram/SourceFiles/main/main_domain.cpp index 4badf2727..d9525fb73 100644 --- a/Telegram/SourceFiles/main/main_domain.cpp +++ b/Telegram/SourceFiles/main/main_domain.cpp @@ -273,6 +273,20 @@ not_null Domain::add(MTP::Environment environment) { return account; } +void Domain::addActivated(MTP::Environment environment) { + if (accounts().size() < Main::Domain::kMaxAccounts) { + activate(add(environment)); + } else { + for (auto &[index, account] : accounts()) { + if (!account->sessionExists() + && account->mtp().environment() == environment) { + activate(account.get()); + break; + } + } + } +} + void Domain::watchSession(not_null account) { account->sessionValue( ) | rpl::filter([=](Session *session) { diff --git a/Telegram/SourceFiles/main/main_domain.h b/Telegram/SourceFiles/main/main_domain.h index 6e9da8386..4adadf21e 100644 --- a/Telegram/SourceFiles/main/main_domain.h +++ b/Telegram/SourceFiles/main/main_domain.h @@ -64,6 +64,7 @@ public: [[nodiscard]] not_null add(MTP::Environment environment); void activate(not_null account); + void addActivated(MTP::Environment environment); // Interface for Storage::Domain. void accountAddedInStorage(AccountWithIndex accountWithIndex); diff --git a/Telegram/SourceFiles/settings/settings_common.cpp b/Telegram/SourceFiles/settings/settings_common.cpp index 76b9f40bc..0b6dc0390 100644 --- a/Telegram/SourceFiles/settings/settings_common.cpp +++ b/Telegram/SourceFiles/settings/settings_common.cpp @@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "settings/settings_privacy_security.h" #include "settings/settings_folders.h" #include "settings/settings_calls.h" +#include "core/application.h" #include "ui/wrap/padding_wrap.h" #include "ui/wrap/vertical_layout.h" #include "ui/widgets/labels.h" @@ -27,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "mainwindow.h" #include "main/main_session.h" +#include "main/main_domain.h" #include "styles/style_layers.h" #include "styles/style_settings.h" @@ -195,6 +197,12 @@ void FillMenu( tr::lng_settings_bg_theme_create(tr::now), [=] { window->show(Box(Window::Theme::CreateBox, window)); }); } else { + const auto &list = Core::App().domain().accounts(); + if (list.size() < ::Main::Domain::kMaxAccounts) { + addAction(tr::lng_menu_add_account(tr::now), [=] { + Core::App().domain().addActivated(MTP::Environment{}); + }); + } if (!controller->session().supportMode()) { addAction( tr::lng_settings_information(tr::now), diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index a9f2e65a2..b4723b80c 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -799,18 +799,7 @@ not_null*> MainMenu::setupAddAccount( }, button->lifetime()); const auto add = [=](MTP::Environment environment) { - auto &domain = Core::App().domain(); - if (domain.accounts().size() < Main::Domain::kMaxAccounts) { - domain.activate(domain.add(environment)); - } else { - for (auto &[index, account] : domain.accounts()) { - if (!account->sessionExists() - && account->mtp().environment() == environment) { - domain.activate(account.get()); - break; - } - } - } + Core::App().domain().addActivated(environment); }; button->setAcceptBoth(true); From 1dc31c7f2f7cc19569209c62a1b4efe4b2060cce Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 22:11:48 +0400 Subject: [PATCH 31/37] Allow turning off inactive accounts notifications. --- Telegram/Resources/langs/lang.strings | 3 ++ Telegram/SourceFiles/core/core_settings.cpp | 9 +++- Telegram/SourceFiles/core/core_settings.h | 7 ++++ .../settings/settings_notifications.cpp | 41 +++++++++++++++++++ .../window/notifications_manager.cpp | 3 ++ 5 files changed, 61 insertions(+), 2 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index acc9ba08d..7787db0a0 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -292,6 +292,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_settings_empty_bio" = "None"; "lng_settings_section_notify" = "Notifications"; +"lng_settings_show_from" = "Show notifications from"; +"lng_settings_notify_all" = "All accounts"; +"lng_settings_notify_all_about" = "Turn this off if you want to receive notifications only from the account you are currently using."; "lng_settings_notify_title" = "Notifications for chats"; "lng_settings_desktop_notify" = "Desktop notifications"; "lng_settings_show_name" = "Show sender's name"; diff --git a/Telegram/SourceFiles/core/core_settings.cpp b/Telegram/SourceFiles/core/core_settings.cpp index 41be395df..5e7cb62b5 100644 --- a/Telegram/SourceFiles/core/core_settings.cpp +++ b/Telegram/SourceFiles/core/core_settings.cpp @@ -104,7 +104,8 @@ QByteArray Settings::serialize() const { 0, 1000000)) << qint32(_thirdColumnWidth.current()) - << qint32(_thirdSectionExtendedBy); + << qint32(_thirdSectionExtendedBy) + << qint32(_notifyFromAll ? 1 : 0); } return result; } @@ -167,6 +168,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) { float64 dialogsWidthRatio = _dialogsWidthRatio.current(); qint32 thirdColumnWidth = _thirdColumnWidth.current(); qint32 thirdSectionExtendedBy = _thirdSectionExtendedBy; + qint32 notifyFromAll = _notifyFromAll ? 1 : 0; stream >> themesAccentColors; if (!stream.atEnd()) { @@ -237,7 +239,8 @@ void Settings::addFromSerialized(const QByteArray &serialized) { >> thirdSectionInfoEnabled >> dialogsWidthRatioInt >> thirdColumnWidth - >> thirdSectionExtendedBy; + >> thirdSectionExtendedBy + >> notifyFromAll; dialogsWidthRatio = snap(dialogsWidthRatioInt / 1000000., 0., 1.); } if (stream.status() != QDataStream::Ok) { @@ -331,6 +334,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) { if (_thirdSectionInfoEnabled) { _tabbedSelectorSectionEnabled = false; } + _notifyFromAll = (notifyFromAll == 1); } bool Settings::chatWide() const { @@ -462,6 +466,7 @@ void Settings::resetOnLastLogout() { _thirdSectionExtendedBy = -1; // per-window _dialogsWidthRatio = DefaultDialogsWidthRatio(); // per-window _thirdColumnWidth = kDefaultThirdColumnWidth; // p-w + _notifyFromAll = true; _tabbedReplacedWithInfo = false; // per-window } diff --git a/Telegram/SourceFiles/core/core_settings.h b/Telegram/SourceFiles/core/core_settings.h index 907e37fd5..cedbe6a94 100644 --- a/Telegram/SourceFiles/core/core_settings.h +++ b/Telegram/SourceFiles/core/core_settings.h @@ -401,6 +401,12 @@ public: void setThirdColumnWidth(int width); [[nodiscard]] int thirdColumnWidth() const; [[nodiscard]] rpl::producer thirdColumnWidthChanges() const; + void setNotifyFromAll(bool value) { + _notifyFromAll = value; + } + [[nodiscard]] bool notifyFromAll() const { + return _notifyFromAll; + } [[nodiscard]] static bool ThirdColumnByDefault(); [[nodiscard]] float64 DefaultDialogsWidthRatio(); @@ -467,6 +473,7 @@ private: int _thirdSectionExtendedBy = -1; // per-window rpl::variable _dialogsWidthRatio; // per-window rpl::variable _thirdColumnWidth = kDefaultThirdColumnWidth; // p-w + bool _notifyFromAll = true; bool _tabbedReplacedWithInfo = false; // per-window rpl::event_stream _tabbedReplacedWithInfoValue; // per-window diff --git a/Telegram/SourceFiles/settings/settings_notifications.cpp b/Telegram/SourceFiles/settings/settings_notifications.cpp index 2608d5737..daf4d1fcd 100644 --- a/Telegram/SourceFiles/settings/settings_notifications.cpp +++ b/Telegram/SourceFiles/settings/settings_notifications.cpp @@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwindow.h" #include "core/application.h" #include "main/main_session.h" +#include "main/main_account.h" #include "main/main_domain.h" #include "apiwrap.h" #include "facades.h" @@ -540,9 +541,49 @@ void SetupAdvancedNotifications( AddSkip(container, st::settingsCheckboxesSkip); } +void SetupMultiAccountNotifications( + not_null controller, + not_null container) { + if (Core::App().domain().accounts().size() < 2) { + return; + } + AddSubsectionTitle(container, tr::lng_settings_show_from()); + + const auto fromAll = container->add( + object_ptr( + container, + tr::lng_settings_notify_all(tr::now), + Core::App().settings().notifyFromAll(), + st::settingsCheckbox), + st::settingsCheckboxPadding); + fromAll->checkedChanges( + ) | rpl::filter([](bool checked) { + return (checked != Core::App().settings().notifyFromAll()); + }) | rpl::start_with_next([=](bool checked) { + Core::App().settings().setNotifyFromAll(checked); + Core::App().saveSettingsDelayed(); + if (!checked) { + auto ¬ifications = Core::App().notifications(); + const auto &list = Core::App().domain().accounts(); + for (const auto &[index, account] : list) { + if (account.get() == &Core::App().domain().active()) { + continue; + } else if (const auto session = account->maybeSession()) { + notifications.clearFromSession(session); + } + } + } + }, fromAll->lifetime()); + + AddSkip(container); + AddDividerText(container, tr::lng_settings_notify_all_about()); +} + void SetupNotificationsContent( not_null controller, not_null container) { + SetupMultiAccountNotifications(controller, container); + AddSubsectionTitle(container, tr::lng_settings_notify_title()); const auto session = &controller->session(); diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index f9f78850f..e6d772506 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -89,6 +89,9 @@ System::SkipState System::skipNotification( const auto notifyBy = item->specialNotificationPeer(); if (App::quitting() || !history->currentNotification()) { return { SkipState::Skip }; + } else if (!Core::App().settings().notifyFromAll() + && &history->session().account() != &Core::App().domain().active()) { + return { SkipState::Skip }; } const auto scheduled = item->out() && item->isFromScheduled(); From dd76d54aebf7d82d10c086793d64aa411f7e1c92 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 30 Jun 2020 16:36:11 +0400 Subject: [PATCH 32/37] Fix build with TDESKTOP_DISABLE_GTK_INTEGRATION --- Telegram/SourceFiles/platform/linux/specific_linux.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index eb237960a..931e342ff 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -521,6 +521,7 @@ QString GetIconName() { } bool GtkClipboardSupported() { +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION return (Libs::gtk_clipboard_get != nullptr) && (Libs::gtk_clipboard_wait_for_contents != nullptr) && (Libs::gtk_clipboard_wait_for_image != nullptr) @@ -532,6 +533,9 @@ bool GtkClipboardSupported() { && (Libs::gdk_pixbuf_get_rowstride != nullptr) && (Libs::gdk_pixbuf_get_has_alpha != nullptr) && (Libs::gdk_atom_intern != nullptr); +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION + + return false; } QImage GetImageFromClipboard() { From e7c598e533525756b1e492b67f9c92b6e17ad551 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 30 Jun 2020 15:24:00 +0400 Subject: [PATCH 33/37] Reset cursor on window leave --- Telegram/SourceFiles/window/window_title_qt.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Telegram/SourceFiles/window/window_title_qt.cpp b/Telegram/SourceFiles/window/window_title_qt.cpp index 17edd2368..92dd3d9da 100644 --- a/Telegram/SourceFiles/window/window_title_qt.cpp +++ b/Telegram/SourceFiles/window/window_title_qt.cpp @@ -116,6 +116,12 @@ bool TitleWidgetQt::eventFilter(QObject *obj, QEvent *e) { return startResize(mouseEvent->windowPos().toPoint()); } } + } else if (e->type() == QEvent::Leave) { + if (window() == static_cast(obj)) { + while (QGuiApplication::overrideCursor()) { + QGuiApplication::restoreOverrideCursor(); + } + } } return TitleWidget::eventFilter(obj, e); From e050055c1eca4bb73a4349cec562cef9adb910b8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Jun 2020 22:17:36 +0400 Subject: [PATCH 34/37] Beta version 2.1.15. - Receive notifications only from the active account in Settings > Notifications. - Fix saving chats list width between application relaunches. - Multiple crash fixes. --- Telegram/Resources/uwp/AppX/AppxManifest.xml | 2 +- Telegram/Resources/winrc/Telegram.rc | 8 ++++---- Telegram/Resources/winrc/Updater.rc | 8 ++++---- Telegram/SourceFiles/core/version.h | 4 ++-- Telegram/build/version | 8 ++++---- changelog.txt | 6 ++++++ 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml index feb557542..11c19f66f 100644 --- a/Telegram/Resources/uwp/AppX/AppxManifest.xml +++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml @@ -9,7 +9,7 @@ + Version="2.1.15.0" /> Telegram Desktop Telegram FZ-LLC diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index 96a5eefb3..e42be221b 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -44,8 +44,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,1,14,0 - PRODUCTVERSION 2,1,14,0 + FILEVERSION 2,1,15,0 + PRODUCTVERSION 2,1,15,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -62,10 +62,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop" - VALUE "FileVersion", "2.1.14.0" + VALUE "FileVersion", "2.1.15.0" VALUE "LegalCopyright", "Copyright (C) 2014-2020" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "2.1.14.0" + VALUE "ProductVersion", "2.1.15.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index 337a5df9a..83e3fea9b 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -35,8 +35,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,1,14,0 - PRODUCTVERSION 2,1,14,0 + FILEVERSION 2,1,15,0 + PRODUCTVERSION 2,1,15,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -53,10 +53,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop Updater" - VALUE "FileVersion", "2.1.14.0" + VALUE "FileVersion", "2.1.15.0" VALUE "LegalCopyright", "Copyright (C) 2014-2020" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "2.1.14.0" + VALUE "ProductVersion", "2.1.15.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index 15e9beac7..43504b674 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -22,7 +22,7 @@ constexpr auto AppId = "{53F49750-6209-4FBF-9CA8-7A333C87D1ED}"_cs; constexpr auto AppNameOld = "Telegram Win (Unofficial)"_cs; constexpr auto AppName = "Telegram Desktop"_cs; constexpr auto AppFile = "Telegram"_cs; -constexpr auto AppVersion = 2001014; -constexpr auto AppVersionStr = "2.1.14"; +constexpr auto AppVersion = 2001015; +constexpr auto AppVersionStr = "2.1.15"; constexpr auto AppBetaVersion = true; constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION; diff --git a/Telegram/build/version b/Telegram/build/version index f96758021..1f50cfbca 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,7 +1,7 @@ -AppVersion 2001014 +AppVersion 2001015 AppVersionStrMajor 2.1 -AppVersionStrSmall 2.1.14 -AppVersionStr 2.1.14 +AppVersionStrSmall 2.1.15 +AppVersionStr 2.1.15 BetaChannel 1 AlphaVersion 0 -AppVersionOriginal 2.1.14.beta +AppVersionOriginal 2.1.15.beta diff --git a/changelog.txt b/changelog.txt index 78c284d2b..a55c216a5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,9 @@ +2.1.15 beta (30.06.20) + +- Receive notifications only from the active account in Settings > Notifications. +- Fix saving chats list width between application relaunches. +- Multiple crash fixes. + 2.1.14 beta (29.06.20) - Support for multiple accounts. From 3c0694280faf7e60ac4c12d6d594e12b8c21bb75 Mon Sep 17 00:00:00 2001 From: Nicholas Guriev Date: Tue, 30 Jun 2020 19:25:27 +0300 Subject: [PATCH 35/37] Fix -Wredundant-move --- Telegram/SourceFiles/storage/storage_media_prepare.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/storage/storage_media_prepare.cpp b/Telegram/SourceFiles/storage/storage_media_prepare.cpp index 48ce0d75d..2a05a4837 100644 --- a/Telegram/SourceFiles/storage/storage_media_prepare.cpp +++ b/Telegram/SourceFiles/storage/storage_media_prepare.cpp @@ -286,7 +286,6 @@ std::optional PreparedList::PreparedFileFromFilesDialog( } if (!result.remoteContent.isEmpty()) { - auto list = Storage::PrepareMediaFromImage( QImage(), std::move(result.remoteContent), @@ -311,7 +310,7 @@ std::optional PreparedList::PreparedFileFromFilesDialog( } } Expects(list.files.size() == 1); - return std::move(list); + return list; } else if (!result.paths.isEmpty()) { const auto isSingleFile = (result.paths.size() == 1); auto temp = Storage::PrepareMediaList(result.paths, previewWidth); @@ -366,7 +365,7 @@ std::optional PreparedList::PreparedFileFromFilesDialog( list.allFilesForCompress = temp.allFilesForCompress; list.files = std::move(filteredFiles); - return std::move(list); + return list; } return std::nullopt; } From 1a696271026529fae2fb87d5012601a8f0617055 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 1 Jul 2020 00:41:21 +0400 Subject: [PATCH 36/37] Fix crash in reading saved peers. --- Telegram/SourceFiles/storage/serialize_peer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/storage/serialize_peer.cpp b/Telegram/SourceFiles/storage/serialize_peer.cpp index 81fed5dd7..4e8b896bf 100644 --- a/Telegram/SourceFiles/storage/serialize_peer.cpp +++ b/Telegram/SourceFiles/storage/serialize_peer.cpp @@ -204,7 +204,7 @@ PeerData *readPeer( const auto loaded = (peerId == selfId) ? session->user().get() : session->data().peerLoaded(peerId); - const auto apply = (loaded->loadedStatus != PeerData::FullLoaded); + const auto apply = !loaded || (loaded->loadedStatus != PeerData::FullLoaded); const auto result = loaded ? loaded : session->data().peer(peerId).get(); if (apply) { result->loadedStatus = PeerData::FullLoaded; From 0981335ca7332fdb20e0ef80c53c7768cc5c9ba7 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 1 Jul 2020 00:42:00 +0400 Subject: [PATCH 37/37] Beta version 2.1.16. - Crash fix. --- Telegram/Resources/uwp/AppX/AppxManifest.xml | 2 +- Telegram/Resources/winrc/Telegram.rc | 8 ++++---- Telegram/Resources/winrc/Updater.rc | 8 ++++---- Telegram/SourceFiles/core/version.h | 4 ++-- Telegram/build/version | 8 ++++---- changelog.txt | 4 ++++ 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml index 11c19f66f..915dbf61c 100644 --- a/Telegram/Resources/uwp/AppX/AppxManifest.xml +++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml @@ -9,7 +9,7 @@ + Version="2.1.16.0" /> Telegram Desktop Telegram FZ-LLC diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index e42be221b..98d5d1d2b 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -44,8 +44,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,1,15,0 - PRODUCTVERSION 2,1,15,0 + FILEVERSION 2,1,16,0 + PRODUCTVERSION 2,1,16,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -62,10 +62,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop" - VALUE "FileVersion", "2.1.15.0" + VALUE "FileVersion", "2.1.16.0" VALUE "LegalCopyright", "Copyright (C) 2014-2020" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "2.1.15.0" + VALUE "ProductVersion", "2.1.16.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index 83e3fea9b..a29102114 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -35,8 +35,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,1,15,0 - PRODUCTVERSION 2,1,15,0 + FILEVERSION 2,1,16,0 + PRODUCTVERSION 2,1,16,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -53,10 +53,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop Updater" - VALUE "FileVersion", "2.1.15.0" + VALUE "FileVersion", "2.1.16.0" VALUE "LegalCopyright", "Copyright (C) 2014-2020" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "2.1.15.0" + VALUE "ProductVersion", "2.1.16.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index 43504b674..4afb70c7c 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -22,7 +22,7 @@ constexpr auto AppId = "{53F49750-6209-4FBF-9CA8-7A333C87D1ED}"_cs; constexpr auto AppNameOld = "Telegram Win (Unofficial)"_cs; constexpr auto AppName = "Telegram Desktop"_cs; constexpr auto AppFile = "Telegram"_cs; -constexpr auto AppVersion = 2001015; -constexpr auto AppVersionStr = "2.1.15"; +constexpr auto AppVersion = 2001016; +constexpr auto AppVersionStr = "2.1.16"; constexpr auto AppBetaVersion = true; constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION; diff --git a/Telegram/build/version b/Telegram/build/version index 1f50cfbca..71f03d59c 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,7 +1,7 @@ -AppVersion 2001015 +AppVersion 2001016 AppVersionStrMajor 2.1 -AppVersionStrSmall 2.1.15 -AppVersionStr 2.1.15 +AppVersionStrSmall 2.1.16 +AppVersionStr 2.1.16 BetaChannel 1 AlphaVersion 0 -AppVersionOriginal 2.1.15.beta +AppVersionOriginal 2.1.16.beta diff --git a/changelog.txt b/changelog.txt index a55c216a5..756f9b0f7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +2.1.16 beta (01.07.20) + +- Crash fix. + 2.1.15 beta (30.06.20) - Receive notifications only from the active account in Settings > Notifications.