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