mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +02:00
Count all accounts in Core::App().unreadBadge.
This commit is contained in:
parent
357caf8007
commit
3a5ede534e
34 changed files with 255 additions and 175 deletions
|
@ -245,7 +245,7 @@ ApiWrap::ApiWrap(not_null<Main::Session*> session)
|
|||
, _updateNotifySettingsTimer([=] { sendNotifySettingsUpdates(); })
|
||||
, _selfDestruct(std::make_unique<Api::SelfDestruct>(this))
|
||||
, _sensitiveContent(std::make_unique<Api::SensitiveContent>(this)) {
|
||||
crl::on_main([=] {
|
||||
crl::on_main(session, [=] {
|
||||
// You can't use _session->lifetime() in the constructor,
|
||||
// only queued, because it is not constructed yet.
|
||||
_session->uploader().photoReady(
|
||||
|
|
|
@ -512,10 +512,6 @@ void Application::handleAppDeactivated() {
|
|||
Ui::Tooltip::Hide();
|
||||
}
|
||||
|
||||
void Application::call_handleUnreadCounterUpdate() {
|
||||
Global::RefUnreadCounterUpdate().notify(true);
|
||||
}
|
||||
|
||||
void Application::call_handleObservables() {
|
||||
base::HandleObservables();
|
||||
}
|
||||
|
@ -575,17 +571,15 @@ bool Application::exportPreventsQuit() {
|
|||
}
|
||||
|
||||
int Application::unreadBadge() const {
|
||||
if (const auto session = maybeActiveSession()) {
|
||||
return session->data().unreadBadge();
|
||||
}
|
||||
return 0;
|
||||
return accounts().unreadBadge();
|
||||
}
|
||||
|
||||
bool Application::unreadBadgeMuted() const {
|
||||
if (const auto session = maybeActiveSession()) {
|
||||
return session->data().unreadBadgeMuted();
|
||||
}
|
||||
return false;
|
||||
return accounts().unreadBadgeMuted();
|
||||
}
|
||||
|
||||
rpl::producer<> Application::unreadBadgeChanges() const {
|
||||
return accounts().unreadBadgeChanges();
|
||||
}
|
||||
|
||||
bool Application::offerLegacyLangPackSwitch() const {
|
||||
|
|
|
@ -164,6 +164,7 @@ public:
|
|||
Main::Session *maybeActiveSession() const;
|
||||
[[nodiscard]] int unreadBadge() const;
|
||||
[[nodiscard]] bool unreadBadgeMuted() const;
|
||||
[[nodiscard]] rpl::producer<> unreadBadgeChanges() const;
|
||||
|
||||
// Media component.
|
||||
[[nodiscard]] Media::Audio::Instance &audio() {
|
||||
|
@ -232,7 +233,6 @@ public:
|
|||
void switchFreeType();
|
||||
void writeInstallBetaVersionsSetting();
|
||||
|
||||
void call_handleUnreadCounterUpdate();
|
||||
void call_handleObservables();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -236,8 +236,8 @@ Session::Session(not_null<Main::Session*> session)
|
|||
setupUserIsContactViewer();
|
||||
|
||||
_chatsList.unreadStateChanges(
|
||||
) | rpl::start_with_next([] {
|
||||
Notify::unreadCounterUpdated();
|
||||
) | rpl::start_with_next([=] {
|
||||
notifyUnreadBadgeChanged();
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
|
@ -2082,6 +2082,14 @@ int Session::unreadOnlyMutedBadge() const {
|
|||
: state.chatsMuted;
|
||||
}
|
||||
|
||||
rpl::producer<> Session::unreadBadgeChanges() const {
|
||||
return _unreadBadgeChanges.events();
|
||||
}
|
||||
|
||||
void Session::notifyUnreadBadgeChanged() {
|
||||
_unreadBadgeChanges.fire({});
|
||||
}
|
||||
|
||||
int Session::computeUnreadBadge(const Dialogs::UnreadState &state) const {
|
||||
const auto all = _session->settings().includeMutedCounter();
|
||||
return std::max(state.marks - (all ? 0 : state.marksMuted), 0)
|
||||
|
|
|
@ -391,11 +391,13 @@ public:
|
|||
-> rpl::producer<SendActionAnimationUpdate>;
|
||||
void updateSendActionAnimation(SendActionAnimationUpdate &&update);
|
||||
|
||||
int unreadBadge() const;
|
||||
bool unreadBadgeMuted() const;
|
||||
int unreadBadgeIgnoreOne(const Dialogs::Key &key) const;
|
||||
bool unreadBadgeMutedIgnoreOne(const Dialogs::Key &key) const;
|
||||
int unreadOnlyMutedBadge() const;
|
||||
[[nodiscard]] int unreadBadge() const;
|
||||
[[nodiscard]] bool unreadBadgeMuted() const;
|
||||
[[nodiscard]] int unreadBadgeIgnoreOne(const Dialogs::Key &key) const;
|
||||
[[nodiscard]] bool unreadBadgeMutedIgnoreOne(const Dialogs::Key &key) const;
|
||||
[[nodiscard]] int unreadOnlyMutedBadge() const;
|
||||
[[nodiscard]] rpl::producer<> unreadBadgeChanges() const;
|
||||
void notifyUnreadBadgeChanged();
|
||||
|
||||
void selfDestructIn(not_null<HistoryItem*> item, crl::time delay);
|
||||
|
||||
|
@ -809,6 +811,7 @@ private:
|
|||
rpl::event_stream<MegagroupParticipant> _megagroupParticipantAdded;
|
||||
rpl::event_stream<DialogsRowReplacement> _dialogsRowReplacements;
|
||||
rpl::event_stream<ChatListEntryRefresh> _chatListEntryRefreshes;
|
||||
rpl::event_stream<> _unreadBadgeChanges;
|
||||
|
||||
Dialogs::MainList _chatsList;
|
||||
Dialogs::IndexedList _contactsList;
|
||||
|
|
|
@ -311,10 +311,6 @@ bool switchInlineBotButtonReceived(
|
|||
return false;
|
||||
}
|
||||
|
||||
void unreadCounterUpdated() {
|
||||
Global::RefHandleUnreadCounterUpdate().call();
|
||||
}
|
||||
|
||||
} // namespace Notify
|
||||
|
||||
#define DefineReadOnlyVar(Namespace, Type, Name) const Type &Name() { \
|
||||
|
@ -336,8 +332,6 @@ namespace Global {
|
|||
namespace internal {
|
||||
|
||||
struct Data {
|
||||
SingleQueuedInvokation HandleUnreadCounterUpdate = { [] { Core::App().call_handleUnreadCounterUpdate(); } };
|
||||
|
||||
Adaptive::WindowLayout AdaptiveWindowLayout = Adaptive::WindowLayout::Normal;
|
||||
Adaptive::ChatLayout AdaptiveChatLayout = Adaptive::ChatLayout::Normal;
|
||||
bool AdaptiveForWide = true;
|
||||
|
@ -348,16 +342,12 @@ struct Data {
|
|||
|
||||
bool ScreenIsLocked = false;
|
||||
|
||||
int32 DebugLoggingFlags = 0;
|
||||
|
||||
float64 RememberedSongVolume = kDefaultVolume;
|
||||
float64 SongVolume = kDefaultVolume;
|
||||
base::Observable<void> SongVolumeChanged;
|
||||
float64 VideoVolume = kDefaultVolume;
|
||||
base::Observable<void> VideoVolumeChanged;
|
||||
|
||||
HiddenPinnedMessagesMap HiddenPinnedMessages;
|
||||
|
||||
bool AskDownloadPath = false;
|
||||
QString DownloadPath;
|
||||
QByteArray DownloadPathBookmark;
|
||||
|
@ -388,7 +378,6 @@ struct Data {
|
|||
|
||||
base::Variable<DBIWorkMode> WorkMode = { dbiwmWindowAndTray };
|
||||
|
||||
base::Observable<void> UnreadCounterUpdate;
|
||||
base::Observable<void> PeerChooseCancel;
|
||||
|
||||
QString CallOutputDeviceID = qsl("default");
|
||||
|
@ -418,8 +407,6 @@ void finish() {
|
|||
GlobalData = nullptr;
|
||||
}
|
||||
|
||||
DefineRefVar(Global, SingleQueuedInvokation, HandleUnreadCounterUpdate);
|
||||
|
||||
DefineVar(Global, Adaptive::WindowLayout, AdaptiveWindowLayout);
|
||||
DefineVar(Global, Adaptive::ChatLayout, AdaptiveChatLayout);
|
||||
DefineVar(Global, bool, AdaptiveForWide);
|
||||
|
@ -430,16 +417,12 @@ DefineVar(Global, bool, ModerateModeEnabled);
|
|||
|
||||
DefineVar(Global, bool, ScreenIsLocked);
|
||||
|
||||
DefineVar(Global, int32, DebugLoggingFlags);
|
||||
|
||||
DefineVar(Global, float64, RememberedSongVolume);
|
||||
DefineVar(Global, float64, SongVolume);
|
||||
DefineRefVar(Global, base::Observable<void>, SongVolumeChanged);
|
||||
DefineVar(Global, float64, VideoVolume);
|
||||
DefineRefVar(Global, base::Observable<void>, VideoVolumeChanged);
|
||||
|
||||
DefineVar(Global, HiddenPinnedMessagesMap, HiddenPinnedMessages);
|
||||
|
||||
DefineVar(Global, bool, AskDownloadPath);
|
||||
DefineVar(Global, QString, DownloadPath);
|
||||
DefineVar(Global, QByteArray, DownloadPathBookmark);
|
||||
|
@ -470,7 +453,6 @@ DefineRefVar(Global, base::Observable<void>, LocalPasscodeChanged);
|
|||
|
||||
DefineRefVar(Global, base::Variable<DBIWorkMode>, WorkMode);
|
||||
|
||||
DefineRefVar(Global, base::Observable<void>, UnreadCounterUpdate);
|
||||
DefineRefVar(Global, base::Observable<void>, PeerChooseCancel);
|
||||
|
||||
DefineVar(Global, QString, CallOutputDeviceID);
|
||||
|
|
|
@ -132,19 +132,13 @@ enum class ChatLayout {
|
|||
|
||||
} // namespace Adaptive
|
||||
|
||||
namespace DebugLogging {
|
||||
enum Flags {
|
||||
FileLoaderFlag = 0x00000001,
|
||||
};
|
||||
} // namespace DebugLogging
|
||||
|
||||
namespace Global {
|
||||
|
||||
bool started();
|
||||
void start();
|
||||
void finish();
|
||||
|
||||
DeclareRefVar(SingleQueuedInvokation, HandleUnreadCounterUpdate);
|
||||
DeclareVar(bool, ScreenIsLocked);
|
||||
|
||||
DeclareVar(Adaptive::WindowLayout, AdaptiveWindowLayout);
|
||||
DeclareVar(Adaptive::ChatLayout, AdaptiveChatLayout);
|
||||
|
@ -154,26 +148,17 @@ DeclareRefVar(base::Observable<void>, AdaptiveChanged);
|
|||
DeclareVar(bool, DialogsFiltersEnabled);
|
||||
DeclareVar(bool, ModerateModeEnabled);
|
||||
|
||||
DeclareVar(bool, ScreenIsLocked);
|
||||
|
||||
DeclareVar(int32, DebugLoggingFlags);
|
||||
|
||||
constexpr float64 kDefaultVolume = 0.9;
|
||||
constexpr auto kDefaultVolume = 0.9;
|
||||
|
||||
DeclareVar(float64, RememberedSongVolume);
|
||||
DeclareVar(float64, SongVolume);
|
||||
DeclareRefVar(base::Observable<void>, SongVolumeChanged);
|
||||
DeclareVar(float64, VideoVolume);
|
||||
DeclareRefVar(base::Observable<void>, VideoVolumeChanged);
|
||||
|
||||
typedef QMap<PeerId, MsgId> HiddenPinnedMessagesMap;
|
||||
DeclareVar(HiddenPinnedMessagesMap, HiddenPinnedMessages);
|
||||
|
||||
DeclareVar(bool, AskDownloadPath);
|
||||
DeclareVar(QString, DownloadPath);
|
||||
DeclareVar(QByteArray, DownloadPathBookmark);
|
||||
DeclareRefVar(base::Observable<void>, DownloadPathChanged);
|
||||
|
||||
DeclareVar(bool, VoiceMsgPlaybackDoubled);
|
||||
DeclareVar(bool, SoundNotify);
|
||||
DeclareVar(bool, DesktopNotify);
|
||||
|
@ -181,9 +166,16 @@ DeclareVar(bool, FlashBounceNotify);
|
|||
DeclareVar(bool, RestoreSoundNotifyFromTray);
|
||||
DeclareVar(bool, RestoreFlashBounceNotifyFromTray);
|
||||
DeclareVar(DBINotifyView, NotifyView);
|
||||
DeclareVar(bool, NativeNotifications);
|
||||
DeclareVar(int, NotificationsCount);
|
||||
DeclareVar(Notify::ScreenCorner, NotificationsCorner);
|
||||
|
||||
DeclareVar(QString, CallOutputDeviceID);
|
||||
DeclareVar(QString, CallInputDeviceID);
|
||||
DeclareVar(int, CallOutputVolume);
|
||||
DeclareVar(int, CallInputVolume);
|
||||
DeclareVar(bool, CallAudioDuckingEnabled);
|
||||
|
||||
DeclareVar(bool, NativeNotifications);
|
||||
DeclareVar(bool, NotificationsDemoIsShown);
|
||||
|
||||
DeclareVar(bool, TryIPv6);
|
||||
|
@ -199,15 +191,8 @@ DeclareRefVar(base::Observable<void>, LocalPasscodeChanged);
|
|||
|
||||
DeclareRefVar(base::Variable<DBIWorkMode>, WorkMode);
|
||||
|
||||
DeclareRefVar(base::Observable<void>, UnreadCounterUpdate);
|
||||
DeclareRefVar(base::Observable<void>, PeerChooseCancel);
|
||||
|
||||
DeclareVar(QString, CallOutputDeviceID);
|
||||
DeclareVar(QString, CallInputDeviceID);
|
||||
DeclareVar(int, CallOutputVolume);
|
||||
DeclareVar(int, CallInputVolume);
|
||||
DeclareVar(bool, CallAudioDuckingEnabled);
|
||||
|
||||
} // namespace Global
|
||||
|
||||
namespace Adaptive {
|
||||
|
@ -238,11 +223,3 @@ inline bool ChatWide() {
|
|||
}
|
||||
|
||||
} // namespace Adaptive
|
||||
|
||||
namespace DebugLogging {
|
||||
|
||||
inline bool FileLoader() {
|
||||
return (Global::DebugLoggingFlags() & FileLoaderFlag) != 0;
|
||||
}
|
||||
|
||||
} // namespace DebugLogging
|
||||
|
|
|
@ -107,7 +107,10 @@ FixedBar::FixedBar(
|
|||
, _controller(controller)
|
||||
, _channel(channel)
|
||||
, _field(this, st::historyAdminLogSearchField, tr::lng_dlg_filter())
|
||||
, _backButton(this, tr::lng_admin_log_title_all(tr::now))
|
||||
, _backButton(
|
||||
this,
|
||||
&controller->session(),
|
||||
tr::lng_admin_log_title_all(tr::now))
|
||||
, _search(this, st::topBarSearch)
|
||||
, _cancel(this, st::historyAdminLogCancelSearch)
|
||||
, _filter(this, tr::lng_admin_log_filter(), st::topBarButton) {
|
||||
|
|
|
@ -5683,14 +5683,13 @@ bool HistoryWidget::pinnedMsgVisibilityUpdated() {
|
|||
auto result = false;
|
||||
auto pinnedId = _peer->pinnedMessageId();
|
||||
if (pinnedId && !_peer->canPinMessages()) {
|
||||
auto it = Global::HiddenPinnedMessages().constFind(_peer->id);
|
||||
if (it != Global::HiddenPinnedMessages().cend()) {
|
||||
if (it.value() == pinnedId) {
|
||||
pinnedId = 0;
|
||||
} else {
|
||||
Global::RefHiddenPinnedMessages().remove(_peer->id);
|
||||
session().local().writeSettings();
|
||||
}
|
||||
const auto hiddenId = session().settings().hiddenPinnedMessageId(
|
||||
_peer->id);
|
||||
if (hiddenId == pinnedId) {
|
||||
pinnedId = 0;
|
||||
} else if (hiddenId) {
|
||||
session().settings().setHiddenPinnedMessageId(_peer->id, 0);
|
||||
session().local().writeSettings();
|
||||
}
|
||||
}
|
||||
if (pinnedId) {
|
||||
|
@ -6020,7 +6019,7 @@ void HistoryWidget::hidePinnedMessage() {
|
|||
_peer->isChannel() ? peerToChannel(_peer->id) : NoChannel,
|
||||
pinnedId));
|
||||
} else {
|
||||
Global::RefHiddenPinnedMessages().insert(_peer->id, pinnedId);
|
||||
session().settings().setHiddenPinnedMessageId(_peer->id, pinnedId);
|
||||
session().local().writeSettings();
|
||||
if (pinnedMsgVisibilityUpdated()) {
|
||||
updateControlsGeometry();
|
||||
|
|
|
@ -747,10 +747,7 @@ void TopBarWidget::updateAdaptiveLayout() {
|
|||
|
||||
void TopBarWidget::refreshUnreadBadge() {
|
||||
if (!Adaptive::OneColumn() && !_activeChat.folder()) {
|
||||
if (_unreadBadge) {
|
||||
unsubscribe(base::take(_unreadCounterSubscription));
|
||||
_unreadBadge.destroy();
|
||||
}
|
||||
_unreadBadge.destroy();
|
||||
return;
|
||||
} else if (_unreadBadge) {
|
||||
return;
|
||||
|
@ -768,9 +765,10 @@ void TopBarWidget::refreshUnreadBadge() {
|
|||
|
||||
_unreadBadge->show();
|
||||
_unreadBadge->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
_unreadCounterSubscription = subscribe(
|
||||
Global::RefUnreadCounterUpdate(),
|
||||
[=] { updateUnreadBadge(); });
|
||||
_controller->session().data().unreadBadgeChanges(
|
||||
) | rpl::start_with_next([=] {
|
||||
updateUnreadBadge();
|
||||
}, _unreadBadge->lifetime());
|
||||
updateUnreadBadge();
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,6 @@ Account::~Account() {
|
|||
session().saveSettingsNowIfNeeded();
|
||||
}
|
||||
destroySession();
|
||||
_mtpValue.reset(nullptr);
|
||||
base::take(_mtp);
|
||||
}
|
||||
|
||||
[[nodiscard]] Storage::StartResult Account::legacyStart(
|
||||
|
@ -65,23 +63,17 @@ Account::~Account() {
|
|||
|
||||
const auto result = _local->legacyStart(passcode);
|
||||
if (result == Storage::StartResult::Success) {
|
||||
finishStarting(nullptr);
|
||||
start(nullptr);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void Account::start(std::shared_ptr<MTP::AuthKey> localKey) {
|
||||
finishStarting(_local->start(std::move(localKey)));
|
||||
std::unique_ptr<MTP::Config> Account::prepareToStart(
|
||||
std::shared_ptr<MTP::AuthKey> localKey) {
|
||||
return _local->start(std::move(localKey));
|
||||
}
|
||||
|
||||
void Account::startAdded(
|
||||
std::shared_ptr<MTP::AuthKey> localKey,
|
||||
std::unique_ptr<MTP::Config> config) {
|
||||
_local->startAdded(std::move(localKey));
|
||||
finishStarting(std::move(config));
|
||||
}
|
||||
|
||||
void Account::finishStarting(std::unique_ptr<MTP::Config> config) {
|
||||
void Account::start(std::unique_ptr<MTP::Config> config) {
|
||||
startMtp(config
|
||||
? std::move(config)
|
||||
: std::make_unique<MTP::Config>(
|
||||
|
@ -91,6 +83,11 @@ void Account::finishStarting(std::unique_ptr<MTP::Config> config) {
|
|||
watchSessionChanges();
|
||||
}
|
||||
|
||||
void Account::prepareToStartAdded(
|
||||
std::shared_ptr<MTP::AuthKey> localKey) {
|
||||
_local->startAdded(std::move(localKey));
|
||||
}
|
||||
|
||||
void Account::watchProxyChanges() {
|
||||
using ProxyChange = Core::Application::ProxyChange;
|
||||
|
||||
|
@ -189,8 +186,6 @@ void Account::destroySession() {
|
|||
|
||||
_sessionValue = nullptr;
|
||||
_session = nullptr;
|
||||
|
||||
Notify::unreadCounterUpdated();
|
||||
}
|
||||
|
||||
bool Account::sessionExists() const {
|
||||
|
|
|
@ -37,10 +37,11 @@ public:
|
|||
|
||||
[[nodiscard]] Storage::StartResult legacyStart(
|
||||
const QByteArray &passcode);
|
||||
void start(std::shared_ptr<MTP::AuthKey> localKey);
|
||||
void startAdded(
|
||||
std::shared_ptr<MTP::AuthKey> localKey,
|
||||
std::unique_ptr<MTP::Config> config);
|
||||
[[nodiscard]] std::unique_ptr<MTP::Config> prepareToStart(
|
||||
std::shared_ptr<MTP::AuthKey> localKey);
|
||||
void prepareToStartAdded(
|
||||
std::shared_ptr<MTP::AuthKey> localKey);
|
||||
void start(std::unique_ptr<MTP::Config> config);
|
||||
|
||||
[[nodiscard]] UserId willHaveUserId() const;
|
||||
void createSession(const MTPUser &user);
|
||||
|
@ -105,7 +106,6 @@ private:
|
|||
QByteArray serialized,
|
||||
int streamVersion,
|
||||
Settings &&settings);
|
||||
void finishStarting(std::unique_ptr<MTP::Config> config);
|
||||
void watchProxyChanges();
|
||||
void watchSessionChanges();
|
||||
bool checkForUpdates(const mtpPrime *from, const mtpPrime *end);
|
||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/shortcuts.h"
|
||||
#include "main/main_account.h"
|
||||
#include "main/main_session.h"
|
||||
#include "data/data_session.h"
|
||||
#include "mtproto/mtproto_config.h"
|
||||
#include "mtproto/mtproto_dc_options.h"
|
||||
#include "storage/storage_accounts.h"
|
||||
|
@ -35,10 +36,10 @@ Storage::StartResult Accounts::start(const QByteArray &passcode) {
|
|||
|
||||
const auto result = _local->start(passcode);
|
||||
if (result == Storage::StartResult::Success) {
|
||||
activateAfterStarting();
|
||||
if (Local::oldSettingsVersion() < AppVersion) {
|
||||
Local::writeSettings();
|
||||
}
|
||||
activateAfterStarting();
|
||||
} else {
|
||||
Assert(!started());
|
||||
}
|
||||
|
@ -123,6 +124,52 @@ rpl::producer<Session*> Accounts::activeSessionValue() const {
|
|||
return rpl::single(current) | rpl::then(_activeSessions.events());
|
||||
}
|
||||
|
||||
int Accounts::unreadBadge() const {
|
||||
return _unreadBadge;
|
||||
}
|
||||
|
||||
bool Accounts::unreadBadgeMuted() const {
|
||||
return _unreadBadgeMuted;
|
||||
}
|
||||
|
||||
rpl::producer<> Accounts::unreadBadgeChanges() const {
|
||||
return _unreadBadgeChanges.events();
|
||||
}
|
||||
|
||||
void Accounts::notifyUnreadBadgeChanged() {
|
||||
for (const auto &[index, account] : _accounts) {
|
||||
if (account->sessionExists()) {
|
||||
account->session().data().notifyUnreadBadgeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Accounts::updateUnreadBadge() {
|
||||
_unreadBadge = 0;
|
||||
_unreadBadgeMuted = true;
|
||||
for (const auto &[index, account] : _accounts) {
|
||||
if (account->sessionExists()) {
|
||||
const auto data = &account->session().data();
|
||||
_unreadBadge += data->unreadBadge();
|
||||
if (!data->unreadBadgeMuted()) {
|
||||
_unreadBadgeMuted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
_unreadBadgeChanges.fire({});
|
||||
}
|
||||
|
||||
void Accounts::scheduleUpdateUnreadBadge() {
|
||||
if (_unreadBadgeUpdateScheduled) {
|
||||
return;
|
||||
}
|
||||
_unreadBadgeUpdateScheduled = true;
|
||||
Core::App().postponeCall(crl::guard(&Core::App(), [=] {
|
||||
_unreadBadgeUpdateScheduled = false;
|
||||
updateUnreadBadge();
|
||||
}));
|
||||
}
|
||||
|
||||
int Accounts::add(MTP::Environment environment) {
|
||||
Expects(_active.current() != nullptr);
|
||||
|
||||
|
@ -159,10 +206,21 @@ int Accounts::add(MTP::Environment environment) {
|
|||
}
|
||||
|
||||
void Accounts::watchSession(not_null<Account*> account) {
|
||||
account->sessionValue(
|
||||
) | rpl::filter([=](Session *session) {
|
||||
return session != nullptr;
|
||||
}) | rpl::start_with_next([=](Session *session) {
|
||||
session->data().unreadBadgeChanges(
|
||||
) | rpl::start_with_next([=] {
|
||||
scheduleUpdateUnreadBadge();
|
||||
}, session->lifetime());
|
||||
}, account->lifetime());
|
||||
|
||||
account->sessionChanges(
|
||||
) | rpl::filter([=](Session *session) {
|
||||
return !session; // removeRedundantAccounts may remove passcode lock.
|
||||
return !session;
|
||||
}) | rpl::start_with_next([=] {
|
||||
scheduleUpdateUnreadBadge();
|
||||
if (account == _active.current()) {
|
||||
activateAuthedAccount();
|
||||
}
|
||||
|
@ -238,13 +296,16 @@ void Accounts::checkForLastProductionConfig(
|
|||
void Accounts::activate(int index) {
|
||||
Expects(_accounts.contains(index));
|
||||
|
||||
const auto changed = (_activeIndex != index);
|
||||
_activeLifetime.destroy();
|
||||
_activeIndex = index;
|
||||
_active = _accounts.find(index)->second.get();
|
||||
_active.current()->sessionValue(
|
||||
) | rpl::start_to_stream(_activeSessions, _activeLifetime);
|
||||
|
||||
scheduleWriteAccounts();
|
||||
if (changed) {
|
||||
scheduleWriteAccounts();
|
||||
}
|
||||
}
|
||||
|
||||
void Accounts::scheduleWriteAccounts() {
|
||||
|
|
|
@ -47,6 +47,11 @@ public:
|
|||
[[nodiscard]] rpl::producer<Session*> activeSessionValue() const;
|
||||
[[nodiscard]] rpl::producer<Session*> activeSessionChanges() const;
|
||||
|
||||
[[nodiscard]] int unreadBadge() const;
|
||||
[[nodiscard]] bool unreadBadgeMuted() const;
|
||||
[[nodiscard]] rpl::producer<> unreadBadgeChanges() const;
|
||||
void notifyUnreadBadgeChanged();
|
||||
|
||||
[[nodiscard]] int add(MTP::Environment environment);
|
||||
void activate(int index);
|
||||
|
||||
|
@ -61,6 +66,8 @@ private:
|
|||
void watchSession(not_null<Account*> account);
|
||||
void scheduleWriteAccounts();
|
||||
void checkForLastProductionConfig(not_null<Main::Account*> account);
|
||||
void updateUnreadBadge();
|
||||
void scheduleUpdateUnreadBadge();
|
||||
|
||||
const QString _dataName;
|
||||
const std::unique_ptr<Storage::Accounts> _local;
|
||||
|
@ -72,6 +79,11 @@ private:
|
|||
|
||||
rpl::event_stream<Session*> _activeSessions;
|
||||
|
||||
rpl::event_stream<> _unreadBadgeChanges;
|
||||
int _unreadBadge = 0;
|
||||
bool _unreadBadgeMuted = true;
|
||||
bool _unreadBadgeUpdateScheduled = false;
|
||||
|
||||
rpl::lifetime _activeLifetime;
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "apiwrap.h"
|
||||
#include "api/api_updates.h"
|
||||
#include "core/application.h"
|
||||
#include "core/changelogs.h"
|
||||
#include "main/main_account.h"
|
||||
#include "mtproto/mtproto_config.h"
|
||||
#include "chat_helpers/stickers_emoji_pack.h"
|
||||
|
@ -81,7 +80,6 @@ Session::Session(
|
|||
, _user(_data->processUser(user))
|
||||
, _emojiStickersPack(std::make_unique<Stickers::EmojiPack>(this))
|
||||
, _diceStickersPacks(std::make_unique<Stickers::DicePacks>(this))
|
||||
, _changelogs(Core::Changelogs::Create(this))
|
||||
, _supportHelper(Support::Helper::Create(this)) {
|
||||
Core::App().lockChanges(
|
||||
) | rpl::start_with_next([=] {
|
||||
|
|
|
@ -57,10 +57,6 @@ class EmojiPack;
|
|||
class DicePacks;
|
||||
} // namespace Stickers;
|
||||
|
||||
namespace Core {
|
||||
class Changelogs;
|
||||
} // namespace Core
|
||||
|
||||
namespace Main {
|
||||
|
||||
class Account;
|
||||
|
@ -180,9 +176,6 @@ private:
|
|||
const std::unique_ptr<Stickers::EmojiPack> _emojiStickersPack;
|
||||
const std::unique_ptr<Stickers::DicePacks> _diceStickersPacks;
|
||||
|
||||
// _changelogs depends on _data, subscribes on chats loading event.
|
||||
const std::unique_ptr<Core::Changelogs> _changelogs;
|
||||
|
||||
const std::unique_ptr<Support::Helper> _supportHelper;
|
||||
|
||||
base::flat_set<not_null<Window::SessionController*>> _windows;
|
||||
|
|
|
@ -52,13 +52,14 @@ bool Settings::ThirdColumnByDefault() {
|
|||
QByteArray Settings::serialize() const {
|
||||
const auto autoDownload = _variables.autoDownload.serialize();
|
||||
auto size = sizeof(qint32) * 38;
|
||||
for (auto i = _variables.soundOverrides.cbegin(), e = _variables.soundOverrides.cend(); i != e; ++i) {
|
||||
size += Serialize::stringSize(i.key()) + Serialize::stringSize(i.value());
|
||||
for (const auto &[key, value] : _variables.soundOverrides) {
|
||||
size += Serialize::stringSize(key) + Serialize::stringSize(value);
|
||||
}
|
||||
size += _variables.groupStickersSectionHidden.size() * sizeof(quint64);
|
||||
size += _variables.mediaLastPlaybackPosition.size() * 2 * sizeof(quint64);
|
||||
size += Serialize::bytearraySize(autoDownload);
|
||||
size += Serialize::bytearraySize(_variables.videoPipGeometry);
|
||||
size += sizeof(qint32) + _variables.hiddenPinnedMessages.size() * (sizeof(quint64) + sizeof(qint32));
|
||||
|
||||
auto result = QByteArray();
|
||||
result.reserve(size);
|
||||
|
@ -70,8 +71,8 @@ QByteArray Settings::serialize() const {
|
|||
stream << qint32(_variables.lastSeenWarningSeen ? 1 : 0);
|
||||
stream << qint32(_variables.tabbedSelectorSectionEnabled ? 1 : 0);
|
||||
stream << qint32(_variables.soundOverrides.size());
|
||||
for (auto i = _variables.soundOverrides.cbegin(), e = _variables.soundOverrides.cend(); i != e; ++i) {
|
||||
stream << i.key() << i.value();
|
||||
for (const auto &[key, value] : _variables.soundOverrides) {
|
||||
stream << key << value;
|
||||
}
|
||||
stream << qint32(_variables.tabbedSelectorSectionTooltipShown);
|
||||
stream << qint32(_variables.floatPlayerColumn);
|
||||
|
@ -122,6 +123,10 @@ QByteArray Settings::serialize() const {
|
|||
stream << quint64(i);
|
||||
}
|
||||
stream << qint32(_variables.autoDownloadDictionaries.current() ? 1 : 0);
|
||||
stream << qint32(_variables.hiddenPinnedMessages.size());
|
||||
for (const auto &[key, value] : _variables.hiddenPinnedMessages) {
|
||||
stream << quint64(key) << qint32(value);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -141,7 +146,7 @@ void Settings::constructFromSerialized(const QByteArray &serialized) {
|
|||
qint32 tabbedSelectorSectionTooltipShown = 0;
|
||||
qint32 floatPlayerColumn = static_cast<qint32>(Window::Column::Second);
|
||||
qint32 floatPlayerCorner = static_cast<qint32>(RectPart::TopRight);
|
||||
QMap<QString, QString> soundOverrides;
|
||||
base::flat_map<QString, QString> soundOverrides;
|
||||
base::flat_set<PeerId> groupStickersSectionHidden;
|
||||
qint32 thirdSectionInfoEnabled = 0;
|
||||
qint32 smallDialogsList = 0;
|
||||
|
@ -176,6 +181,7 @@ void Settings::constructFromSerialized(const QByteArray &serialized) {
|
|||
QByteArray videoPipGeometry = _variables.videoPipGeometry;
|
||||
std::vector<int> dictionariesEnabled;
|
||||
qint32 autoDownloadDictionaries = _variables.autoDownloadDictionaries.current() ? 1 : 0;
|
||||
base::flat_map<PeerId, MsgId> hiddenPinnedMessages;
|
||||
|
||||
stream >> versionTag;
|
||||
if (versionTag == kVersionTag) {
|
||||
|
@ -195,7 +201,7 @@ void Settings::constructFromSerialized(const QByteArray &serialized) {
|
|||
for (auto i = 0; i != count; ++i) {
|
||||
QString key, value;
|
||||
stream >> key >> value;
|
||||
soundOverrides[key] = value;
|
||||
soundOverrides.emplace(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -316,6 +322,18 @@ void Settings::constructFromSerialized(const QByteArray &serialized) {
|
|||
if (!stream.atEnd()) {
|
||||
stream >> autoDownloadDictionaries;
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
auto count = qint32(0);
|
||||
stream >> count;
|
||||
if (stream.status() == QDataStream::Ok) {
|
||||
for (auto i = 0; i != count; ++i) {
|
||||
auto key = quint64();
|
||||
auto value = qint32();
|
||||
stream >> key >> value;
|
||||
hiddenPinnedMessages.emplace(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for Main::Settings::constructFromSerialized()"));
|
||||
|
@ -407,6 +425,7 @@ void Settings::constructFromSerialized(const QByteArray &serialized) {
|
|||
_variables.videoPipGeometry = videoPipGeometry;
|
||||
_variables.dictionariesEnabled = std::move(dictionariesEnabled);
|
||||
_variables.autoDownloadDictionaries = (autoDownloadDictionaries == 1);
|
||||
_variables.hiddenPinnedMessages = std::move(hiddenPinnedMessages);
|
||||
}
|
||||
|
||||
void Settings::setSupportChatsTimeSlice(int slice) {
|
||||
|
@ -470,9 +489,9 @@ void Settings::setTabbedReplacedWithInfo(bool enabled) {
|
|||
}
|
||||
|
||||
QString Settings::getSoundPath(const QString &key) const {
|
||||
auto it = _variables.soundOverrides.constFind(key);
|
||||
auto it = _variables.soundOverrides.find(key);
|
||||
if (it != _variables.soundOverrides.end()) {
|
||||
return it.value();
|
||||
return it->second;
|
||||
}
|
||||
return qsl(":/sounds/") + key + qsl(".mp3");
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ public:
|
|||
return _variables.smallDialogsList;
|
||||
}
|
||||
void setSoundOverride(const QString &key, const QString &path) {
|
||||
_variables.soundOverrides.insert(key, path);
|
||||
_variables.soundOverrides.emplace(key, path);
|
||||
}
|
||||
void clearSoundOverrides() {
|
||||
_variables.soundOverrides.clear();
|
||||
|
@ -279,6 +279,18 @@ public:
|
|||
_variables.videoPipGeometry = geometry;
|
||||
}
|
||||
|
||||
[[nodiscard]] MsgId hiddenPinnedMessageId(PeerId peerId) const {
|
||||
const auto i = _variables.hiddenPinnedMessages.find(peerId);
|
||||
return (i != end(_variables.hiddenPinnedMessages)) ? i->second : 0;
|
||||
}
|
||||
void setHiddenPinnedMessageId(PeerId peerId, MsgId msgId) {
|
||||
if (msgId) {
|
||||
_variables.hiddenPinnedMessages[peerId] = msgId;
|
||||
} else {
|
||||
_variables.hiddenPinnedMessages.remove(peerId);
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] static bool ThirdColumnByDefault();
|
||||
|
||||
private:
|
||||
|
@ -294,7 +306,7 @@ private:
|
|||
ChatHelpers::SelectorTab selectorTab; // per-window
|
||||
bool tabbedSelectorSectionEnabled = false; // per-window
|
||||
int tabbedSelectorSectionTooltipShown = 0;
|
||||
QMap<QString, QString> soundOverrides;
|
||||
base::flat_map<QString, QString> soundOverrides;
|
||||
Window::Column floatPlayerColumn; // per-window
|
||||
RectPart floatPlayerCorner; // per-window
|
||||
base::flat_set<PeerId> groupStickersSectionHidden;
|
||||
|
@ -325,6 +337,7 @@ private:
|
|||
QByteArray videoPipGeometry;
|
||||
rpl::variable<std::vector<int>> dictionariesEnabled;
|
||||
rpl::variable<bool> autoDownloadDictionaries = true;
|
||||
base::flat_map<PeerId, MsgId> hiddenPinnedMessages;
|
||||
|
||||
static constexpr auto kDefaultSupportChatsLimitSlice
|
||||
= 7 * 24 * 60 * 60;
|
||||
|
|
|
@ -90,6 +90,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/update_checker.h"
|
||||
#include "core/shortcuts.h"
|
||||
#include "core/application.h"
|
||||
#include "core/changelogs.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "calls/calls_instance.h"
|
||||
#include "calls/calls_top_bar.h"
|
||||
|
@ -233,7 +234,8 @@ MainWidget::MainWidget(
|
|||
, _history(this, _controller)
|
||||
, _playerPlaylist(this, _controller)
|
||||
, _cacheBackgroundTimer([=] { cacheBackground(); })
|
||||
, _viewsIncrementTimer([=] { viewsIncrement(); }) {
|
||||
, _viewsIncrementTimer([=] { viewsIncrement(); })
|
||||
, _changelogs(Core::Changelogs::Create(&controller->session())) {
|
||||
_controller->setDefaultFloatPlayerDelegate(floatPlayerDelegate());
|
||||
_controller->floatPlayerClosed(
|
||||
) | rpl::start_with_next([=](FullMsgId itemId) {
|
||||
|
|
|
@ -88,6 +88,10 @@ class Call;
|
|||
class TopBar;
|
||||
} // namespace Calls
|
||||
|
||||
namespace Core {
|
||||
class Changelogs;
|
||||
} // namespace Core
|
||||
|
||||
namespace InlineBots {
|
||||
namespace Layout {
|
||||
class ItemBase;
|
||||
|
@ -410,6 +414,9 @@ private:
|
|||
bool _firstColumnResizing = false;
|
||||
int _firstColumnResizingShift = 0;
|
||||
|
||||
// _changelogs depends on _data, subscribes on chats loading event.
|
||||
const std::unique_ptr<Core::Changelogs> _changelogs;
|
||||
|
||||
};
|
||||
|
||||
namespace App {
|
||||
|
|
|
@ -737,7 +737,7 @@ void MainWindow::showFromTray(QSystemTrayIcon::ActivationReason reason) {
|
|||
updateGlobalMenu();
|
||||
});
|
||||
activate();
|
||||
Notify::unreadCounterUpdated();
|
||||
updateUnreadCounter();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ std::unique_ptr<Config> Config::FromSerialized(const QByteArray &serialized) {
|
|||
|
||||
auto dcOptionsSerialized = QByteArray();
|
||||
const auto read = [&](auto &field) {
|
||||
using Type = std::decay_t<decltype(field)>();
|
||||
using Type = std::remove_reference_t<decltype(field)>;
|
||||
if constexpr (std::is_same_v<Type, int>
|
||||
|| std::is_same_v<Type, rpl::variable<int>>) {
|
||||
auto value = qint32();
|
||||
|
@ -123,6 +123,8 @@ std::unique_ptr<Config> Config::FromSerialized(const QByteArray &serialized) {
|
|||
field = (value == 1);
|
||||
} else if constexpr (std::is_same_v<Type, QByteArray>
|
||||
|| std::is_same_v<Type, QString>) {
|
||||
stream >> field;
|
||||
} else {
|
||||
static_assert(false_(field), "Bad read() call.");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -196,7 +196,7 @@ private:
|
|||
}
|
||||
|
||||
- (void) darkModeChanged:(NSNotification *)aNotification {
|
||||
Notify::unreadCounterUpdated();
|
||||
Core::App().accounts().notifyUnreadBadgeChanged();
|
||||
}
|
||||
|
||||
- (void) screenIsLocked:(NSNotification *)aNotification {
|
||||
|
|
|
@ -10,17 +10,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "mainwindow.h"
|
||||
#include "ui/widgets/shadow.h"
|
||||
#include "ui/image/image_prepare.h"
|
||||
#include "core/application.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "styles/style_media_view.h"
|
||||
#include "platform/platform_main_window.h"
|
||||
#include "facades.h"
|
||||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include <CoreFoundation/CFURL.h>
|
||||
|
||||
namespace Platform {
|
||||
|
||||
TitleWidget::TitleWidget(MainWindow *parent, int height) : Window::TitleWidget(parent)
|
||||
TitleWidget::TitleWidget(MainWindow *parent, int height)
|
||||
: Window::TitleWidget(parent)
|
||||
, _shadow(this, st::titleShadow) {
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
resize(width(), height);
|
||||
|
@ -41,7 +42,10 @@ TitleWidget::TitleWidget(MainWindow *parent, int height) : Window::TitleWidget(p
|
|||
_font = st::normalFont;
|
||||
}
|
||||
|
||||
subscribe(Global::RefUnreadCounterUpdate(), [this] { update(); });
|
||||
Core::App().unreadBadgeValue(
|
||||
) | rpl::start_with_next([=] {
|
||||
update();
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
void TitleWidget::paintEvent(QPaintEvent *e) {
|
||||
|
|
|
@ -8,19 +8,26 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "profile/profile_back_button.h"
|
||||
|
||||
//#include "history/view/history_view_top_bar_widget.h"
|
||||
#include "facades.h"
|
||||
#include "main/main_session.h"
|
||||
#include "data/data_session.h"
|
||||
#include "styles/style_widgets.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "styles/style_profile.h"
|
||||
#include "styles/style_info.h"
|
||||
#include "facades.h"
|
||||
|
||||
namespace Profile {
|
||||
|
||||
BackButton::BackButton(QWidget *parent, const QString &text) : Ui::AbstractButton(parent)
|
||||
BackButton::BackButton(
|
||||
QWidget *parent,
|
||||
not_null<Main::Session*> session,
|
||||
const QString &text)
|
||||
: Ui::AbstractButton(parent)
|
||||
, _session(session)
|
||||
, _text(text.toUpper()) {
|
||||
setCursor(style::cur_pointer);
|
||||
|
||||
subscribe(Adaptive::Changed(), [this] { updateAdaptiveLayout(); });
|
||||
subscribe(Adaptive::Changed(), [=] { updateAdaptiveLayout(); });
|
||||
updateAdaptiveLayout();
|
||||
}
|
||||
|
||||
|
@ -52,11 +59,12 @@ void BackButton::onStateChanged(State was, StateChangeSource source) {
|
|||
|
||||
void BackButton::updateAdaptiveLayout() {
|
||||
if (!Adaptive::OneColumn()) {
|
||||
unsubscribe(base::take(_unreadCounterSubscription));
|
||||
} else if (!_unreadCounterSubscription) {
|
||||
_unreadCounterSubscription = subscribe(Global::RefUnreadCounterUpdate(), [this] {
|
||||
_unreadBadgeLifetime.destroy();
|
||||
} else if (!_unreadBadgeLifetime) {
|
||||
_session->data().unreadBadgeChanges(
|
||||
) | rpl::start_with_next([=] {
|
||||
rtlupdate(0, 0, st::titleUnreadCounterRight, st::titleUnreadCounterTop);
|
||||
});
|
||||
}, _unreadBadgeLifetime);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,11 +9,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "ui/abstract_button.h"
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Profile {
|
||||
|
||||
class BackButton final : public Ui::AbstractButton, private base::Subscriber {
|
||||
public:
|
||||
BackButton(QWidget *parent, const QString &text);
|
||||
BackButton(
|
||||
QWidget *parent,
|
||||
not_null<Main::Session*> session,
|
||||
const QString &text);
|
||||
|
||||
void setText(const QString &text);
|
||||
|
||||
|
@ -26,7 +33,9 @@ protected:
|
|||
private:
|
||||
void updateAdaptiveLayout();
|
||||
|
||||
int _unreadCounterSubscription = 0;
|
||||
const not_null<Main::Session*> _session;
|
||||
|
||||
rpl::lifetime _unreadBadgeLifetime;
|
||||
QString _text;
|
||||
|
||||
};
|
||||
|
|
|
@ -58,17 +58,6 @@ auto GenerateCodes() {
|
|||
codes.emplace(qsl("loadlang"), [](SessionController *window) {
|
||||
Lang::CurrentCloudManager().switchToLanguage({ qsl("#custom") });
|
||||
});
|
||||
codes.emplace(qsl("debugfiles"), [](SessionController *window) {
|
||||
if (!Logs::DebugEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (DebugLogging::FileLoader()) {
|
||||
Global::RefDebugLoggingFlags() &= ~DebugLogging::FileLoaderFlag;
|
||||
} else {
|
||||
Global::RefDebugLoggingFlags() |= DebugLogging::FileLoaderFlag;
|
||||
}
|
||||
Ui::show(Box<InformBox>(DebugLogging::FileLoader() ? qsl("Enabled file download logging") : qsl("Disabled file download logging")));
|
||||
});
|
||||
codes.emplace(qsl("crashplease"), [](SessionController *window) {
|
||||
Unexpected("Crashed in Settings!");
|
||||
});
|
||||
|
|
|
@ -955,12 +955,16 @@ bool ReadSetting(
|
|||
cSetEmojiVariants(v);
|
||||
} break;
|
||||
|
||||
case dbiHiddenPinnedMessages: {
|
||||
Global::HiddenPinnedMessagesMap v;
|
||||
case dbiHiddenPinnedMessagesOld: {
|
||||
auto v = QMap<PeerId, MsgId>();
|
||||
stream >> v;
|
||||
if (!CheckStreamStatus(stream)) return false;
|
||||
|
||||
Global::SetHiddenPinnedMessages(v);
|
||||
for (auto i = v.begin(), e = v.end(); i != e; ++i) {
|
||||
context.sessionSettings().setHiddenPinnedMessageId(
|
||||
i.key(),
|
||||
i.value());
|
||||
}
|
||||
} break;
|
||||
|
||||
case dbiDialogLastPath: {
|
||||
|
|
|
@ -124,7 +124,7 @@ enum {
|
|||
dbiShowingSavedGifsOld = 0x36,
|
||||
dbiAutoPlayOld = 0x37,
|
||||
dbiAdaptiveForWide = 0x38,
|
||||
dbiHiddenPinnedMessages = 0x39,
|
||||
dbiHiddenPinnedMessagesOld = 0x39,
|
||||
dbiRecentEmoji = 0x3a,
|
||||
dbiEmojiVariants = 0x3b,
|
||||
dbiDialogsModeOld = 0x40,
|
||||
|
|
|
@ -798,9 +798,6 @@ void Account::writeSettings(Main::Settings *stored) {
|
|||
size += sizeof(quint32) + 3 * sizeof(qint32);
|
||||
size += sizeof(quint32) + 2 * sizeof(qint32);
|
||||
size += sizeof(quint32) + sizeof(qint64) + sizeof(qint32);
|
||||
if (!Global::HiddenPinnedMessages().isEmpty()) {
|
||||
size += sizeof(quint32) + sizeof(qint32) + Global::HiddenPinnedMessages().size() * (sizeof(PeerId) + sizeof(MsgId));
|
||||
}
|
||||
if (!userData.isEmpty()) {
|
||||
size += sizeof(quint32) + Serialize::bytearraySize(userData);
|
||||
}
|
||||
|
@ -837,9 +834,6 @@ void Account::writeSettings(Main::Settings *stored) {
|
|||
data.stream << quint32(dbiRecentEmoji) << recentEmojiPreloadData;
|
||||
data.stream << quint32(dbiEmojiVariants) << cEmojiVariants();
|
||||
data.stream << quint32(dbiRecentStickers) << recentStickers;
|
||||
if (!Global::HiddenPinnedMessages().isEmpty()) {
|
||||
data.stream << quint32(dbiHiddenPinnedMessages) << Global::HiddenPinnedMessages();
|
||||
}
|
||||
data.stream << qint32(dbiCallSettings) << callSettings;
|
||||
|
||||
FileWriteDescriptor file(_settingsKey, _basePath);
|
||||
|
|
|
@ -73,7 +73,8 @@ void Accounts::startAdded(
|
|||
std::unique_ptr<MTP::Config> config) {
|
||||
Expects(_localKey != nullptr);
|
||||
|
||||
account->startAdded(_localKey, std::move(config));
|
||||
account->prepareToStartAdded(_localKey);
|
||||
account->start(std::move(config));
|
||||
}
|
||||
|
||||
void Accounts::startWithSingleAccount(
|
||||
|
@ -86,7 +87,7 @@ void Accounts::startWithSingleAccount(
|
|||
encryptLocalKey(passcode);
|
||||
} else {
|
||||
generateLocalKey();
|
||||
account->start(_localKey);
|
||||
account->start(account->prepareToStart(_localKey));
|
||||
}
|
||||
_owner->accountAddedInStorage(0, std::move(account));
|
||||
writeAccounts();
|
||||
|
@ -178,10 +179,11 @@ Accounts::StartModernResult Accounts::startModern(
|
|||
&& index < kMaxAccounts
|
||||
&& tried.emplace(index).second) {
|
||||
auto account = std::make_unique<Main::Account>(_dataName, index);
|
||||
account->start(_localKey);
|
||||
auto config = account->prepareToStart(_localKey);
|
||||
const auto userId = account->willHaveUserId();
|
||||
if (!users.contains(userId)
|
||||
&& (userId != 0 || (users.empty() && i + 1 == count))) {
|
||||
account->start(std::move(config));
|
||||
_owner->accountAddedInStorage(index, std::move(account));
|
||||
users.emplace(userId);
|
||||
}
|
||||
|
|
|
@ -133,9 +133,12 @@ MainWindow::MainWindow(not_null<Controller*> controller)
|
|||
updatePalette();
|
||||
}
|
||||
});
|
||||
subscribe(Global::RefUnreadCounterUpdate(), [=] {
|
||||
|
||||
Core::App().unreadBadgeChanges(
|
||||
) | rpl::start_with_next([=] {
|
||||
updateUnreadCounter();
|
||||
});
|
||||
}, lifetime());
|
||||
|
||||
subscribe(Global::RefWorkMode(), [=](DBIWorkMode mode) {
|
||||
workmodeUpdated(mode);
|
||||
});
|
||||
|
|
|
@ -170,10 +170,10 @@ protected:
|
|||
void attachToTrayIcon(not_null<QSystemTrayIcon*> icon);
|
||||
virtual void handleTrayIconActication(
|
||||
QSystemTrayIcon::ActivationReason reason) = 0;
|
||||
void updateUnreadCounter();
|
||||
|
||||
private:
|
||||
void updatePalette();
|
||||
void updateUnreadCounter();
|
||||
void initSize();
|
||||
|
||||
bool computeIsActive() const;
|
||||
|
|
|
@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "api/api_updates.h"
|
||||
#include "apiwrap.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_accounts.h"
|
||||
#include "facades.h"
|
||||
#include "app.h"
|
||||
|
||||
|
@ -60,7 +61,7 @@ System::System(not_null<Main::Session*> session)
|
|||
updateAll();
|
||||
} else if (type == ChangeType::IncludeMuted
|
||||
|| type == ChangeType::CountMessages) {
|
||||
Notify::unreadCounterUpdated();
|
||||
Core::App().accounts().notifyUnreadBadgeChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue