mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Replace observer_peer with rpl interface.
This commit is contained in:
parent
b0f9ad71dd
commit
3c4e959468
81 changed files with 1405 additions and 1304 deletions
|
@ -357,6 +357,8 @@ PRIVATE
|
||||||
data/data_chat.h
|
data/data_chat.h
|
||||||
data/data_chat_filters.cpp
|
data/data_chat_filters.cpp
|
||||||
data/data_chat_filters.h
|
data/data_chat_filters.h
|
||||||
|
data/data_changes.cpp
|
||||||
|
data/data_changes.h
|
||||||
data/data_channel.cpp
|
data/data_channel.cpp
|
||||||
data/data_channel.h
|
data/data_channel.h
|
||||||
data/data_channel_admins.cpp
|
data/data_channel_admins.cpp
|
||||||
|
@ -1046,8 +1048,6 @@ PRIVATE
|
||||||
mainwidget.h
|
mainwidget.h
|
||||||
mainwindow.cpp
|
mainwindow.cpp
|
||||||
mainwindow.h
|
mainwindow.h
|
||||||
observer_peer.cpp
|
|
||||||
observer_peer.h
|
|
||||||
qt_static_plugins.cpp
|
qt_static_plugins.cpp
|
||||||
settings.cpp
|
settings.cpp
|
||||||
settings.h
|
settings.h
|
||||||
|
|
|
@ -168,9 +168,7 @@ void SendExistingMedia(
|
||||||
};
|
};
|
||||||
performRequest();
|
performRequest();
|
||||||
|
|
||||||
if (const auto main = App::main()) {
|
api->finishForwarding(message.action);
|
||||||
main->finishForwarding(message.action);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -191,10 +189,7 @@ void SendExistingDocument(
|
||||||
document->stickerOrGifOrigin());
|
document->stickerOrGifOrigin());
|
||||||
|
|
||||||
if (document->sticker()) {
|
if (document->sticker()) {
|
||||||
if (const auto main = App::main()) {
|
document->owner().stickers().incrementSticker(document);
|
||||||
main->incrementSticker(document);
|
|
||||||
}
|
|
||||||
document->owner().stickers().notifyRecentUpdated();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,6 +318,7 @@ bool SendDice(Api::MessageToSend &message) {
|
||||||
).send();
|
).send();
|
||||||
return history->sendRequestId;
|
return history->sendRequestId;
|
||||||
});
|
});
|
||||||
|
api->finishForwarding(message.action);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_chat_filters.h"
|
#include "data/data_chat_filters.h"
|
||||||
#include "data/data_cloud_themes.h"
|
#include "data/data_cloud_themes.h"
|
||||||
|
@ -37,7 +38,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "app.h" // App::formatPhone
|
#include "app.h" // App::formatPhone
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
|
|
||||||
|
@ -828,9 +828,9 @@ void Updates::updateOnline(bool gotOtherOffline) {
|
||||||
|
|
||||||
const auto self = session().user();
|
const auto self = session().user();
|
||||||
self->onlineTill = base::unixtime::now() + (isOnline ? (Global::OnlineUpdatePeriod() / 1000) : -1);
|
self->onlineTill = base::unixtime::now() + (isOnline ? (Global::OnlineUpdatePeriod() / 1000) : -1);
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(
|
||||||
self,
|
self,
|
||||||
Notify::PeerUpdate::Flag::UserOnlineChanged);
|
Data::PeerUpdate::Flag::OnlineStatus);
|
||||||
if (!isOnline) { // Went offline, so we need to save message draft to the cloud.
|
if (!isOnline) { // Went offline, so we need to save message draft to the cloud.
|
||||||
api().saveCurrentDraftToCloud();
|
api().saveCurrentDraftToCloud();
|
||||||
}
|
}
|
||||||
|
@ -1582,9 +1582,9 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||||
case mtpc_userStatusOffline: user->onlineTill = d.vstatus().c_userStatusOffline().vwas_online().v; break;
|
case mtpc_userStatusOffline: user->onlineTill = d.vstatus().c_userStatusOffline().vwas_online().v; break;
|
||||||
case mtpc_userStatusOnline: user->onlineTill = d.vstatus().c_userStatusOnline().vexpires().v; break;
|
case mtpc_userStatusOnline: user->onlineTill = d.vstatus().c_userStatusOnline().vexpires().v; break;
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(
|
||||||
user,
|
user,
|
||||||
Notify::PeerUpdate::Flag::UserOnlineChanged);
|
Data::PeerUpdate::Flag::OnlineStatus);
|
||||||
}
|
}
|
||||||
if (d.vuser_id().v == session().userId()) {
|
if (d.vuser_id().v == session().userId()) {
|
||||||
if (d.vstatus().type() == mtpc_userStatusOffline
|
if (d.vstatus().type() == mtpc_userStatusOffline
|
||||||
|
@ -1680,9 +1680,9 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||||
: App::formatPhone(user->phone())),
|
: App::formatPhone(user->phone())),
|
||||||
user->username);
|
user->username);
|
||||||
|
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(
|
||||||
user,
|
user,
|
||||||
Notify::PeerUpdate::Flag::UserPhoneChanged);
|
Data::PeerUpdate::Flag::PhoneNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "api/api_updates.h"
|
#include "api/api_updates.h"
|
||||||
#include "data/stickers/data_stickers.h"
|
#include "data/stickers/data_stickers.h"
|
||||||
#include "data/data_drafts.h"
|
#include "data/data_drafts.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_photo.h"
|
#include "data/data_photo.h"
|
||||||
#include "data/data_web_page.h"
|
#include "data/data_web_page.h"
|
||||||
#include "data/data_poll.h"
|
#include "data/data_poll.h"
|
||||||
|
@ -38,7 +39,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/openssl_help.h"
|
#include "base/openssl_help.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "base/call_delayed.h"
|
#include "base/call_delayed.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
@ -358,14 +358,11 @@ void ApiWrap::topPromotionDone(const MTPhelp_PromoData &proxy) {
|
||||||
_session->data().processChats(data.vchats());
|
_session->data().processChats(data.vchats());
|
||||||
_session->data().processUsers(data.vusers());
|
_session->data().processUsers(data.vusers());
|
||||||
const auto peerId = peerFromMTP(data.vpeer());
|
const auto peerId = peerFromMTP(data.vpeer());
|
||||||
const auto peer = _session->data().peer(peerId);
|
const auto history = _session->data().history(peerId);
|
||||||
_session->data().setTopPromoted(
|
_session->data().setTopPromoted(
|
||||||
peer,
|
history,
|
||||||
data.vpsa_type().value_or_empty(),
|
data.vpsa_type().value_or_empty(),
|
||||||
data.vpsa_message().value_or_empty());
|
data.vpsa_message().value_or_empty());
|
||||||
if (const auto history = _session->data().historyLoaded(peer)) {
|
|
||||||
history->owner().histories().requestDialogEntry(history);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,7 +419,7 @@ void ApiWrap::requestTermsUpdate() {
|
||||||
const auto &terms = data.vterms_of_service();
|
const auto &terms = data.vterms_of_service();
|
||||||
const auto &fields = terms.c_help_termsOfService();
|
const auto &fields = terms.c_help_termsOfService();
|
||||||
Core::App().lockByTerms(
|
Core::App().lockByTerms(
|
||||||
Window::TermsLock::FromMTP(&session(), fields));
|
Window::TermsLock::FromMTP(_session, fields));
|
||||||
requestNext(data);
|
requestNext(data);
|
||||||
} break;
|
} break;
|
||||||
default: Unexpected("Type in requestTermsUpdate().");
|
default: Unexpected("Type in requestTermsUpdate().");
|
||||||
|
@ -606,7 +603,7 @@ void ApiWrap::sendMessageFail(
|
||||||
}
|
}
|
||||||
if (const auto item = _session->data().message(itemId)) {
|
if (const auto item = _session->data().message(itemId)) {
|
||||||
Assert(randomId != 0);
|
Assert(randomId != 0);
|
||||||
session().data().unregisterMessageRandomId(randomId);
|
_session->data().unregisterMessageRandomId(randomId);
|
||||||
item->sendFailed();
|
item->sendFailed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1065,7 +1062,7 @@ void ApiWrap::requestWallPaper(
|
||||||
)).done([=](const MTPWallPaper &result) {
|
)).done([=](const MTPWallPaper &result) {
|
||||||
_wallPaperRequestId = 0;
|
_wallPaperRequestId = 0;
|
||||||
_wallPaperSlug = QString();
|
_wallPaperSlug = QString();
|
||||||
if (const auto paper = Data::WallPaper::Create(&session(), result)) {
|
if (const auto paper = Data::WallPaper::Create(_session, result)) {
|
||||||
if (const auto done = base::take(_wallPaperDone)) {
|
if (const auto done = base::take(_wallPaperDone)) {
|
||||||
done(*paper);
|
done(*paper);
|
||||||
}
|
}
|
||||||
|
@ -1261,9 +1258,9 @@ void ApiWrap::migrateChat(
|
||||||
}
|
}
|
||||||
_migrateCallbacks.emplace(chat).first->second.push_back(callback());
|
_migrateCallbacks.emplace(chat).first->second.push_back(callback());
|
||||||
if (const auto channel = chat->migrateTo()) {
|
if (const auto channel = chat->migrateTo()) {
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(
|
||||||
chat,
|
chat,
|
||||||
Notify::PeerUpdate::Flag::MigrationChanged);
|
Data::PeerUpdate::Flag::Migration);
|
||||||
crl::on_main([=] {
|
crl::on_main([=] {
|
||||||
migrateDone(chat, channel);
|
migrateDone(chat, channel);
|
||||||
});
|
});
|
||||||
|
@ -1291,7 +1288,7 @@ void ApiWrap::migrateChat(
|
||||||
chat->inputChat
|
chat->inputChat
|
||||||
)).done([=](const MTPUpdates &result) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
applyUpdates(result);
|
applyUpdates(result);
|
||||||
Notify::peerUpdatedSendDelayed();
|
session().changes().sendNotifications();
|
||||||
|
|
||||||
if (const auto channel = chat->migrateTo()) {
|
if (const auto channel = chat->migrateTo()) {
|
||||||
if (auto handlers = _migrateCallbacks.take(chat)) {
|
if (auto handlers = _migrateCallbacks.take(chat)) {
|
||||||
|
@ -1311,7 +1308,7 @@ void ApiWrap::migrateChat(
|
||||||
void ApiWrap::migrateDone(
|
void ApiWrap::migrateDone(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
not_null<ChannelData*> channel) {
|
not_null<ChannelData*> channel) {
|
||||||
Notify::peerUpdatedSendDelayed();
|
session().changes().sendNotifications();
|
||||||
if (auto handlers = _migrateCallbacks.take(peer)) {
|
if (auto handlers = _migrateCallbacks.take(peer)) {
|
||||||
for (auto &handler : *handlers) {
|
for (auto &handler : *handlers) {
|
||||||
if (handler.done) {
|
if (handler.done) {
|
||||||
|
@ -1602,9 +1599,9 @@ void ApiWrap::applyLastParticipantsList(
|
||||||
//} else {
|
//} else {
|
||||||
// channel->setMembersCount(availableCount);
|
// channel->setMembersCount(availableCount);
|
||||||
//}
|
//}
|
||||||
Notify::PeerUpdate update(channel);
|
session().changes().peerUpdated(
|
||||||
update.flags |= Notify::PeerUpdate::Flag::MembersChanged | Notify::PeerUpdate::Flag::AdminsChanged;
|
channel,
|
||||||
Notify::peerUpdatedDelayed(update);
|
(Data::PeerUpdate::Flag::Members | Data::PeerUpdate::Flag::Admins));
|
||||||
|
|
||||||
channel->mgInfo->botStatus = botStatus;
|
channel->mgInfo->botStatus = botStatus;
|
||||||
fullPeerUpdated().notify(channel);
|
fullPeerUpdated().notify(channel);
|
||||||
|
@ -2008,9 +2005,9 @@ void ApiWrap::stickerSetDisenabled(mtpRequestId requestId) {
|
||||||
|
|
||||||
void ApiWrap::joinChannel(not_null<ChannelData*> channel) {
|
void ApiWrap::joinChannel(not_null<ChannelData*> channel) {
|
||||||
if (channel->amIn()) {
|
if (channel->amIn()) {
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(
|
||||||
channel,
|
channel,
|
||||||
Notify::PeerUpdate::Flag::ChannelAmIn);
|
Data::PeerUpdate::Flag::ChannelAmIn);
|
||||||
} else if (!_channelAmInRequests.contains(channel)) {
|
} else if (!_channelAmInRequests.contains(channel)) {
|
||||||
auto requestId = request(MTPchannels_JoinChannel(
|
auto requestId = request(MTPchannels_JoinChannel(
|
||||||
channel->inputChannel
|
channel->inputChannel
|
||||||
|
@ -2038,9 +2035,9 @@ void ApiWrap::joinChannel(not_null<ChannelData*> channel) {
|
||||||
|
|
||||||
void ApiWrap::leaveChannel(not_null<ChannelData*> channel) {
|
void ApiWrap::leaveChannel(not_null<ChannelData*> channel) {
|
||||||
if (!channel->amIn()) {
|
if (!channel->amIn()) {
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(
|
||||||
channel,
|
channel,
|
||||||
Notify::PeerUpdate::Flag::ChannelAmIn);
|
Data::PeerUpdate::Flag::ChannelAmIn);
|
||||||
} else if (!_channelAmInRequests.contains(channel)) {
|
} else if (!_channelAmInRequests.contains(channel)) {
|
||||||
auto requestId = request(MTPchannels_LeaveChannel(
|
auto requestId = request(MTPchannels_LeaveChannel(
|
||||||
channel->inputChannel
|
channel->inputChannel
|
||||||
|
@ -2057,7 +2054,9 @@ void ApiWrap::leaveChannel(not_null<ChannelData*> channel) {
|
||||||
|
|
||||||
void ApiWrap::blockUser(not_null<UserData*> user) {
|
void ApiWrap::blockUser(not_null<UserData*> user) {
|
||||||
if (user->isBlocked()) {
|
if (user->isBlocked()) {
|
||||||
Notify::peerUpdatedDelayed(user, Notify::PeerUpdate::Flag::UserIsBlocked);
|
session().changes().peerUpdated(
|
||||||
|
user,
|
||||||
|
Data::PeerUpdate::Flag::IsBlocked);
|
||||||
} else if (_blockRequests.find(user) == end(_blockRequests)) {
|
} else if (_blockRequests.find(user) == end(_blockRequests)) {
|
||||||
const auto requestId = request(MTPcontacts_Block(user->inputUser)).done([this, user](const MTPBool &result) {
|
const auto requestId = request(MTPcontacts_Block(user->inputUser)).done([this, user](const MTPBool &result) {
|
||||||
_blockRequests.erase(user);
|
_blockRequests.erase(user);
|
||||||
|
@ -2079,9 +2078,9 @@ void ApiWrap::blockUser(not_null<UserData*> user) {
|
||||||
|
|
||||||
void ApiWrap::unblockUser(not_null<UserData*> user, Fn<void()> onDone) {
|
void ApiWrap::unblockUser(not_null<UserData*> user, Fn<void()> onDone) {
|
||||||
if (!user->isBlocked()) {
|
if (!user->isBlocked()) {
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(
|
||||||
user,
|
user,
|
||||||
Notify::PeerUpdate::Flag::UserIsBlocked);
|
Data::PeerUpdate::Flag::IsBlocked);
|
||||||
return;
|
return;
|
||||||
} else if (_blockRequests.find(user) != end(_blockRequests)) {
|
} else if (_blockRequests.find(user) != end(_blockRequests)) {
|
||||||
return;
|
return;
|
||||||
|
@ -2269,7 +2268,9 @@ void ApiWrap::updatePrivacyLastSeens(const QVector<MTPPrivacyRule> &rules) {
|
||||||
} else {
|
} else {
|
||||||
user->onlineTill = 0;
|
user->onlineTill = 0;
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(user, Notify::PeerUpdate::Flag::UserOnlineChanged);
|
session().changes().peerUpdated(
|
||||||
|
user,
|
||||||
|
Data::PeerUpdate::Flag::OnlineStatus);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (_contactsStatusesRequestId) {
|
if (_contactsStatusesRequestId) {
|
||||||
|
@ -2278,7 +2279,7 @@ void ApiWrap::updatePrivacyLastSeens(const QVector<MTPPrivacyRule> &rules) {
|
||||||
_contactsStatusesRequestId = request(MTPcontacts_GetStatuses(
|
_contactsStatusesRequestId = request(MTPcontacts_GetStatuses(
|
||||||
)).done([=](const MTPVector<MTPContactStatus> &result) {
|
)).done([=](const MTPVector<MTPContactStatus> &result) {
|
||||||
_contactsStatusesRequestId = 0;
|
_contactsStatusesRequestId = 0;
|
||||||
for_const (auto &item, result.v) {
|
for (const auto &item : result.v) {
|
||||||
Assert(item.type() == mtpc_contactStatus);
|
Assert(item.type() == mtpc_contactStatus);
|
||||||
auto &data = item.c_contactStatus();
|
auto &data = item.c_contactStatus();
|
||||||
if (auto user = _session->data().userLoaded(data.vuser_id().v)) {
|
if (auto user = _session->data().userLoaded(data.vuser_id().v)) {
|
||||||
|
@ -2286,7 +2287,9 @@ void ApiWrap::updatePrivacyLastSeens(const QVector<MTPPrivacyRule> &rules) {
|
||||||
auto newOnlineTill = OnlineTillFromStatus(data.vstatus(), oldOnlineTill);
|
auto newOnlineTill = OnlineTillFromStatus(data.vstatus(), oldOnlineTill);
|
||||||
if (oldOnlineTill != newOnlineTill) {
|
if (oldOnlineTill != newOnlineTill) {
|
||||||
user->onlineTill = newOnlineTill;
|
user->onlineTill = newOnlineTill;
|
||||||
Notify::peerUpdatedDelayed(user, Notify::PeerUpdate::Flag::UserOnlineChanged);
|
session().changes().peerUpdated(
|
||||||
|
user,
|
||||||
|
Data::PeerUpdate::Flag::OnlineStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2429,15 +2432,15 @@ void ApiWrap::applyAffectedMessages(
|
||||||
void ApiWrap::saveCurrentDraftToCloud() {
|
void ApiWrap::saveCurrentDraftToCloud() {
|
||||||
Core::App().saveCurrentDraftsToHistories();
|
Core::App().saveCurrentDraftsToHistories();
|
||||||
|
|
||||||
for (const auto controller : session().windows()) {
|
for (const auto controller : _session->windows()) {
|
||||||
if (const auto peer = controller->activeChatCurrent().peer()) {
|
if (const auto peer = controller->activeChatCurrent().peer()) {
|
||||||
if (const auto history = session().data().historyLoaded(peer)) {
|
if (const auto history = _session->data().historyLoaded(peer)) {
|
||||||
session().local().writeDrafts(history);
|
_session->local().writeDrafts(history);
|
||||||
|
|
||||||
const auto localDraft = history->localDraft();
|
const auto localDraft = history->localDraft();
|
||||||
const auto cloudDraft = history->cloudDraft();
|
const auto cloudDraft = history->cloudDraft();
|
||||||
if (!Data::draftsAreEqual(localDraft, cloudDraft)
|
if (!Data::draftsAreEqual(localDraft, cloudDraft)
|
||||||
&& !session().supportMode()) {
|
&& !_session->supportMode()) {
|
||||||
saveDraftToCloudDelayed(history);
|
saveDraftToCloudDelayed(history);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2473,7 +2476,7 @@ void ApiWrap::saveDraftsToCloud() {
|
||||||
flags |= MTPmessages_SaveDraft::Flag::f_entities;
|
flags |= MTPmessages_SaveDraft::Flag::f_entities;
|
||||||
}
|
}
|
||||||
auto entities = Api::EntitiesToMTP(
|
auto entities = Api::EntitiesToMTP(
|
||||||
&session(),
|
_session,
|
||||||
TextUtilities::ConvertTextTagsToEntities(textWithTags.tags),
|
TextUtilities::ConvertTextTagsToEntities(textWithTags.tags),
|
||||||
Api::ConvertOption::SkipLocal);
|
Api::ConvertOption::SkipLocal);
|
||||||
|
|
||||||
|
@ -2709,7 +2712,7 @@ void ApiWrap::requestAttachedStickerSets(not_null<PhotoData*> photo) {
|
||||||
Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now)));
|
Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now)));
|
||||||
return;
|
return;
|
||||||
} else if (result.v.size() > 1) {
|
} else if (result.v.size() > 1) {
|
||||||
Ui::show(Box<StickersBox>(&session(), result));
|
Ui::show(Box<StickersBox>(_session, result));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Single attached sticker pack.
|
// Single attached sticker pack.
|
||||||
|
@ -2827,7 +2830,7 @@ void ApiWrap::refreshFileReference(
|
||||||
origin.data.match([&](Data::FileOriginMessage data) {
|
origin.data.match([&](Data::FileOriginMessage data) {
|
||||||
if (const auto item = _session->data().message(data)) {
|
if (const auto item = _session->data().message(data)) {
|
||||||
if (item->isScheduled()) {
|
if (item->isScheduled()) {
|
||||||
const auto &scheduled = session().data().scheduledMessages();
|
const auto &scheduled = _session->data().scheduledMessages();
|
||||||
const auto realId = scheduled.lookupId(item);
|
const auto realId = scheduled.lookupId(item);
|
||||||
request(MTPmessages_GetScheduledMessages(
|
request(MTPmessages_GetScheduledMessages(
|
||||||
item->history()->peer->input,
|
item->history()->peer->input,
|
||||||
|
@ -2865,16 +2868,16 @@ void ApiWrap::refreshFileReference(
|
||||||
request(MTPmessages_GetRecentStickers(
|
request(MTPmessages_GetRecentStickers(
|
||||||
MTP_flags(0),
|
MTP_flags(0),
|
||||||
MTP_int(0)),
|
MTP_int(0)),
|
||||||
[=] { crl::on_main(&session(), [=] { local().writeRecentStickers(); }); });
|
[=] { crl::on_main(_session, [=] { local().writeRecentStickers(); }); });
|
||||||
} else if (data.setId == Data::Stickers::FavedSetId) {
|
} else if (data.setId == Data::Stickers::FavedSetId) {
|
||||||
request(MTPmessages_GetFavedStickers(MTP_int(0)),
|
request(MTPmessages_GetFavedStickers(MTP_int(0)),
|
||||||
[=] { crl::on_main(&session(), [=] { local().writeFavedStickers(); }); });
|
[=] { crl::on_main(_session, [=] { local().writeFavedStickers(); }); });
|
||||||
} else {
|
} else {
|
||||||
request(MTPmessages_GetStickerSet(
|
request(MTPmessages_GetStickerSet(
|
||||||
MTP_inputStickerSetID(
|
MTP_inputStickerSetID(
|
||||||
MTP_long(data.setId),
|
MTP_long(data.setId),
|
||||||
MTP_long(data.accessHash))),
|
MTP_long(data.accessHash))),
|
||||||
[=] { crl::on_main(&session(), [=] {
|
[=] { crl::on_main(_session, [=] {
|
||||||
local().writeInstalledStickers();
|
local().writeInstalledStickers();
|
||||||
local().writeRecentStickers();
|
local().writeRecentStickers();
|
||||||
local().writeFavedStickers();
|
local().writeFavedStickers();
|
||||||
|
@ -2883,7 +2886,7 @@ void ApiWrap::refreshFileReference(
|
||||||
}, [&](Data::FileOriginSavedGifs data) {
|
}, [&](Data::FileOriginSavedGifs data) {
|
||||||
request(
|
request(
|
||||||
MTPmessages_GetSavedGifs(MTP_int(0)),
|
MTPmessages_GetSavedGifs(MTP_int(0)),
|
||||||
[=] { crl::on_main(&session(), [=] { local().writeSavedGifs(); }); });
|
[=] { crl::on_main(_session, [=] { local().writeSavedGifs(); }); });
|
||||||
}, [&](Data::FileOriginWallpaper data) {
|
}, [&](Data::FileOriginWallpaper data) {
|
||||||
request(MTPaccount_GetWallPaper(
|
request(MTPaccount_GetWallPaper(
|
||||||
MTP_inputWallPaper(
|
MTP_inputWallPaper(
|
||||||
|
@ -2902,7 +2905,7 @@ void ApiWrap::refreshFileReference(
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &result, mtpRequestId req) {
|
void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &result, mtpRequestId req) {
|
||||||
WebPageData::ApplyChanges(&session(), channel, result);
|
WebPageData::ApplyChanges(_session, channel, result);
|
||||||
for (auto i = _webPagesPending.begin(); i != _webPagesPending.cend();) {
|
for (auto i = _webPagesPending.begin(); i != _webPagesPending.cend();) {
|
||||||
if (i.value() == req) {
|
if (i.value() == req) {
|
||||||
if (i.key()->pendingTill > 0) {
|
if (i.key()->pendingTill > 0) {
|
||||||
|
@ -3103,7 +3106,7 @@ void ApiWrap::requestStickers(TimeId now) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
_stickersUpdateRequest = request(MTPmessages_GetAllStickers(
|
_stickersUpdateRequest = request(MTPmessages_GetAllStickers(
|
||||||
MTP_int(Api::CountStickersHash(&session(), true))
|
MTP_int(Api::CountStickersHash(_session, true))
|
||||||
)).done(onDone).fail([=](const RPCError &error) {
|
)).done(onDone).fail([=](const RPCError &error) {
|
||||||
LOG(("App Fail: Failed to get stickers!"));
|
LOG(("App Fail: Failed to get stickers!"));
|
||||||
onDone(MTP_messages_allStickersNotModified());
|
onDone(MTP_messages_allStickersNotModified());
|
||||||
|
@ -3115,7 +3118,7 @@ void ApiWrap::requestRecentStickers(TimeId now) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
requestRecentStickersWithHash(
|
requestRecentStickersWithHash(
|
||||||
Api::CountRecentStickersHash(&session()));
|
Api::CountRecentStickersHash(_session));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiWrap::requestRecentStickersWithHash(int32 hash) {
|
void ApiWrap::requestRecentStickersWithHash(int32 hash) {
|
||||||
|
@ -3157,7 +3160,7 @@ void ApiWrap::requestFavedStickers(TimeId now) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_favedStickersUpdateRequest = request(MTPmessages_GetFavedStickers(
|
_favedStickersUpdateRequest = request(MTPmessages_GetFavedStickers(
|
||||||
MTP_int(Api::CountFavedStickersHash(&session()))
|
MTP_int(Api::CountFavedStickersHash(_session))
|
||||||
)).done([=](const MTPmessages_FavedStickers &result) {
|
)).done([=](const MTPmessages_FavedStickers &result) {
|
||||||
_session->data().stickers().setLastFavedUpdate(crl::now());
|
_session->data().stickers().setLastFavedUpdate(crl::now());
|
||||||
_favedStickersUpdateRequest = 0;
|
_favedStickersUpdateRequest = 0;
|
||||||
|
@ -3189,7 +3192,7 @@ void ApiWrap::requestFeaturedStickers(TimeId now) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_featuredStickersUpdateRequest = request(MTPmessages_GetFeaturedStickers(
|
_featuredStickersUpdateRequest = request(MTPmessages_GetFeaturedStickers(
|
||||||
MTP_int(Api::CountFeaturedStickersHash(&session()))
|
MTP_int(Api::CountFeaturedStickersHash(_session))
|
||||||
)).done([=](const MTPmessages_FeaturedStickers &result) {
|
)).done([=](const MTPmessages_FeaturedStickers &result) {
|
||||||
_session->data().stickers().setLastFeaturedUpdate(crl::now());
|
_session->data().stickers().setLastFeaturedUpdate(crl::now());
|
||||||
_featuredStickersUpdateRequest = 0;
|
_featuredStickersUpdateRequest = 0;
|
||||||
|
@ -3219,7 +3222,7 @@ void ApiWrap::requestSavedGifs(TimeId now) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_savedGifsUpdateRequest = request(MTPmessages_GetSavedGifs(
|
_savedGifsUpdateRequest = request(MTPmessages_GetSavedGifs(
|
||||||
MTP_int(Api::CountSavedGifsHash(&session()))
|
MTP_int(Api::CountSavedGifsHash(_session))
|
||||||
)).done([=](const MTPmessages_SavedGifs &result) {
|
)).done([=](const MTPmessages_SavedGifs &result) {
|
||||||
_session->data().stickers().setLastSavedGifsUpdate(crl::now());
|
_session->data().stickers().setLastSavedGifsUpdate(crl::now());
|
||||||
_savedGifsUpdateRequest = 0;
|
_savedGifsUpdateRequest = 0;
|
||||||
|
@ -3622,7 +3625,7 @@ void ApiWrap::requestSharedMedia(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto history = session().data().history(peer);
|
const auto history = _session->data().history(peer);
|
||||||
auto &histories = history->owner().histories();
|
auto &histories = history->owner().histories();
|
||||||
const auto requestType = Data::Histories::RequestType::History;
|
const auto requestType = Data::Histories::RequestType::History;
|
||||||
histories.sendRequest(history, requestType, [=](Fn<void()> finish) {
|
histories.sendRequest(history, requestType, [=](Fn<void()> finish) {
|
||||||
|
@ -3988,18 +3991,35 @@ void ApiWrap::userPhotosDone(
|
||||||
//}
|
//}
|
||||||
|
|
||||||
void ApiWrap::sendAction(const SendAction &action) {
|
void ApiWrap::sendAction(const SendAction &action) {
|
||||||
session().data().histories().readInbox(action.history);
|
_session->data().histories().readInbox(action.history);
|
||||||
action.history->getReadyFor(ShowAtTheEndMsgId);
|
action.history->getReadyFor(ShowAtTheEndMsgId);
|
||||||
_sendActions.fire_copy(action);
|
_sendActions.fire_copy(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ApiWrap::finishForwarding(const SendAction &action) {
|
||||||
|
const auto history = action.history;
|
||||||
|
auto toForward = history->validateForwardDraft();
|
||||||
|
if (!toForward.empty()) {
|
||||||
|
const auto error = GetErrorTextForSending(history->peer, toForward);
|
||||||
|
if (!error.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
forwardMessages(std::move(toForward), action);
|
||||||
|
_session->data().cancelForwarding(history);
|
||||||
|
}
|
||||||
|
|
||||||
|
_session->data().sendHistoryChangeNotifications();
|
||||||
|
_session->data().newMessageSent(history);
|
||||||
|
}
|
||||||
|
|
||||||
void ApiWrap::forwardMessages(
|
void ApiWrap::forwardMessages(
|
||||||
HistoryItemsList &&items,
|
HistoryItemsList &&items,
|
||||||
const SendAction &action,
|
const SendAction &action,
|
||||||
FnMut<void()> &&successCallback) {
|
FnMut<void()> &&successCallback) {
|
||||||
Expects(!items.empty());
|
Expects(!items.empty());
|
||||||
|
|
||||||
auto &histories = session().data().histories();
|
auto &histories = _session->data().histories();
|
||||||
|
|
||||||
struct SharedCallback {
|
struct SharedCallback {
|
||||||
int requestsLeft = 0;
|
int requestsLeft = 0;
|
||||||
|
@ -4094,7 +4114,7 @@ void ApiWrap::forwardMessages(
|
||||||
if (const auto message = item->toHistoryMessage()) {
|
if (const auto message = item->toHistoryMessage()) {
|
||||||
const auto newId = FullMsgId(
|
const auto newId = FullMsgId(
|
||||||
peerToChannel(peer->id),
|
peerToChannel(peer->id),
|
||||||
session().data().nextLocalMessageId());
|
_session->data().nextLocalMessageId());
|
||||||
const auto self = _session->user();
|
const auto self = _session->user();
|
||||||
const auto messageFromId = channelPost
|
const auto messageFromId = channelPost
|
||||||
? UserId(0)
|
? UserId(0)
|
||||||
|
@ -4170,7 +4190,7 @@ void ApiWrap::sendSharedContact(
|
||||||
|
|
||||||
const auto newId = FullMsgId(
|
const auto newId = FullMsgId(
|
||||||
history->channelId(),
|
history->channelId(),
|
||||||
session().data().nextLocalMessageId());
|
_session->data().nextLocalMessageId());
|
||||||
const auto channelPost = peer->isChannel() && !peer->isMegagroup();
|
const auto channelPost = peer->isChannel() && !peer->isMegagroup();
|
||||||
|
|
||||||
auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media;
|
auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media;
|
||||||
|
@ -4227,11 +4247,8 @@ void ApiWrap::sendSharedContact(
|
||||||
options.silent = _session->data().notifySilentPosts(peer);
|
options.silent = _session->data().notifySilentPosts(peer);
|
||||||
sendMedia(item, media, options);
|
sendMedia(item, media, options);
|
||||||
|
|
||||||
if (const auto main = App::main()) {
|
_session->data().sendHistoryChangeNotifications();
|
||||||
_session->data().sendHistoryChangeNotifications();
|
_session->data().newMessageSent(history);
|
||||||
main->historyToDown(history);
|
|
||||||
main->dialogsToUp();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiWrap::sendVoiceMessage(
|
void ApiWrap::sendVoiceMessage(
|
||||||
|
@ -4411,7 +4428,7 @@ void ApiWrap::editUploadedFile(
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sentEntities = Api::EntitiesToMTP(
|
auto sentEntities = Api::EntitiesToMTP(
|
||||||
&session(),
|
_session,
|
||||||
item->originalText().entities,
|
item->originalText().entities,
|
||||||
Api::ConvertOption::SkipLocal);
|
Api::ConvertOption::SkipLocal);
|
||||||
|
|
||||||
|
@ -4530,7 +4547,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
||||||
while (TextUtilities::CutPart(sending, left, MaxMessageSize)) {
|
while (TextUtilities::CutPart(sending, left, MaxMessageSize)) {
|
||||||
auto newId = FullMsgId(
|
auto newId = FullMsgId(
|
||||||
peerToChannel(peer->id),
|
peerToChannel(peer->id),
|
||||||
session().data().nextLocalMessageId());
|
_session->data().nextLocalMessageId());
|
||||||
auto randomId = rand_value<uint64>();
|
auto randomId = rand_value<uint64>();
|
||||||
|
|
||||||
TextUtilities::Trim(sending);
|
TextUtilities::Trim(sending);
|
||||||
|
@ -4565,10 +4582,10 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
||||||
sendFlags |= MTPmessages_SendMessage::Flag::f_silent;
|
sendFlags |= MTPmessages_SendMessage::Flag::f_silent;
|
||||||
}
|
}
|
||||||
auto localEntities = Api::EntitiesToMTP(
|
auto localEntities = Api::EntitiesToMTP(
|
||||||
&session(),
|
_session,
|
||||||
sending.entities);
|
sending.entities);
|
||||||
auto sentEntities = Api::EntitiesToMTP(
|
auto sentEntities = Api::EntitiesToMTP(
|
||||||
&session(),
|
_session,
|
||||||
sending.entities,
|
sending.entities,
|
||||||
Api::ConvertOption::SkipLocal);
|
Api::ConvertOption::SkipLocal);
|
||||||
if (!sentEntities.v.isEmpty()) {
|
if (!sentEntities.v.isEmpty()) {
|
||||||
|
@ -4640,9 +4657,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto main = App::main()) {
|
finishForwarding(action);
|
||||||
main->finishForwarding(action);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiWrap::sendBotStart(not_null<UserData*> bot, PeerData *chat) {
|
void ApiWrap::sendBotStart(not_null<UserData*> bot, PeerData *chat) {
|
||||||
|
@ -4687,7 +4702,7 @@ void ApiWrap::sendInlineResult(
|
||||||
const auto peer = history->peer;
|
const auto peer = history->peer;
|
||||||
const auto newId = FullMsgId(
|
const auto newId = FullMsgId(
|
||||||
peerToChannel(peer->id),
|
peerToChannel(peer->id),
|
||||||
session().data().nextLocalMessageId());
|
_session->data().nextLocalMessageId());
|
||||||
const auto randomId = rand_value<uint64>();
|
const auto randomId = rand_value<uint64>();
|
||||||
|
|
||||||
auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media;
|
auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media;
|
||||||
|
@ -4758,9 +4773,7 @@ void ApiWrap::sendInlineResult(
|
||||||
).send();
|
).send();
|
||||||
return history->sendRequestId;
|
return history->sendRequestId;
|
||||||
});
|
});
|
||||||
if (const auto main = App::main()) {
|
finishForwarding(action);
|
||||||
main->finishForwarding(action);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiWrap::uploadAlbumMedia(
|
void ApiWrap::uploadAlbumMedia(
|
||||||
|
@ -4859,7 +4872,7 @@ void ApiWrap::sendMediaWithRandomId(
|
||||||
auto caption = item->originalText();
|
auto caption = item->originalText();
|
||||||
TextUtilities::Trim(caption);
|
TextUtilities::Trim(caption);
|
||||||
auto sentEntities = Api::EntitiesToMTP(
|
auto sentEntities = Api::EntitiesToMTP(
|
||||||
&session(),
|
_session,
|
||||||
caption.entities,
|
caption.entities,
|
||||||
Api::ConvertOption::SkipLocal);
|
Api::ConvertOption::SkipLocal);
|
||||||
|
|
||||||
|
@ -5025,7 +5038,7 @@ void ApiWrap::uploadPeerPhoto(not_null<PeerData*> peer, QImage &&image) {
|
||||||
|
|
||||||
const auto fakeId = FullMsgId(
|
const auto fakeId = FullMsgId(
|
||||||
peerToChannel(peer->id),
|
peerToChannel(peer->id),
|
||||||
session().data().nextLocalMessageId());
|
_session->data().nextLocalMessageId());
|
||||||
const auto already = ranges::find(
|
const auto already = ranges::find(
|
||||||
_peerPhotoUploads,
|
_peerPhotoUploads,
|
||||||
peer,
|
peer,
|
||||||
|
@ -5536,7 +5549,7 @@ void ApiWrap::rescheduleMessage(
|
||||||
Api::SendOptions options) {
|
Api::SendOptions options) {
|
||||||
const auto text = item->originalText().text;
|
const auto text = item->originalText().text;
|
||||||
const auto sentEntities = Api::EntitiesToMTP(
|
const auto sentEntities = Api::EntitiesToMTP(
|
||||||
&session(),
|
_session,
|
||||||
item->originalText().entities,
|
item->originalText().entities,
|
||||||
Api::ConvertOption::SkipLocal);
|
Api::ConvertOption::SkipLocal);
|
||||||
const auto media = item->media();
|
const auto media = item->media();
|
||||||
|
|
|
@ -374,6 +374,7 @@ public:
|
||||||
return _sendActions.events();
|
return _sendActions.events();
|
||||||
}
|
}
|
||||||
void sendAction(const SendAction &action);
|
void sendAction(const SendAction &action);
|
||||||
|
void finishForwarding(const SendAction &action);
|
||||||
void forwardMessages(
|
void forwardMessages(
|
||||||
HistoryItemsList &&items,
|
HistoryItemsList &&items,
|
||||||
const SendAction &action,
|
const SendAction &action,
|
||||||
|
|
|
@ -39,7 +39,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "numbers.h"
|
#include "numbers.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
#include "styles/style_overview.h"
|
#include "styles/style_overview.h"
|
||||||
|
|
|
@ -34,11 +34,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_cloud_file.h"
|
#include "data/data_cloud_file.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
|
@ -817,11 +817,13 @@ void SetupChannelBox::prepare() {
|
||||||
connect(&_checkTimer, &QTimer::timeout, [=] { check(); });
|
connect(&_checkTimer, &QTimer::timeout, [=] { check(); });
|
||||||
|
|
||||||
_privacyGroup->setChangedCallback([this](Privacy value) { privacyChanged(value); });
|
_privacyGroup->setChangedCallback([this](Privacy value) { privacyChanged(value); });
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::InviteLinkChanged, [this](const Notify::PeerUpdate &update) {
|
|
||||||
if (update.peer == _channel) {
|
_channel->session().changes().peerUpdates(
|
||||||
rtlupdate(_invitationLink);
|
_channel,
|
||||||
}
|
Data::PeerUpdate::Flag::InviteLink
|
||||||
}));
|
) | rpl::start_with_next([=] {
|
||||||
|
rtlupdate(_invitationLink);
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
boxClosing() | rpl::start_with_next([=] {
|
boxClosing() | rpl::start_with_next([=] {
|
||||||
if (!_existing) {
|
if (!_existing) {
|
||||||
|
|
|
@ -33,9 +33,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_file_origin.h"
|
#include "data/data_file_origin.h"
|
||||||
#include "data/data_histories.h"
|
#include "data/data_histories.h"
|
||||||
#include "data/data_photo_media.h"
|
#include "data/data_photo_media.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
|
@ -367,11 +367,12 @@ void MaxInviteBox::prepare() {
|
||||||
_textHeight = qMin(_text.countHeight(_textWidth), 16 * st::boxLabelStyle.lineHeight);
|
_textHeight = qMin(_text.countHeight(_textWidth), 16 * st::boxLabelStyle.lineHeight);
|
||||||
setDimensions(st::boxWidth, st::boxPadding.top() + _textHeight + st::boxTextFont->height + st::boxTextFont->height * 2 + st::newGroupLinkPadding.bottom());
|
setDimensions(st::boxWidth, st::boxPadding.top() + _textHeight + st::boxTextFont->height + st::boxTextFont->height * 2 + st::newGroupLinkPadding.bottom());
|
||||||
|
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::InviteLinkChanged, [this](const Notify::PeerUpdate &update) {
|
_channel->session().changes().peerUpdates(
|
||||||
if (update.peer == _channel) {
|
_channel,
|
||||||
rtlupdate(_invitationLink);
|
Data::PeerUpdate::Flag::InviteLink
|
||||||
}
|
) | rpl::start_with_next([=] {
|
||||||
}));
|
rtlupdate(_invitationLink);
|
||||||
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxInviteBox::mouseMoveEvent(QMouseEvent *e) {
|
void MaxInviteBox::mouseMoveEvent(QMouseEvent *e) {
|
||||||
|
|
|
@ -19,11 +19,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/wrap/slide_wrap.h"
|
#include "ui/wrap/slide_wrap.h"
|
||||||
#include "ui/text_options.h"
|
#include "ui/text_options.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "storage/file_download.h"
|
#include "storage/file_download.h"
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
|
@ -666,15 +666,18 @@ PeerListContent::PeerListContent(
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
|
|
||||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
using UpdateFlag = Data::PeerUpdate::Flag;
|
||||||
auto changes = UpdateFlag::NameChanged | UpdateFlag::PhotoChanged;
|
_controller->session().changes().peerUpdates(
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(changes, [this](const Notify::PeerUpdate &update) {
|
UpdateFlag::Name | UpdateFlag::Photo
|
||||||
if (update.flags & UpdateFlag::PhotoChanged) {
|
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
|
||||||
this->update();
|
if (update.flags & UpdateFlag::Name) {
|
||||||
} else if (update.flags & UpdateFlag::NameChanged) {
|
handleNameChanged(update.peer);
|
||||||
handleNameChanged(update);
|
|
||||||
}
|
}
|
||||||
}));
|
if (update.flags & UpdateFlag::Photo) {
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &update) {
|
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &update) {
|
||||||
if (update.paletteChanged()) {
|
if (update.paletteChanged()) {
|
||||||
invalidatePixmapsCache();
|
invalidatePixmapsCache();
|
||||||
|
@ -1717,8 +1720,8 @@ PeerListContent::RowIndex PeerListContent::findRowIndex(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerListContent::handleNameChanged(const Notify::PeerUpdate &update) {
|
void PeerListContent::handleNameChanged(not_null<PeerData*> peer) {
|
||||||
auto byPeer = _rowsByPeer.find(update.peer);
|
auto byPeer = _rowsByPeer.find(peer);
|
||||||
if (byPeer != _rowsByPeer.cend()) {
|
if (byPeer != _rowsByPeer.cend()) {
|
||||||
for (auto row : byPeer->second) {
|
for (auto row : byPeer->second) {
|
||||||
if (addingToSearchIndex()) {
|
if (addingToSearchIndex()) {
|
||||||
|
|
|
@ -34,10 +34,6 @@ struct ScrollToRequest;
|
||||||
class PopupMenu;
|
class PopupMenu;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Notify {
|
|
||||||
struct PeerUpdate;
|
|
||||||
} // namespace Notify
|
|
||||||
|
|
||||||
using PaintRoundImageCallback = Fn<void(
|
using PaintRoundImageCallback = Fn<void(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
int x,
|
int x,
|
||||||
|
@ -551,7 +547,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
void refreshIndices();
|
void refreshIndices();
|
||||||
void removeRowAtIndex(std::vector<std::unique_ptr<PeerListRow>> &from, int index);
|
void removeRowAtIndex(std::vector<std::unique_ptr<PeerListRow>> &from, int index);
|
||||||
void handleNameChanged(const Notify::PeerUpdate &update);
|
void handleNameChanged(not_null<PeerData*> peer);
|
||||||
|
|
||||||
void invalidatePixmapsCache();
|
void invalidatePixmapsCache();
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/peer_list_controllers.h"
|
#include "boxes/peer_list_controllers.h"
|
||||||
|
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
|
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "dialogs/dialogs_indexed_list.h"
|
#include "dialogs/dialogs_indexed_list.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
|
@ -23,7 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
|
@ -348,17 +348,16 @@ void AddSpecialBoxController::prepareChatRows(not_null<ChatData*> chat) {
|
||||||
chat->updateFullForced();
|
chat->updateFullForced();
|
||||||
}
|
}
|
||||||
|
|
||||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
using UpdateFlag = Data::PeerUpdate::Flag;
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(
|
chat->session().changes().peerUpdates(
|
||||||
UpdateFlag::MembersChanged | UpdateFlag::AdminsChanged,
|
chat,
|
||||||
[=](const Notify::PeerUpdate &update) {
|
UpdateFlag::Members | UpdateFlag::Admins
|
||||||
if (update.peer == chat) {
|
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
|
||||||
_additional.fillFromPeer();
|
_additional.fillFromPeer();
|
||||||
if (update.flags & UpdateFlag::MembersChanged) {
|
if (update.flags & UpdateFlag::Members) {
|
||||||
rebuildChatRows(chat);
|
rebuildChatRows(chat);
|
||||||
}
|
}
|
||||||
}
|
}, lifetime());
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddSpecialBoxController::rebuildChatRows(not_null<ChatData*> chat) {
|
void AddSpecialBoxController::rebuildChatRows(not_null<ChatData*> chat) {
|
||||||
|
|
|
@ -16,13 +16,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "dialogs/dialogs_indexed_list.h"
|
#include "dialogs/dialogs_indexed_list.h"
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
|
@ -286,20 +286,19 @@ void SubscribeToMigration(
|
||||||
if (const auto channel = peer->migrateTo()) {
|
if (const auto channel = peer->migrateTo()) {
|
||||||
migrate(channel);
|
migrate(channel);
|
||||||
} else if (!chat->isDeactivated()) {
|
} else if (!chat->isDeactivated()) {
|
||||||
const auto alive = lifetime.make_state<base::Subscription>();
|
chat->session().changes().peerUpdates(
|
||||||
const auto handler = [=](const Notify::PeerUpdate &update) {
|
peer,
|
||||||
if (update.peer == peer) {
|
Data::PeerUpdate::Flag::Migration
|
||||||
if (const auto channel = peer->migrateTo()) {
|
) | rpl::map([](const Data::PeerUpdate &update) {
|
||||||
const auto onstack = base::duplicate(migrate);
|
return update.peer->migrateTo();
|
||||||
*alive = base::Subscription();
|
}) | rpl::filter([](ChannelData *channel) {
|
||||||
onstack(channel);
|
return (channel != nullptr);
|
||||||
}
|
}) | rpl::take(
|
||||||
}
|
1
|
||||||
};
|
) | rpl::start_with_next([=](not_null<ChannelData*> channel) {
|
||||||
*alive = Notify::PeerUpdated().add_subscription(
|
const auto onstack = base::duplicate(migrate);
|
||||||
Notify::PeerUpdatedHandler(
|
onstack(channel);
|
||||||
Notify::PeerUpdate::Flag::MigrationChanged,
|
}, lifetime);
|
||||||
handler));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -686,17 +685,15 @@ ParticipantsOnlineSorter::ParticipantsOnlineSorter(
|
||||||
: _peer(peer)
|
: _peer(peer)
|
||||||
, _delegate(delegate)
|
, _delegate(delegate)
|
||||||
, _sortByOnlineTimer([=] { sort(); }) {
|
, _sortByOnlineTimer([=] { sort(); }) {
|
||||||
const auto handleUpdate = [=](const Notify::PeerUpdate &update) {
|
peer->session().changes().peerUpdates(
|
||||||
|
Data::PeerUpdate::Flag::OnlineStatus
|
||||||
|
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
|
||||||
const auto peerId = update.peer->id;
|
const auto peerId = update.peer->id;
|
||||||
if (const auto row = _delegate->peerListFindRow(peerId)) {
|
if (const auto row = _delegate->peerListFindRow(peerId)) {
|
||||||
row->refreshStatus();
|
row->refreshStatus();
|
||||||
sortDelayed();
|
sortDelayed();
|
||||||
}
|
}
|
||||||
};
|
}, _lifetime);
|
||||||
|
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(
|
|
||||||
Notify::PeerUpdate::Flag::UserOnlineChanged,
|
|
||||||
handleUpdate));
|
|
||||||
sort();
|
sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -985,10 +982,10 @@ auto ParticipantsBoxController::saveState() const
|
||||||
|
|
||||||
const auto weak = result.get();
|
const auto weak = result.get();
|
||||||
if (const auto chat = _peer->asChat()) {
|
if (const auto chat = _peer->asChat()) {
|
||||||
Notify::PeerUpdateViewer(
|
chat->session().changes().peerUpdates(
|
||||||
chat,
|
chat,
|
||||||
Notify::PeerUpdate::Flag::MembersChanged
|
Data::PeerUpdate::Flag::Members
|
||||||
) | rpl::start_with_next([=](const Notify::PeerUpdate &) {
|
) | rpl::start_with_next([=] {
|
||||||
weak->controllerState = nullptr;
|
weak->controllerState = nullptr;
|
||||||
}, my->lifetime);
|
}, my->lifetime);
|
||||||
} else if (const auto channel = _peer->asMegagroup()) {
|
} else if (const auto channel = _peer->asMegagroup()) {
|
||||||
|
@ -1104,23 +1101,20 @@ void ParticipantsBoxController::prepareChatRows(not_null<ChatData*> chat) {
|
||||||
chat->updateFullForced();
|
chat->updateFullForced();
|
||||||
}
|
}
|
||||||
|
|
||||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
using UpdateFlag = Data::PeerUpdate::Flag;
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(
|
chat->session().changes().peerUpdates(
|
||||||
UpdateFlag::MembersChanged
|
chat,
|
||||||
| UpdateFlag::AdminsChanged,
|
UpdateFlag::Members | UpdateFlag::Admins
|
||||||
[=](const Notify::PeerUpdate &update) {
|
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
|
||||||
if (update.peer != chat) {
|
_additional.fillFromPeer();
|
||||||
return;
|
if ((update.flags & UpdateFlag::Members)
|
||||||
}
|
|| (_role == Role::Admins)) {
|
||||||
_additional.fillFromPeer();
|
rebuildChatRows(chat);
|
||||||
if ((update.flags & UpdateFlag::MembersChanged)
|
}
|
||||||
|| (_role == Role::Admins)) {
|
if (update.flags & UpdateFlag::Admins) {
|
||||||
rebuildChatRows(chat);
|
rebuildRowTypes();
|
||||||
}
|
}
|
||||||
if (update.flags & UpdateFlag::AdminsChanged) {
|
}, lifetime());
|
||||||
rebuildRowTypes();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticipantsBoxController::rebuildChatRows(not_null<ChatData*> chat) {
|
void ParticipantsBoxController::rebuildChatRows(not_null<ChatData*> chat) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ enum class ParticipantsRole {
|
||||||
Kicked,
|
Kicked,
|
||||||
};
|
};
|
||||||
|
|
||||||
class ParticipantsOnlineSorter : private base::Subscriber {
|
class ParticipantsOnlineSorter {
|
||||||
public:
|
public:
|
||||||
ParticipantsOnlineSorter(
|
ParticipantsOnlineSorter(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
|
@ -63,10 +63,11 @@ private:
|
||||||
void sortDelayed();
|
void sortDelayed();
|
||||||
void refreshOnlineCount();
|
void refreshOnlineCount();
|
||||||
|
|
||||||
not_null<PeerData*> _peer;
|
const not_null<PeerData*> _peer;
|
||||||
not_null<PeerListDelegate*> _delegate;
|
const not_null<PeerListDelegate*> _delegate;
|
||||||
base::Timer _sortByOnlineTimer;
|
base::Timer _sortByOnlineTimer;
|
||||||
rpl::variable<int> _onlineCount = 0;
|
rpl::variable<int> _onlineCount = 0;
|
||||||
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "ui/rp_widget.h"
|
#include "ui/rp_widget.h"
|
||||||
#include "ui/special_buttons.h"
|
#include "ui/special_buttons.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
|
|
|
@ -19,11 +19,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "info/profile/info_profile_values.h"
|
#include "info/profile/info_profile_values.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "ui/rp_widget.h"
|
#include "ui/rp_widget.h"
|
||||||
#include "ui/special_buttons.h"
|
#include "ui/special_buttons.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
|
@ -574,9 +574,9 @@ void Controller::observeInviteLink() {
|
||||||
if (!_controls.editInviteLinkWrap) {
|
if (!_controls.editInviteLinkWrap) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Notify::PeerUpdateValue(
|
_peer->session().changes().peerFlagsValue(
|
||||||
_peer,
|
_peer,
|
||||||
Notify::PeerUpdate::Flag::InviteLinkChanged
|
Data::PeerUpdate::Flag::InviteLink
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
refreshCreateInviteLink();
|
refreshCreateInviteLink();
|
||||||
refreshEditInviteLink();
|
refreshEditInviteLink();
|
||||||
|
|
|
@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/share_box.h"
|
#include "boxes/share_box.h"
|
||||||
|
|
||||||
#include "dialogs/dialogs_indexed_list.h"
|
#include "dialogs/dialogs_indexed_list.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
@ -35,6 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
|
@ -91,7 +91,6 @@ private:
|
||||||
Ui::Animations::Simple nameActive;
|
Ui::Animations::Simple nameActive;
|
||||||
};
|
};
|
||||||
|
|
||||||
void notifyPeerUpdated(const Notify::PeerUpdate &update);
|
|
||||||
void invalidateCache();
|
void invalidateCache();
|
||||||
|
|
||||||
int displayedChatsCount() const;
|
int displayedChatsCount() const;
|
||||||
|
@ -558,11 +557,19 @@ ShareBox::Inner::Inner(
|
||||||
_filter = qsl("a");
|
_filter = qsl("a");
|
||||||
updateFilter();
|
updateFilter();
|
||||||
|
|
||||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
_navigation->session().changes().peerUpdates(
|
||||||
auto observeEvents = UpdateFlag::NameChanged | UpdateFlag::PhotoChanged;
|
Data::PeerUpdate::Flag::Photo
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) {
|
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
|
||||||
notifyPeerUpdated(update);
|
updateChat(update.peer);
|
||||||
}));
|
}, lifetime());
|
||||||
|
|
||||||
|
_navigation->session().changes().realtimeNameUpdates(
|
||||||
|
) | rpl::start_with_next([=](const Data::NameUpdate &update) {
|
||||||
|
_chatsIndexed->peerNameChanged(
|
||||||
|
update.peer,
|
||||||
|
update.oldFirstLetters);
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
subscribe(_navigation->session().downloaderTaskFinished(), [=] {
|
subscribe(_navigation->session().downloaderTaskFinished(), [=] {
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
|
@ -616,16 +623,6 @@ void ShareBox::Inner::activateSkipPage(int pageHeight, int direction) {
|
||||||
activateSkipRow(direction * (pageHeight / _rowHeight));
|
activateSkipRow(direction * (pageHeight / _rowHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShareBox::Inner::notifyPeerUpdated(const Notify::PeerUpdate &update) {
|
|
||||||
if (update.flags & Notify::PeerUpdate::Flag::NameChanged) {
|
|
||||||
_chatsIndexed->peerNameChanged(
|
|
||||||
update.peer,
|
|
||||||
update.oldNameFirstLetters);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateChat(update.peer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShareBox::Inner::updateChat(not_null<PeerData*> peer) {
|
void ShareBox::Inner::updateChat(not_null<PeerData*> peer) {
|
||||||
if (const auto i = _dataMap.find(peer); i != end(_dataMap)) {
|
if (const auto i = _dataMap.find(peer); i != end(_dataMap)) {
|
||||||
updateChatName(i->second.get(), peer);
|
updateChatName(i->second.get(), peer);
|
||||||
|
|
|
@ -33,10 +33,6 @@ class Row;
|
||||||
class IndexedList;
|
class IndexedList;
|
||||||
} // namespace Dialogs
|
} // namespace Dialogs
|
||||||
|
|
||||||
namespace Notify {
|
|
||||||
struct PeerUpdate;
|
|
||||||
} // namespace Notify
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MultiSelect;
|
class MultiSelect;
|
||||||
class InputField;
|
class InputField;
|
||||||
|
|
|
@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_calls.h"
|
#include "styles/style_calls.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "ui/effects/ripple_animation.h"
|
#include "ui/effects/ripple_animation.h"
|
||||||
#include "calls/calls_instance.h"
|
#include "calls/calls_instance.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_file_origin.h"
|
#include "data/data_file_origin.h"
|
||||||
#include "data/data_photo_media.h"
|
#include "data/data_photo_media.h"
|
||||||
#include "data/data_cloud_file.h"
|
#include "data/data_cloud_file.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "calls/calls_emoji_fingerprint.h"
|
#include "calls/calls_emoji_fingerprint.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
|
@ -28,7 +29,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "platform/platform_specific.h"
|
#include "platform/platform_specific.h"
|
||||||
#include "window/main_window.h"
|
#include "window/main_window.h"
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
|
@ -361,13 +361,7 @@ void Panel::initControls() {
|
||||||
subscribe(_call->muteChanged(), [this](bool mute) {
|
subscribe(_call->muteChanged(), [this](bool mute) {
|
||||||
_mute->setIconOverride(mute ? &st::callUnmuteIcon : nullptr);
|
_mute->setIconOverride(mute ? &st::callUnmuteIcon : nullptr);
|
||||||
});
|
});
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::NameChanged, [this](const Notify::PeerUpdate &update) {
|
|
||||||
if (!_call || update.peer != _call->user()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_name->setText(_call->user()->name);
|
|
||||||
updateControlsGeometry();
|
|
||||||
}));
|
|
||||||
_updateDurationTimer.setCallback([this] {
|
_updateDurationTimer.setCallback([this] {
|
||||||
if (_call) {
|
if (_call) {
|
||||||
updateStatusText(_call->state());
|
updateStatusText(_call->state());
|
||||||
|
@ -423,7 +417,7 @@ void Panel::reinitControls() {
|
||||||
st::callPanelSignalBars,
|
st::callPanelSignalBars,
|
||||||
[=] { rtlupdate(signalBarsRect()); });
|
[=] { rtlupdate(signalBarsRect()); });
|
||||||
|
|
||||||
_name->setText(_call->user()->name);
|
_name->setText(_user->name);
|
||||||
updateStatusText(_call->state());
|
updateStatusText(_call->state());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,12 +429,22 @@ void Panel::initLayout() {
|
||||||
|
|
||||||
initGeometry();
|
initGeometry();
|
||||||
|
|
||||||
Notify::PeerUpdateValue(
|
using UpdateFlag = Data::PeerUpdate::Flag;
|
||||||
_user,
|
_user->session().changes().peerUpdates(
|
||||||
Notify::PeerUpdate::Flag::PhotoChanged
|
UpdateFlag::Name | UpdateFlag::Photo
|
||||||
) | rpl::start_with_next(
|
) | rpl::filter([=](const Data::PeerUpdate &update) {
|
||||||
[this] { processUserPhoto(); },
|
// _user may change for the same Panel.
|
||||||
lifetime());
|
return (_call != nullptr) && (update.peer == _user);
|
||||||
|
}) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
|
||||||
|
if (update.flags & UpdateFlag::Name) {
|
||||||
|
_name->setText(_call->user()->name);
|
||||||
|
updateControlsGeometry();
|
||||||
|
}
|
||||||
|
if (update.flags & UpdateFlag::Photo) {
|
||||||
|
processUserPhoto();
|
||||||
|
}
|
||||||
|
}, lifetime());
|
||||||
|
processUserPhoto();
|
||||||
|
|
||||||
subscribe(_user->session().downloaderTaskFinished(), [=] {
|
subscribe(_user->session().downloaderTaskFinished(), [=] {
|
||||||
refreshUserPhoto();
|
refreshUserPhoto();
|
||||||
|
|
|
@ -15,8 +15,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "calls/calls_instance.h"
|
#include "calls/calls_instance.h"
|
||||||
#include "calls/calls_panel.h"
|
#include "calls/calls_panel.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
|
@ -101,13 +101,16 @@ void TopBar::initControls() {
|
||||||
setMuted(mute);
|
setMuted(mute);
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::NameChanged, [this](const Notify::PeerUpdate &update) {
|
|
||||||
if (auto call = _call.get()) {
|
_call->user()->session().changes().peerUpdates(
|
||||||
if (update.peer == call->user()) {
|
Data::PeerUpdate::Flag::Name
|
||||||
updateInfoLabels();
|
) | rpl::filter([=](const Data::PeerUpdate &update) {
|
||||||
}
|
// _user may change for the same Panel.
|
||||||
}
|
return (_call != nullptr) && (update.peer == _call->user());
|
||||||
}));
|
}) | rpl::start_with_next([=] {
|
||||||
|
updateInfoLabels();
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
setInfoLabels();
|
setInfoLabels();
|
||||||
_info->setClickedCallback([=] {
|
_info->setClickedCallback([=] {
|
||||||
if (const auto call = _call.get()) {
|
if (const auto call = _call.get()) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_file_origin.h"
|
#include "data/data_file_origin.h"
|
||||||
#include "data/data_cloud_file.h"
|
#include "data/data_cloud_file.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "chat_helpers/stickers_lottie.h"
|
#include "chat_helpers/stickers_lottie.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
|
@ -32,7 +33,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
#include "window/window_session_controller.h" // GifPauseReason.
|
#include "window/window_session_controller.h" // GifPauseReason.
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "styles/style_chat_helpers.h"
|
#include "styles/style_chat_helpers.h"
|
||||||
|
@ -896,11 +896,19 @@ StickersListWidget::StickersListWidget(
|
||||||
readVisibleFeatured(getVisibleTop(), getVisibleBottom());
|
readVisibleFeatured(getVisibleTop(), getVisibleBottom());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::ChannelStickersChanged, [this](const Notify::PeerUpdate &update) {
|
|
||||||
if (update.peer == _megagroupSet) {
|
session().changes().peerUpdates(
|
||||||
refreshStickers();
|
Data::PeerUpdate::Flag::StickersSet
|
||||||
}
|
) | rpl::filter([=](const Data::PeerUpdate &update) {
|
||||||
}));
|
return (update.peer.get() == _megagroupSet);
|
||||||
|
}) | rpl::start_with_next([=] {
|
||||||
|
refreshStickers();
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
|
session().data().stickers().recentUpdated(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
refreshRecent();
|
||||||
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
Main::Session &StickersListWidget::session() const {
|
Main::Session &StickersListWidget::session() const {
|
||||||
|
|
|
@ -20,10 +20,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/stickers/data_stickers.h"
|
#include "data/stickers/data_stickers.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "styles/style_chat_helpers.h"
|
#include "styles/style_chat_helpers.h"
|
||||||
|
|
||||||
|
@ -347,16 +347,13 @@ TabbedSelector::TabbedSelector(
|
||||||
if (full()) {
|
if (full()) {
|
||||||
_tabsSlider->raise();
|
_tabsSlider->raise();
|
||||||
|
|
||||||
const auto handleUpdate = [=](const Notify::PeerUpdate &update) {
|
session().changes().peerUpdates(
|
||||||
if (update.peer == _currentPeer) {
|
Data::PeerUpdate::Flag::Rights
|
||||||
checkRestrictedPeer();
|
) | rpl::filter([=](const Data::PeerUpdate &update) {
|
||||||
}
|
return (update.peer.get() == _currentPeer);
|
||||||
};
|
}) | rpl::start_with_next([=] {
|
||||||
subscribe(
|
checkRestrictedPeer();
|
||||||
Notify::PeerUpdated(),
|
}, lifetime());
|
||||||
Notify::PeerUpdatedHandler(
|
|
||||||
Notify::PeerUpdate::Flag::RightsChanged,
|
|
||||||
handleUpdate));
|
|
||||||
|
|
||||||
session().api().stickerSetInstalled(
|
session().api().stickerSetInstalled(
|
||||||
) | rpl::start_with_next([this](uint64 setId) {
|
) | rpl::start_with_next([this](uint64 setId) {
|
||||||
|
|
|
@ -35,7 +35,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lang/lang_translator.h"
|
#include "lang/lang_translator.h"
|
||||||
#include "lang/lang_cloud_manager.h"
|
#include "lang/lang_cloud_manager.h"
|
||||||
#include "lang/lang_hardcoded.h"
|
#include "lang/lang_hardcoded.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "storage/storage_databases.h"
|
#include "storage/storage_databases.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "core/file_utilities.h"
|
#include "core/file_utilities.h"
|
||||||
|
@ -502,10 +501,6 @@ void Application::call_handleUnreadCounterUpdate() {
|
||||||
Global::RefUnreadCounterUpdate().notify(true);
|
Global::RefUnreadCounterUpdate().notify(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::call_handleDelayedPeerUpdates() {
|
|
||||||
Notify::peerUpdatedSendDelayed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::call_handleObservables() {
|
void Application::call_handleObservables() {
|
||||||
base::HandleObservables();
|
base::HandleObservables();
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,6 @@ public:
|
||||||
void writeInstallBetaVersionsSetting();
|
void writeInstallBetaVersionsSetting();
|
||||||
|
|
||||||
void call_handleUnreadCounterUpdate();
|
void call_handleUnreadCounterUpdate();
|
||||||
void call_handleDelayedPeerUpdates();
|
|
||||||
void call_handleObservables();
|
void call_handleObservables();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
169
Telegram/SourceFiles/data/data_changes.cpp
Normal file
169
Telegram/SourceFiles/data/data_changes.cpp
Normal file
|
@ -0,0 +1,169 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#include "data/data_changes.h"
|
||||||
|
|
||||||
|
#include "main/main_session.h"
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
|
||||||
|
template <typename DataType, typename UpdateType>
|
||||||
|
void Changes::Manager<DataType, UpdateType>::updated(
|
||||||
|
not_null<DataType*> data,
|
||||||
|
Flags flags) {
|
||||||
|
sendRealtimeNotifications(data, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename DataType, typename UpdateType>
|
||||||
|
void Changes::Manager<DataType, UpdateType>::sendRealtimeNotifications(
|
||||||
|
not_null<DataType*> data,
|
||||||
|
Flags flags) {
|
||||||
|
auto clearRealtime = false;
|
||||||
|
for (auto i = 0; i != kCount; ++i) {
|
||||||
|
const auto flag = static_cast<Flag>(1U << i);
|
||||||
|
if (flags & flag) {
|
||||||
|
_realtimeStreams[i].fire({ data, flags });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename DataType, typename UpdateType>
|
||||||
|
rpl::producer<UpdateType> Changes::Manager<DataType, UpdateType>::updates(
|
||||||
|
Flags flags) const {
|
||||||
|
return _stream.events(
|
||||||
|
) | rpl::filter([=](const UpdateType &update) {
|
||||||
|
return (update.flags & flags);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename DataType, typename UpdateType>
|
||||||
|
rpl::producer<UpdateType> Changes::Manager<DataType, UpdateType>::updates(
|
||||||
|
not_null<DataType*> data,
|
||||||
|
Flags flags) const {
|
||||||
|
return _stream.events(
|
||||||
|
) | rpl::filter([=](const UpdateType &update) {
|
||||||
|
const auto [updateData, updateFlags] = update;
|
||||||
|
return (updateData == data) && (updateFlags & flags);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename DataType, typename UpdateType>
|
||||||
|
auto Changes::Manager<DataType, UpdateType>::realtimeUpdates(Flag flag) const
|
||||||
|
-> rpl::producer<UpdateType> {
|
||||||
|
return _realtimeStreams[CountBit(flag)].events();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename DataType, typename UpdateType>
|
||||||
|
rpl::producer<UpdateType> Changes::Manager<DataType, UpdateType>::flagsValue(
|
||||||
|
not_null<DataType*> data,
|
||||||
|
Flags flags) const {
|
||||||
|
return rpl::single(
|
||||||
|
UpdateType{ data, flags }
|
||||||
|
) | rpl::then(updates(data, flags));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename DataType, typename UpdateType>
|
||||||
|
void Changes::Manager<DataType, UpdateType>::sendNotifications() {
|
||||||
|
for (const auto [data, flags] : base::take(_updates)) {
|
||||||
|
_stream.fire({ data, flags });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Changes::Changes(not_null<Main::Session*> session) : _session(session) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Main::Session &Changes::session() const {
|
||||||
|
return *_session;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Changes::nameUpdated(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
base::flat_set<QChar> oldFirstLetters) {
|
||||||
|
_nameStream.fire({ peer, std::move(oldFirstLetters) });
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<NameUpdate> Changes::realtimeNameUpdates() const {
|
||||||
|
return _nameStream.events();
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<NameUpdate> Changes::realtimeNameUpdates(
|
||||||
|
not_null<PeerData*> peer) const {
|
||||||
|
return _nameStream.events() | rpl::filter([=](const NameUpdate &update) {
|
||||||
|
return (update.peer == peer);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Changes::peerUpdated(not_null<PeerData*> peer, PeerUpdate::Flags flags) {
|
||||||
|
_peerChanges.updated(peer, flags);
|
||||||
|
scheduleNotifications();
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<PeerUpdate> Changes::peerUpdates(
|
||||||
|
PeerUpdate::Flags flags) const {
|
||||||
|
return _peerChanges.updates(flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<PeerUpdate> Changes::peerUpdates(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
PeerUpdate::Flags flags) const {
|
||||||
|
return _peerChanges.updates(peer, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<PeerUpdate> Changes::peerFlagsValue(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
PeerUpdate::Flags flags) const {
|
||||||
|
return _peerChanges.flagsValue(peer, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<PeerUpdate> Changes::realtimePeerUpdates(
|
||||||
|
PeerUpdate::Flag flag) const {
|
||||||
|
return _peerChanges.realtimeUpdates(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Changes::historyUpdated(
|
||||||
|
not_null<History*> history,
|
||||||
|
HistoryUpdate::Flags flags) {
|
||||||
|
_historyChanges.updated(history, flags);
|
||||||
|
scheduleNotifications();
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<HistoryUpdate> Changes::historyUpdates(
|
||||||
|
HistoryUpdate::Flags flags) const {
|
||||||
|
return _historyChanges.updates(flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<HistoryUpdate> Changes::historyUpdates(
|
||||||
|
not_null<History*> history,
|
||||||
|
HistoryUpdate::Flags flags) const {
|
||||||
|
return _historyChanges.updates(history, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<HistoryUpdate> Changes::historyFlagsValue(
|
||||||
|
not_null<History*> history,
|
||||||
|
HistoryUpdate::Flags flags) const {
|
||||||
|
return _historyChanges.flagsValue(history, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Changes::scheduleNotifications() {
|
||||||
|
if (!_notify) {
|
||||||
|
_notify = true;
|
||||||
|
crl::on_main(&session(), [=] {
|
||||||
|
sendNotifications();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Changes::sendNotifications() {
|
||||||
|
if (!_notify) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_notify = false;
|
||||||
|
_peerChanges.sendNotifications();
|
||||||
|
_historyChanges.sendNotifications();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Data
|
197
Telegram/SourceFiles/data/data_changes.h
Normal file
197
Telegram/SourceFiles/data/data_changes.h
Normal file
|
@ -0,0 +1,197 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/flags.h"
|
||||||
|
|
||||||
|
class History;
|
||||||
|
class PeerData;
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
|
||||||
|
struct NameUpdate {
|
||||||
|
NameUpdate(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
base::flat_set<QChar> oldFirstLetters)
|
||||||
|
: peer(peer)
|
||||||
|
, oldFirstLetters(std::move(oldFirstLetters)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
not_null<PeerData*> peer;
|
||||||
|
base::flat_set<QChar> oldFirstLetters;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PeerUpdate {
|
||||||
|
enum class Flag : uint32 {
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
// Common flags
|
||||||
|
Name = (1 << 0),
|
||||||
|
Username = (1 << 1),
|
||||||
|
Photo = (1 << 2),
|
||||||
|
About = (1 << 3),
|
||||||
|
Notifications = (1 << 4),
|
||||||
|
Migration = (1 << 5),
|
||||||
|
UnavailableReason = (1 << 6),
|
||||||
|
PinnedMessage = (1 << 7),
|
||||||
|
|
||||||
|
// For users
|
||||||
|
CanShareContact = (1 << 8),
|
||||||
|
IsContact = (1 << 9),
|
||||||
|
PhoneNumber = (1 << 10),
|
||||||
|
IsBlocked = (1 << 11),
|
||||||
|
OnlineStatus = (1 << 12),
|
||||||
|
BotCommands = (1 << 13),
|
||||||
|
BotCanBeInvited = (1 << 14),
|
||||||
|
CommonChats = (1 << 15),
|
||||||
|
HasCalls = (1 << 16),
|
||||||
|
SupportInfo = (1 << 17),
|
||||||
|
IsBot = (1 << 18),
|
||||||
|
|
||||||
|
// For chats and channels
|
||||||
|
InviteLink = (1 << 19),
|
||||||
|
Members = (1 << 20),
|
||||||
|
Admins = (1 << 21),
|
||||||
|
BannedUsers = (1 << 22),
|
||||||
|
Rights = (1 << 23),
|
||||||
|
|
||||||
|
// For channels
|
||||||
|
ChannelAmIn = (1 << 24),
|
||||||
|
StickersSet = (1 << 25),
|
||||||
|
ChannelLinkedChat = (1 << 26),
|
||||||
|
ChannelLocation = (1 << 27),
|
||||||
|
Slowmode = (1 << 28),
|
||||||
|
|
||||||
|
// For iteration
|
||||||
|
LastUsedBit = (1 << 28),
|
||||||
|
};
|
||||||
|
using Flags = base::flags<Flag>;
|
||||||
|
friend inline constexpr auto is_flag_type(Flag) { return true; }
|
||||||
|
|
||||||
|
not_null<PeerData*> peer;
|
||||||
|
Flags flags = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct HistoryUpdate {
|
||||||
|
enum class Flag : uint32 {
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
IsPinned = (1 << 0),
|
||||||
|
UnreadView = (1 << 1),
|
||||||
|
TopPromoted = (1 << 2),
|
||||||
|
Folder = (1 << 3),
|
||||||
|
UnreadMentions = (1 << 4),
|
||||||
|
LocalMessages = (1 << 5),
|
||||||
|
ChatOccupied = (1 << 6),
|
||||||
|
|
||||||
|
LastUsedBit = (1 << 6),
|
||||||
|
};
|
||||||
|
using Flags = base::flags<Flag>;
|
||||||
|
friend inline constexpr auto is_flag_type(Flag) { return true; }
|
||||||
|
|
||||||
|
not_null<History*> history;
|
||||||
|
Flags flags = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class Changes final {
|
||||||
|
public:
|
||||||
|
explicit Changes(not_null<Main::Session*> session);
|
||||||
|
|
||||||
|
[[nodiscard]] Main::Session &session() const;
|
||||||
|
|
||||||
|
void nameUpdated(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
base::flat_set<QChar> oldFirstLetters);
|
||||||
|
[[nodiscard]] rpl::producer<NameUpdate> realtimeNameUpdates() const;
|
||||||
|
[[nodiscard]] rpl::producer<NameUpdate> realtimeNameUpdates(
|
||||||
|
not_null<PeerData*> peer) const;
|
||||||
|
|
||||||
|
void peerUpdated(not_null<PeerData*> peer, PeerUpdate::Flags flags);
|
||||||
|
[[nodiscard]] rpl::producer<PeerUpdate> peerUpdates(
|
||||||
|
PeerUpdate::Flags flags) const;
|
||||||
|
[[nodiscard]] rpl::producer<PeerUpdate> peerUpdates(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
PeerUpdate::Flags flags) const;
|
||||||
|
[[nodiscard]] rpl::producer<PeerUpdate> peerFlagsValue(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
PeerUpdate::Flags flags) const;
|
||||||
|
[[nodiscard]] rpl::producer<PeerUpdate> realtimePeerUpdates(
|
||||||
|
PeerUpdate::Flag flag) const;
|
||||||
|
|
||||||
|
void historyUpdated(
|
||||||
|
not_null<History*> history,
|
||||||
|
HistoryUpdate::Flags flags);
|
||||||
|
[[nodiscard]] rpl::producer<HistoryUpdate> historyUpdates(
|
||||||
|
HistoryUpdate::Flags flags) const;
|
||||||
|
[[nodiscard]] rpl::producer<HistoryUpdate> historyUpdates(
|
||||||
|
not_null<History*> history,
|
||||||
|
HistoryUpdate::Flags flags) const;
|
||||||
|
[[nodiscard]] rpl::producer<HistoryUpdate> historyFlagsValue(
|
||||||
|
not_null<History*> history,
|
||||||
|
HistoryUpdate::Flags flags) const;
|
||||||
|
|
||||||
|
void sendNotifications();
|
||||||
|
|
||||||
|
private:
|
||||||
|
template <typename Flag>
|
||||||
|
static constexpr int CountBit(Flag Last = Flag::LastUsedBit) {
|
||||||
|
auto i = 0;
|
||||||
|
while ((1ULL << i) != static_cast<uint64>(Last)) {
|
||||||
|
++i;
|
||||||
|
Assert(i != 64);
|
||||||
|
}
|
||||||
|
return (i + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename DataType, typename UpdateType>
|
||||||
|
class Manager final {
|
||||||
|
public:
|
||||||
|
using Flag = typename UpdateType::Flag;
|
||||||
|
using Flags = typename UpdateType::Flags;
|
||||||
|
|
||||||
|
void updated(not_null<DataType*> data, Flags flags);
|
||||||
|
[[nodiscard]] rpl::producer<UpdateType> updates(Flags flags) const;
|
||||||
|
[[nodiscard]] rpl::producer<UpdateType> updates(
|
||||||
|
not_null<DataType*> data,
|
||||||
|
Flags flags) const;
|
||||||
|
[[nodiscard]] rpl::producer<UpdateType> flagsValue(
|
||||||
|
not_null<DataType*> data,
|
||||||
|
Flags flags) const;
|
||||||
|
[[nodiscard]] rpl::producer<UpdateType> realtimeUpdates(
|
||||||
|
Flag flag) const;
|
||||||
|
|
||||||
|
void sendNotifications();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static constexpr auto kCount = CountBit<Flag>();
|
||||||
|
|
||||||
|
void sendRealtimeNotifications(not_null<DataType*> data, Flags flags);
|
||||||
|
|
||||||
|
std::array<rpl::event_stream<UpdateType>, kCount> _realtimeStreams;
|
||||||
|
base::flat_map<not_null<DataType*>, Flags> _updates;
|
||||||
|
rpl::event_stream<UpdateType> _stream;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr auto kHistoryCount = CountBit<HistoryUpdate::Flag>();
|
||||||
|
|
||||||
|
void scheduleNotifications();
|
||||||
|
|
||||||
|
const not_null<Main::Session*> _session;
|
||||||
|
|
||||||
|
rpl::event_stream<NameUpdate> _nameStream;
|
||||||
|
Manager<PeerData, PeerUpdate> _peerChanges;
|
||||||
|
Manager<History, HistoryUpdate> _historyChanges;
|
||||||
|
|
||||||
|
bool _notify = false;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Data
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
|
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_channel_admins.h"
|
#include "data/data_channel_admins.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
|
@ -17,13 +18,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_histories.h"
|
#include "data/data_histories.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
using UpdateFlag = Data::PeerUpdate::Flag;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -66,8 +66,8 @@ ChannelData::ChannelData(not_null<Data::Session*> owner, PeerId id)
|
||||||
) | rpl::distinct_until_changed(
|
) | rpl::distinct_until_changed(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
if (const auto chat = getMigrateFromChat()) {
|
if (const auto chat = getMigrateFromChat()) {
|
||||||
Notify::peerUpdatedDelayed(chat, UpdateFlag::MigrationChanged);
|
session().changes().peerUpdated(chat, UpdateFlag::Migration);
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::MigrationChanged);
|
session().changes().peerUpdated(this, UpdateFlag::Migration);
|
||||||
}
|
}
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ void ChannelData::setAccessHash(uint64 accessHash) {
|
||||||
void ChannelData::setInviteLink(const QString &newInviteLink) {
|
void ChannelData::setInviteLink(const QString &newInviteLink) {
|
||||||
if (newInviteLink != _inviteLink) {
|
if (newInviteLink != _inviteLink) {
|
||||||
_inviteLink = newInviteLink;
|
_inviteLink = newInviteLink;
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::InviteLinkChanged);
|
session().changes().peerUpdated(this, UpdateFlag::InviteLink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,9 +131,9 @@ void ChannelData::setLocation(const MTPChannelLocation &data) {
|
||||||
const auto now = mgInfo->getLocation();
|
const auto now = mgInfo->getLocation();
|
||||||
const auto nowValue = now ? *now : ChannelLocation();
|
const auto nowValue = now ? *now : ChannelLocation();
|
||||||
if (was != now || (was && wasValue != nowValue)) {
|
if (was != now || (was && wasValue != nowValue)) {
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(
|
||||||
this,
|
this,
|
||||||
Notify::PeerUpdate::Flag::ChannelLocation);
|
UpdateFlag::ChannelLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ const ChannelLocation *ChannelData::getLocation() const {
|
||||||
void ChannelData::setLinkedChat(ChannelData *linked) {
|
void ChannelData::setLinkedChat(ChannelData *linked) {
|
||||||
if (_linkedChat != linked) {
|
if (_linkedChat != linked) {
|
||||||
_linkedChat = linked;
|
_linkedChat = linked;
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::ChannelLinkedChat);
|
session().changes().peerUpdated(this, UpdateFlag::ChannelLinkedChat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,28 +159,28 @@ void ChannelData::setMembersCount(int newMembersCount) {
|
||||||
mgInfo->lastParticipantsCount = membersCount();
|
mgInfo->lastParticipantsCount = membersCount();
|
||||||
}
|
}
|
||||||
_membersCount = newMembersCount;
|
_membersCount = newMembersCount;
|
||||||
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::MembersChanged);
|
session().changes().peerUpdated(this, UpdateFlag::Members);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelData::setAdminsCount(int newAdminsCount) {
|
void ChannelData::setAdminsCount(int newAdminsCount) {
|
||||||
if (_adminsCount != newAdminsCount) {
|
if (_adminsCount != newAdminsCount) {
|
||||||
_adminsCount = newAdminsCount;
|
_adminsCount = newAdminsCount;
|
||||||
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::AdminsChanged);
|
session().changes().peerUpdated(this, UpdateFlag::Admins);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelData::setRestrictedCount(int newRestrictedCount) {
|
void ChannelData::setRestrictedCount(int newRestrictedCount) {
|
||||||
if (_restrictedCount != newRestrictedCount) {
|
if (_restrictedCount != newRestrictedCount) {
|
||||||
_restrictedCount = newRestrictedCount;
|
_restrictedCount = newRestrictedCount;
|
||||||
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::BannedUsersChanged);
|
session().changes().peerUpdated(this, UpdateFlag::BannedUsers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelData::setKickedCount(int newKickedCount) {
|
void ChannelData::setKickedCount(int newKickedCount) {
|
||||||
if (_kickedCount != newKickedCount) {
|
if (_kickedCount != newKickedCount) {
|
||||||
_kickedCount = newKickedCount;
|
_kickedCount = newKickedCount;
|
||||||
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::BannedUsersChanged);
|
session().changes().peerUpdated(this, UpdateFlag::BannedUsers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,13 +260,11 @@ void ChannelData::applyEditAdmin(
|
||||||
setAdminsCount(adminsCount() + 1);
|
setAdminsCount(adminsCount() + 1);
|
||||||
updateFullForced();
|
updateFullForced();
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(this, UpdateFlag::Admins);
|
||||||
this,
|
|
||||||
Notify::PeerUpdate::Flag::AdminsChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelData::applyEditBanned(not_null<UserData*> user, const MTPChatBannedRights &oldRights, const MTPChatBannedRights &newRights) {
|
void ChannelData::applyEditBanned(not_null<UserData*> user, const MTPChatBannedRights &oldRights, const MTPChatBannedRights &newRights) {
|
||||||
auto flags = Notify::PeerUpdate::Flag::BannedUsersChanged | Notify::PeerUpdate::Flag::None;
|
auto flags = UpdateFlag::BannedUsers | UpdateFlag::None;
|
||||||
auto isKicked = (newRights.c_chatBannedRights().vflags().v & MTPDchatBannedRights::Flag::f_view_messages);
|
auto isKicked = (newRights.c_chatBannedRights().vflags().v & MTPDchatBannedRights::Flag::f_view_messages);
|
||||||
auto isRestricted = !isKicked && (newRights.c_chatBannedRights().vflags().v != 0);
|
auto isRestricted = !isKicked && (newRights.c_chatBannedRights().vflags().v != 0);
|
||||||
if (mgInfo) {
|
if (mgInfo) {
|
||||||
|
@ -276,7 +274,7 @@ void ChannelData::applyEditBanned(not_null<UserData*> user, const MTPChatBannedR
|
||||||
if (adminsCount() > 1) {
|
if (adminsCount() > 1) {
|
||||||
setAdminsCount(adminsCount() - 1);
|
setAdminsCount(adminsCount() - 1);
|
||||||
} else {
|
} else {
|
||||||
flags |= Notify::PeerUpdate::Flag::AdminsChanged;
|
flags |= UpdateFlag::Admins;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto it = mgInfo->lastRestricted.find(user);
|
auto it = mgInfo->lastRestricted.find(user);
|
||||||
|
@ -312,7 +310,7 @@ void ChannelData::applyEditBanned(not_null<UserData*> user, const MTPChatBannedR
|
||||||
mgInfo->botStatus = -1;
|
mgInfo->botStatus = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flags |= Notify::PeerUpdate::Flag::MembersChanged;
|
flags |= UpdateFlag::Members;
|
||||||
owner().removeMegagroupParticipant(this, user);
|
owner().removeMegagroupParticipant(this, user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,12 +319,12 @@ void ChannelData::applyEditBanned(not_null<UserData*> user, const MTPChatBannedR
|
||||||
if (isKicked) {
|
if (isKicked) {
|
||||||
if (membersCount() > 1) {
|
if (membersCount() > 1) {
|
||||||
setMembersCount(membersCount() - 1);
|
setMembersCount(membersCount() - 1);
|
||||||
flags |= Notify::PeerUpdate::Flag::MembersChanged;
|
flags |= UpdateFlag::Members;
|
||||||
}
|
}
|
||||||
setKickedCount(kickedCount() + 1);
|
setKickedCount(kickedCount() + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(this, flags);
|
session().changes().peerUpdated(this, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelData::markForbidden() {
|
void ChannelData::markForbidden() {
|
||||||
|
@ -366,12 +364,11 @@ auto ChannelData::unavailableReasons() const
|
||||||
return _unavailableReasons;
|
return _unavailableReasons;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelData::setUnavailableReasons(std::vector<Data::UnavailableReason> &&reasons) {
|
void ChannelData::setUnavailableReasons(
|
||||||
|
std::vector<Data::UnavailableReason> &&reasons) {
|
||||||
if (_unavailableReasons != reasons) {
|
if (_unavailableReasons != reasons) {
|
||||||
_unavailableReasons = std::move(reasons);
|
_unavailableReasons = std::move(reasons);
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(this, UpdateFlag::UnavailableReason);
|
||||||
this,
|
|
||||||
Notify::PeerUpdate::Flag::UnavailableReasonChanged);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,7 +535,9 @@ void ChannelData::setAdminRights(const MTPChatAdminRights &rights) {
|
||||||
mgInfo->lastAdmins.remove(self);
|
mgInfo->lastAdmins.remove(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::RightsChanged | UpdateFlag::AdminsChanged | UpdateFlag::BannedUsersChanged);
|
session().changes().peerUpdated(
|
||||||
|
this,
|
||||||
|
UpdateFlag::Rights | UpdateFlag::Admins | UpdateFlag::BannedUsers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelData::setRestrictions(const MTPChatBannedRights &rights) {
|
void ChannelData::setRestrictions(const MTPChatBannedRights &rights) {
|
||||||
|
@ -561,7 +560,9 @@ void ChannelData::setRestrictions(const MTPChatBannedRights &rights) {
|
||||||
mgInfo->lastRestricted.remove(self);
|
mgInfo->lastRestricted.remove(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::RightsChanged | UpdateFlag::AdminsChanged | UpdateFlag::BannedUsersChanged);
|
session().changes().peerUpdated(
|
||||||
|
this,
|
||||||
|
UpdateFlag::Rights | UpdateFlag::Admins | UpdateFlag::BannedUsers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelData::setDefaultRestrictions(const MTPChatBannedRights &rights) {
|
void ChannelData::setDefaultRestrictions(const MTPChatBannedRights &rights) {
|
||||||
|
@ -569,7 +570,7 @@ void ChannelData::setDefaultRestrictions(const MTPChatBannedRights &rights) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_defaultRestrictions.set(rights.c_chatBannedRights().vflags().v);
|
_defaultRestrictions.set(rights.c_chatBannedRights().vflags().v);
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::RightsChanged);
|
session().changes().peerUpdated(this, UpdateFlag::Rights);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ChannelData::applyUpdateVersion(int version) -> UpdateStatus {
|
auto ChannelData::applyUpdateVersion(int version) -> UpdateStatus {
|
||||||
|
@ -597,7 +598,7 @@ void ChannelData::setMigrateFromChat(ChatData *chat) {
|
||||||
if (chat != info->getMigrateFromChat()) {
|
if (chat != info->getMigrateFromChat()) {
|
||||||
info->setMigrateFromChat(chat);
|
info->setMigrateFromChat(chat);
|
||||||
if (amIn()) {
|
if (amIn()) {
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::MigrationChanged);
|
session().changes().peerUpdated(this, UpdateFlag::Migration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -611,7 +612,7 @@ void ChannelData::setSlowmodeSeconds(int seconds) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_slowmodeSeconds = seconds;
|
_slowmodeSeconds = seconds;
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::ChannelSlowmode);
|
session().changes().peerUpdated(this, UpdateFlag::Slowmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeId ChannelData::slowmodeLastMessage() const {
|
TimeId ChannelData::slowmodeLastMessage() const {
|
||||||
|
@ -628,7 +629,7 @@ void ChannelData::growSlowmodeLastMessage(TimeId when) {
|
||||||
} else {
|
} else {
|
||||||
_slowmodeLastMessage = when;
|
_slowmodeLastMessage = when;
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::ChannelSlowmode);
|
session().changes().peerUpdated(this, UpdateFlag::Slowmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
@ -655,6 +656,8 @@ void ApplyChannelUpdate(
|
||||||
void ApplyChannelUpdate(
|
void ApplyChannelUpdate(
|
||||||
not_null<ChannelData*> channel,
|
not_null<ChannelData*> channel,
|
||||||
const MTPDchannelFull &update) {
|
const MTPDchannelFull &update) {
|
||||||
|
const auto session = &channel->session();
|
||||||
|
|
||||||
channel->setAvailableMinId(update.vavailable_min_id().value_or_empty());
|
channel->setAvailableMinId(update.vavailable_min_id().value_or_empty());
|
||||||
auto canViewAdmins = channel->canViewAdmins();
|
auto canViewAdmins = channel->canViewAdmins();
|
||||||
auto canViewMembers = channel->canViewMembers();
|
auto canViewMembers = channel->canViewMembers();
|
||||||
|
@ -672,7 +675,7 @@ void ApplyChannelUpdate(
|
||||||
item.match([&](const MTPDbotInfo &info) {
|
item.match([&](const MTPDbotInfo &info) {
|
||||||
if (const auto user = owner.userLoaded(info.vuser_id().v)) {
|
if (const auto user = owner.userLoaded(info.vuser_id().v)) {
|
||||||
user->setBotInfo(item);
|
user->setBotInfo(item);
|
||||||
channel->session().api().fullPeerUpdated().notify(user);
|
session->api().fullPeerUpdated().notify(user);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -746,21 +749,17 @@ void ApplyChannelUpdate(
|
||||||
: MTP_inputStickerSetEmpty();
|
: MTP_inputStickerSetEmpty();
|
||||||
}
|
}
|
||||||
if (stickersChanged) {
|
if (stickersChanged) {
|
||||||
Notify::peerUpdatedDelayed(
|
session->changes().peerUpdated(channel, UpdateFlag::StickersSet);
|
||||||
channel,
|
|
||||||
Notify::PeerUpdate::Flag::ChannelStickersChanged);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
channel->fullUpdated();
|
channel->fullUpdated();
|
||||||
|
|
||||||
if (canViewAdmins != channel->canViewAdmins()
|
if (canViewAdmins != channel->canViewAdmins()
|
||||||
|| canViewMembers != channel->canViewMembers()) {
|
|| canViewMembers != channel->canViewMembers()) {
|
||||||
Notify::peerUpdatedDelayed(
|
session->changes().peerUpdated(channel, UpdateFlag::Rights);
|
||||||
channel,
|
|
||||||
Notify::PeerUpdate::Flag::RightsChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
channel->session().api().applyNotifySettings(
|
session->api().applyNotifySettings(
|
||||||
MTP_inputNotifyPeer(channel->input),
|
MTP_inputNotifyPeer(channel->input),
|
||||||
update.vnotify_settings());
|
update.vnotify_settings());
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
using UpdateFlag = Data::PeerUpdate::Flag;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -96,16 +96,12 @@ void ChatData::setName(const QString &newName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatData::applyEditAdmin(not_null<UserData*> user, bool isAdmin) {
|
void ChatData::applyEditAdmin(not_null<UserData*> user, bool isAdmin) {
|
||||||
auto flags = Notify::PeerUpdate::Flag::AdminsChanged
|
|
||||||
| Notify::PeerUpdate::Flag::None;
|
|
||||||
if (isAdmin) {
|
if (isAdmin) {
|
||||||
admins.emplace(user);
|
admins.emplace(user);
|
||||||
} else {
|
} else {
|
||||||
admins.remove(user);
|
admins.remove(user);
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(this, UpdateFlag::Admins);
|
||||||
this,
|
|
||||||
Notify::PeerUpdate::Flag::AdminsChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatData::invalidateParticipants() {
|
void ChatData::invalidateParticipants() {
|
||||||
|
@ -115,15 +111,15 @@ void ChatData::invalidateParticipants() {
|
||||||
//setDefaultRestrictions(MTP_chatBannedRights(MTP_flags(0), MTP_int(0)));
|
//setDefaultRestrictions(MTP_chatBannedRights(MTP_flags(0), MTP_int(0)));
|
||||||
invitedByMe.clear();
|
invitedByMe.clear();
|
||||||
botStatus = 0;
|
botStatus = 0;
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(
|
||||||
this,
|
this,
|
||||||
UpdateFlag::MembersChanged | UpdateFlag::AdminsChanged);
|
UpdateFlag::Members | UpdateFlag::Admins);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatData::setInviteLink(const QString &newInviteLink) {
|
void ChatData::setInviteLink(const QString &newInviteLink) {
|
||||||
if (newInviteLink != _inviteLink) {
|
if (newInviteLink != _inviteLink) {
|
||||||
_inviteLink = newInviteLink;
|
_inviteLink = newInviteLink;
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::InviteLinkChanged);
|
session().changes().peerUpdated(this, UpdateFlag::InviteLink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,11 +128,9 @@ void ChatData::setAdminRights(const MTPChatAdminRights &rights) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_adminRights.set(rights.c_chatAdminRights().vflags().v);
|
_adminRights.set(rights.c_chatAdminRights().vflags().v);
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(
|
||||||
this,
|
this,
|
||||||
(UpdateFlag::RightsChanged
|
UpdateFlag::Rights | UpdateFlag::Admins | UpdateFlag::BannedUsers);
|
||||||
| UpdateFlag::AdminsChanged
|
|
||||||
| UpdateFlag::BannedUsersChanged));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatData::setDefaultRestrictions(const MTPChatBannedRights &rights) {
|
void ChatData::setDefaultRestrictions(const MTPChatBannedRights &rights) {
|
||||||
|
@ -144,7 +138,7 @@ void ChatData::setDefaultRestrictions(const MTPChatBannedRights &rights) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_defaultRestrictions.set(rights.c_chatBannedRights().vflags().v);
|
_defaultRestrictions.set(rights.c_chatBannedRights().vflags().v);
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::RightsChanged);
|
session().changes().peerUpdated(this, UpdateFlag::Rights);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatData::refreshBotStatus() {
|
void ChatData::refreshBotStatus() {
|
||||||
|
@ -176,7 +170,7 @@ void ChatData::setMigrateToChannel(ChannelData *channel) {
|
||||||
if (_migratedTo != channel) {
|
if (_migratedTo != channel) {
|
||||||
_migratedTo = channel;
|
_migratedTo = channel;
|
||||||
if (channel->amIn()) {
|
if (channel->amIn()) {
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::MigrationChanged);
|
session().changes().peerUpdated(this, UpdateFlag::Migration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,6 +193,7 @@ void ApplyChatUpdate(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto user = chat->owner().userLoaded(update.vuser_id().v);
|
const auto user = chat->owner().userLoaded(update.vuser_id().v);
|
||||||
|
const auto session = &chat->session();
|
||||||
if (!user
|
if (!user
|
||||||
|| (!chat->participants.empty()
|
|| (!chat->participants.empty()
|
||||||
&& chat->participants.contains(user))) {
|
&& chat->participants.contains(user))) {
|
||||||
|
@ -213,7 +208,7 @@ void ApplyChatUpdate(
|
||||||
chat->botStatus = 0;
|
chat->botStatus = 0;
|
||||||
} else {
|
} else {
|
||||||
chat->participants.emplace(user);
|
chat->participants.emplace(user);
|
||||||
if (update.vinviter_id().v == chat->session().userId()) {
|
if (update.vinviter_id().v == session->userId()) {
|
||||||
chat->invitedByMe.insert(user);
|
chat->invitedByMe.insert(user);
|
||||||
} else {
|
} else {
|
||||||
chat->invitedByMe.remove(user);
|
chat->invitedByMe.remove(user);
|
||||||
|
@ -222,13 +217,11 @@ void ApplyChatUpdate(
|
||||||
if (user->isBot()) {
|
if (user->isBot()) {
|
||||||
chat->botStatus = 2;
|
chat->botStatus = 2;
|
||||||
if (!user->botInfo->inited) {
|
if (!user->botInfo->inited) {
|
||||||
chat->session().api().requestFullPeer(user);
|
session->api().requestFullPeer(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(
|
session->changes().peerUpdated(chat, UpdateFlag::Members);
|
||||||
chat,
|
|
||||||
Notify::PeerUpdate::Flag::MembersChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyChatUpdate(
|
void ApplyChatUpdate(
|
||||||
|
@ -270,9 +263,7 @@ void ApplyChatUpdate(
|
||||||
chat->refreshBotStatus();
|
chat->refreshBotStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(
|
chat->session().changes().peerUpdated(chat, UpdateFlag::Members);
|
||||||
chat,
|
|
||||||
Notify::PeerUpdate::Flag::MembersChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyChatUpdate(
|
void ApplyChatUpdate(
|
||||||
|
@ -282,7 +273,7 @@ void ApplyChatUpdate(
|
||||||
!= ChatData::UpdateStatus::Good) {
|
!= ChatData::UpdateStatus::Good) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const auto session = &chat->session();
|
||||||
const auto user = chat->owner().userLoaded(update.vuser_id().v);
|
const auto user = chat->owner().userLoaded(update.vuser_id().v);
|
||||||
if (!user) {
|
if (!user) {
|
||||||
chat->invalidateParticipants();
|
chat->invalidateParticipants();
|
||||||
|
@ -295,16 +286,14 @@ void ApplyChatUpdate(
|
||||||
}
|
}
|
||||||
if (mtpIsTrue(update.vis_admin())) {
|
if (mtpIsTrue(update.vis_admin())) {
|
||||||
if (chat->noParticipantInfo()) {
|
if (chat->noParticipantInfo()) {
|
||||||
chat->session().api().requestFullPeer(chat);
|
session->api().requestFullPeer(chat);
|
||||||
} else {
|
} else {
|
||||||
chat->admins.emplace(user);
|
chat->admins.emplace(user);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chat->admins.erase(user);
|
chat->admins.erase(user);
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(
|
session->changes().peerUpdated(chat, UpdateFlag::Admins);
|
||||||
chat,
|
|
||||||
Notify::PeerUpdate::Flag::AdminsChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyChatUpdate(
|
void ApplyChatUpdate(
|
||||||
|
@ -360,6 +349,7 @@ void ApplyChatUpdate(not_null<ChatData*> chat, const MTPDchatFull &update) {
|
||||||
void ApplyChatUpdate(
|
void ApplyChatUpdate(
|
||||||
not_null<ChatData*> chat,
|
not_null<ChatData*> chat,
|
||||||
const MTPChatParticipants &participants) {
|
const MTPChatParticipants &participants) {
|
||||||
|
const auto session = &chat->session();
|
||||||
participants.match([&](const MTPDchatParticipantsForbidden &data) {
|
participants.match([&](const MTPDchatParticipantsForbidden &data) {
|
||||||
if (const auto self = data.vself_participant()) {
|
if (const auto self = data.vself_participant()) {
|
||||||
// self->
|
// self->
|
||||||
|
@ -381,7 +371,7 @@ void ApplyChatUpdate(
|
||||||
chat->invitedByMe.clear();
|
chat->invitedByMe.clear();
|
||||||
chat->admins.clear();
|
chat->admins.clear();
|
||||||
chat->setAdminRights(MTP_chatAdminRights(MTP_flags(0)));
|
chat->setAdminRights(MTP_chatAdminRights(MTP_flags(0)));
|
||||||
const auto selfUserId = chat->session().userId();
|
const auto selfUserId = session->userId();
|
||||||
for (const auto &participant : list) {
|
for (const auto &participant : list) {
|
||||||
const auto userId = participant.match([&](const auto &data) {
|
const auto userId = participant.match([&](const auto &data) {
|
||||||
return data.vuser_id().v;
|
return data.vuser_id().v;
|
||||||
|
@ -430,10 +420,9 @@ void ApplyChatUpdate(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chat->refreshBotStatus();
|
chat->refreshBotStatus();
|
||||||
Notify::peerUpdatedDelayed(
|
session->changes().peerUpdated(
|
||||||
chat,
|
chat,
|
||||||
Notify::PeerUpdate::Flag::MembersChanged
|
UpdateFlag::Members | UpdateFlag::Admins);
|
||||||
| Notify::PeerUpdate::Flag::AdminsChanged);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -236,6 +236,7 @@ not_null<Dialogs::MainList*> ChatFilters::chatsList(FilterId filterId) {
|
||||||
auto &pointer = _chatsLists[filterId];
|
auto &pointer = _chatsLists[filterId];
|
||||||
if (!pointer) {
|
if (!pointer) {
|
||||||
pointer = std::make_unique<Dialogs::MainList>(
|
pointer = std::make_unique<Dialogs::MainList>(
|
||||||
|
&_owner->session(),
|
||||||
filterId,
|
filterId,
|
||||||
rpl::single(ChatFilter::kPinnedLimit));
|
rpl::single(ChatFilter::kPinnedLimit));
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_histories.h"
|
#include "data/data_histories.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "dialogs/dialogs_key.h"
|
#include "dialogs/dialogs_key.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
|
@ -19,7 +20,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
//#include "storage/storage_feed_messages.h" // #feed
|
//#include "storage/storage_feed_messages.h" // #feed
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
|
@ -57,20 +57,20 @@ rpl::producer<int> PinnedDialogsInFolderMaxValue(
|
||||||
Folder::Folder(not_null<Data::Session*> owner, FolderId id)
|
Folder::Folder(not_null<Data::Session*> owner, FolderId id)
|
||||||
: Entry(owner, this)
|
: Entry(owner, this)
|
||||||
, _id(id)
|
, _id(id)
|
||||||
, _chatsList(FilterId(), PinnedDialogsInFolderMaxValue(&owner->session()))
|
, _chatsList(
|
||||||
|
&owner->session(),
|
||||||
|
FilterId(),
|
||||||
|
PinnedDialogsInFolderMaxValue(&owner->session()))
|
||||||
, _name(tr::lng_archived_name(tr::now)) {
|
, _name(tr::lng_archived_name(tr::now)) {
|
||||||
indexNameParts();
|
indexNameParts();
|
||||||
|
|
||||||
Notify::PeerUpdateViewer(
|
session().changes().peerUpdates(
|
||||||
Notify::PeerUpdate::Flag::NameChanged
|
PeerUpdate::Flag::Name
|
||||||
) | rpl::start_with_next([=](const Notify::PeerUpdate &update) {
|
) | rpl::filter([=](const PeerUpdate &update) {
|
||||||
for (const auto history : _lastHistories) {
|
return ranges::contains(_lastHistories, update.peer, &History::peer);
|
||||||
if (history->peer == update.peer) {
|
}) | rpl::start_with_next([=] {
|
||||||
++_chatListViewVersion;
|
++_chatListViewVersion;
|
||||||
updateChatListEntryPostponed();
|
updateChatListEntryPostponed();
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
|
|
||||||
_chatsList.setAllAreMuted(true);
|
_chatsList.setAllAreMuted(true);
|
||||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_photo.h"
|
#include "data/data_photo.h"
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
@ -18,7 +19,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "base/crc32hash.h"
|
#include "base/crc32hash.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
@ -42,7 +42,7 @@ namespace {
|
||||||
constexpr auto kUpdateFullPeerTimeout = crl::time(5000); // Not more than once in 5 seconds.
|
constexpr auto kUpdateFullPeerTimeout = crl::time(5000); // Not more than once in 5 seconds.
|
||||||
constexpr auto kUserpicSize = 160;
|
constexpr auto kUserpicSize = 160;
|
||||||
|
|
||||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
using UpdateFlag = Data::PeerUpdate::Flag;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -147,15 +147,17 @@ void PeerData::updateNameDelayed(
|
||||||
_nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions());
|
_nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions());
|
||||||
_userpicEmpty = nullptr;
|
_userpicEmpty = nullptr;
|
||||||
|
|
||||||
Notify::PeerUpdate update(this);
|
auto flags = UpdateFlag::None | UpdateFlag::None;
|
||||||
if (nameVersion++ > 1) {
|
auto oldFirstLetters = base::flat_set<QChar>();
|
||||||
update.flags |= UpdateFlag::NameChanged;
|
const auto nameUpdated = (nameVersion++ > 1);
|
||||||
update.oldNameFirstLetters = nameFirstLetters();
|
if (nameUpdated) {
|
||||||
|
oldFirstLetters = nameFirstLetters();
|
||||||
|
flags |= UpdateFlag::Name;
|
||||||
}
|
}
|
||||||
if (isUser()) {
|
if (isUser()) {
|
||||||
if (asUser()->username != newUsername) {
|
if (asUser()->username != newUsername) {
|
||||||
asUser()->username = newUsername;
|
asUser()->username = newUsername;
|
||||||
update.flags |= UpdateFlag::UsernameChanged;
|
flags |= UpdateFlag::Username;
|
||||||
}
|
}
|
||||||
asUser()->setNameOrPhone(newNameOrPhone);
|
asUser()->setNameOrPhone(newNameOrPhone);
|
||||||
} else if (isChannel()) {
|
} else if (isChannel()) {
|
||||||
|
@ -167,12 +169,15 @@ void PeerData::updateNameDelayed(
|
||||||
} else {
|
} else {
|
||||||
asChannel()->addFlags(MTPDchannel::Flag::f_username);
|
asChannel()->addFlags(MTPDchannel::Flag::f_username);
|
||||||
}
|
}
|
||||||
update.flags |= UpdateFlag::UsernameChanged;
|
flags |= UpdateFlag::Username;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fillNames();
|
fillNames();
|
||||||
if (update.flags) {
|
if (nameUpdated) {
|
||||||
Notify::PeerUpdated().notify(update, true);
|
session().changes().nameUpdated(this, std::move(oldFirstLetters));
|
||||||
|
}
|
||||||
|
if (flags) {
|
||||||
|
session().changes().peerUpdated(this, flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +209,7 @@ void PeerData::setUserpicPhoto(const MTPPhoto &data) {
|
||||||
});
|
});
|
||||||
if (_userpicPhotoId != photoId) {
|
if (_userpicPhotoId != photoId) {
|
||||||
_userpicPhotoId = photoId;
|
_userpicPhotoId = photoId;
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::PhotoChanged);
|
session().changes().peerUpdated(this, UpdateFlag::Photo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +389,7 @@ void PeerData::setUserpicChecked(
|
||||||
const ImageLocation &location) {
|
const ImageLocation &location) {
|
||||||
if (_userpicPhotoId != photoId || _userpic.location() != location) {
|
if (_userpicPhotoId != photoId || _userpic.location() != location) {
|
||||||
setUserpic(photoId, location);
|
setUserpic(photoId, location);
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::PhotoChanged);
|
session().changes().peerUpdated(this, UpdateFlag::Photo);
|
||||||
//if (const auto channel = asChannel()) { // #feed
|
//if (const auto channel = asChannel()) { // #feed
|
||||||
// if (const auto feed = channel->feed()) {
|
// if (const auto feed = channel->feed()) {
|
||||||
// owner().notifyFeedUpdated(
|
// owner().notifyFeedUpdated(
|
||||||
|
@ -454,9 +459,7 @@ void PeerData::setPinnedMessageId(MsgId messageId) {
|
||||||
messageId = (messageId > min) ? messageId : MsgId(0);
|
messageId = (messageId > min) ? messageId : MsgId(0);
|
||||||
if (_pinnedMessageId != messageId) {
|
if (_pinnedMessageId != messageId) {
|
||||||
_pinnedMessageId = messageId;
|
_pinnedMessageId = messageId;
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(this, UpdateFlag::PinnedMessage);
|
||||||
this,
|
|
||||||
Notify::PeerUpdate::Flag::PinnedMessageChanged);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,7 +482,7 @@ bool PeerData::setAbout(const QString &newAbout) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_about = newAbout;
|
_about = newAbout;
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::AboutChanged);
|
session().changes().peerUpdated(this, UpdateFlag::About);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
@ -34,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
#include "lang/lang_keys.h" // tr::lng_deleted(tr::now) in user name
|
#include "lang/lang_keys.h" // tr::lng_deleted(tr::now) in user name
|
||||||
#include "data/stickers/data_stickers.h"
|
#include "data/stickers/data_stickers.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_media_types.h"
|
#include "data/data_media_types.h"
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
|
@ -209,7 +209,7 @@ Session::Session(not_null<Main::Session*> session)
|
||||||
, _bigFileCache(Core::App().databases().get(
|
, _bigFileCache(Core::App().databases().get(
|
||||||
_session->local().cacheBigFilePath(),
|
_session->local().cacheBigFilePath(),
|
||||||
_session->local().cacheBigFileSettings()))
|
_session->local().cacheBigFileSettings()))
|
||||||
, _chatsList(FilterId(), PinnedDialogsCountMaxValue(session))
|
, _chatsList(session, FilterId(), PinnedDialogsCountMaxValue(session))
|
||||||
, _contactsList(Dialogs::SortMode::Name)
|
, _contactsList(Dialogs::SortMode::Name)
|
||||||
, _contactsNoChatsList(Dialogs::SortMode::Name)
|
, _contactsNoChatsList(Dialogs::SortMode::Name)
|
||||||
, _selfDestructTimer([=] { checkSelfDestructItems(); })
|
, _selfDestructTimer([=] { checkSelfDestructItems(); })
|
||||||
|
@ -353,8 +353,8 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
|
||||||
const MTPUserStatus *status = nullptr;
|
const MTPUserStatus *status = nullptr;
|
||||||
const MTPUserStatus emptyStatus = MTP_userStatusEmpty();
|
const MTPUserStatus emptyStatus = MTP_userStatusEmpty();
|
||||||
|
|
||||||
Notify::PeerUpdate update;
|
using UpdateFlag = PeerUpdate::Flag;
|
||||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
auto flags = UpdateFlag::None | UpdateFlag::None;
|
||||||
data.match([&](const MTPDuserEmpty &data) {
|
data.match([&](const MTPDuserEmpty &data) {
|
||||||
const auto canShareThisContact = result->canShareThisContactFast();
|
const auto canShareThisContact = result->canShareThisContactFast();
|
||||||
|
|
||||||
|
@ -366,13 +366,13 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
|
||||||
result->setFlags(MTPDuser::Flag::f_deleted);
|
result->setFlags(MTPDuser::Flag::f_deleted);
|
||||||
if (!result->phone().isEmpty()) {
|
if (!result->phone().isEmpty()) {
|
||||||
result->setPhone(QString());
|
result->setPhone(QString());
|
||||||
update.flags |= UpdateFlag::UserPhoneChanged;
|
flags |= UpdateFlag::PhoneNumber;
|
||||||
}
|
}
|
||||||
result->setBotInfoVersion(-1);
|
result->setBotInfoVersion(-1);
|
||||||
status = &emptyStatus;
|
status = &emptyStatus;
|
||||||
result->setIsContact(false);
|
result->setIsContact(false);
|
||||||
if (canShareThisContact != result->canShareThisContactFast()) {
|
if (canShareThisContact != result->canShareThisContactFast()) {
|
||||||
update.flags |= UpdateFlag::UserCanShareContact;
|
flags |= UpdateFlag::CanShareContact;
|
||||||
}
|
}
|
||||||
}, [&](const MTPDuser &data) {
|
}, [&](const MTPDuser &data) {
|
||||||
minimal = data.is_min();
|
minimal = data.is_min();
|
||||||
|
@ -405,7 +405,7 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
|
||||||
if (data.is_deleted()) {
|
if (data.is_deleted()) {
|
||||||
if (!result->phone().isEmpty()) {
|
if (!result->phone().isEmpty()) {
|
||||||
result->setPhone(QString());
|
result->setPhone(QString());
|
||||||
update.flags |= UpdateFlag::UserPhoneChanged;
|
flags |= UpdateFlag::PhoneNumber;
|
||||||
}
|
}
|
||||||
result->setName(tr::lng_deleted(tr::now), QString(), QString(), QString());
|
result->setName(tr::lng_deleted(tr::now), QString(), QString(), QString());
|
||||||
result->setPhoto(MTP_userProfilePhotoEmpty());
|
result->setPhoto(MTP_userProfilePhotoEmpty());
|
||||||
|
@ -423,7 +423,7 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
|
||||||
const auto phoneChanged = (result->phone() != phone);
|
const auto phoneChanged = (result->phone() != phone);
|
||||||
if (phoneChanged) {
|
if (phoneChanged) {
|
||||||
result->setPhone(phone);
|
result->setPhone(phone);
|
||||||
update.flags |= UpdateFlag::UserPhoneChanged;
|
flags |= UpdateFlag::PhoneNumber;
|
||||||
}
|
}
|
||||||
const auto nameChanged = (result->firstName != fname)
|
const auto nameChanged = (result->firstName != fname)
|
||||||
|| (result->lastName != lname);
|
|| (result->lastName != lname);
|
||||||
|
@ -475,7 +475,7 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
|
||||||
result->botInfo->readsAllHistory = data.is_bot_chat_history();
|
result->botInfo->readsAllHistory = data.is_bot_chat_history();
|
||||||
if (result->botInfo->cantJoinGroups != data.is_bot_nochats()) {
|
if (result->botInfo->cantJoinGroups != data.is_bot_nochats()) {
|
||||||
result->botInfo->cantJoinGroups = data.is_bot_nochats();
|
result->botInfo->cantJoinGroups = data.is_bot_nochats();
|
||||||
update.flags |= UpdateFlag::BotCanAddToGroups;
|
flags |= UpdateFlag::BotCanBeInvited;
|
||||||
}
|
}
|
||||||
if (const auto placeholder = data.vbot_inline_placeholder()) {
|
if (const auto placeholder = data.vbot_inline_placeholder()) {
|
||||||
result->botInfo->inlinePlaceholder = '_' + qs(*placeholder);
|
result->botInfo->inlinePlaceholder = '_' + qs(*placeholder);
|
||||||
|
@ -490,7 +490,7 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canShareThisContact != result->canShareThisContactFast()) {
|
if (canShareThisContact != result->canShareThisContactFast()) {
|
||||||
update.flags |= UpdateFlag::UserCanShareContact;
|
flags |= UpdateFlag::CanShareContact;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -510,15 +510,12 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
|
||||||
oldOnlineTill);
|
oldOnlineTill);
|
||||||
if (oldOnlineTill != newOnlineTill) {
|
if (oldOnlineTill != newOnlineTill) {
|
||||||
result->onlineTill = newOnlineTill;
|
result->onlineTill = newOnlineTill;
|
||||||
update.flags |= UpdateFlag::UserOnlineChanged;
|
flags |= UpdateFlag::OnlineStatus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (App::main()) {
|
if (flags) {
|
||||||
if (update.flags) {
|
session().changes().peerUpdated(result, flags);
|
||||||
update.peer = result;
|
|
||||||
Notify::peerUpdatedDelayed(update);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -537,9 +534,8 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
|
||||||
});
|
});
|
||||||
auto minimal = false;
|
auto minimal = false;
|
||||||
|
|
||||||
Notify::PeerUpdate update;
|
using UpdateFlag = Data::PeerUpdate::Flag;
|
||||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
auto flags = UpdateFlag::None | UpdateFlag::None;
|
||||||
|
|
||||||
data.match([&](const MTPDchat &data) {
|
data.match([&](const MTPDchat &data) {
|
||||||
const auto chat = result->asChat();
|
const auto chat = result->asChat();
|
||||||
|
|
||||||
|
@ -585,7 +581,7 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
|
||||||
chat->count = data.vparticipants_count().v;
|
chat->count = data.vparticipants_count().v;
|
||||||
|
|
||||||
if (canAddMembers != chat->canAddMembers()) {
|
if (canAddMembers != chat->canAddMembers()) {
|
||||||
update.flags |= UpdateFlag::RightsChanged;
|
flags |= UpdateFlag::Rights;
|
||||||
}
|
}
|
||||||
}, [&](const MTPDchatForbidden &data) {
|
}, [&](const MTPDchatForbidden &data) {
|
||||||
const auto chat = result->asChat();
|
const auto chat = result->asChat();
|
||||||
|
@ -604,7 +600,7 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
|
||||||
MTP_chatBannedRights(MTP_flags(0), MTP_int(0)));
|
MTP_chatBannedRights(MTP_flags(0), MTP_int(0)));
|
||||||
|
|
||||||
if (canAddMembers != chat->canAddMembers()) {
|
if (canAddMembers != chat->canAddMembers()) {
|
||||||
update.flags |= UpdateFlag::RightsChanged;
|
flags |= UpdateFlag::Rights;
|
||||||
}
|
}
|
||||||
}, [&](const MTPDchannel &data) {
|
}, [&](const MTPDchannel &data) {
|
||||||
const auto channel = result->asChannel();
|
const auto channel = result->asChannel();
|
||||||
|
@ -676,12 +672,12 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
|
||||||
channel->setPhoto(data.vphoto());
|
channel->setPhoto(data.vphoto());
|
||||||
|
|
||||||
if (wasInChannel != channel->amIn()) {
|
if (wasInChannel != channel->amIn()) {
|
||||||
update.flags |= UpdateFlag::ChannelAmIn;
|
flags |= UpdateFlag::ChannelAmIn;
|
||||||
}
|
}
|
||||||
if (canViewAdmins != channel->canViewAdmins()
|
if (canViewAdmins != channel->canViewAdmins()
|
||||||
|| canViewMembers != channel->canViewMembers()
|
|| canViewMembers != channel->canViewMembers()
|
||||||
|| canAddMembers != channel->canAddMembers()) {
|
|| canAddMembers != channel->canAddMembers()) {
|
||||||
update.flags |= UpdateFlag::RightsChanged;
|
flags |= UpdateFlag::Rights;
|
||||||
}
|
}
|
||||||
}, [&](const MTPDchannelForbidden &data) {
|
}, [&](const MTPDchannelForbidden &data) {
|
||||||
const auto channel = result->asChannel();
|
const auto channel = result->asChannel();
|
||||||
|
@ -709,12 +705,12 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
|
||||||
channel->setMembersCount(0);
|
channel->setMembersCount(0);
|
||||||
|
|
||||||
if (wasInChannel != channel->amIn()) {
|
if (wasInChannel != channel->amIn()) {
|
||||||
update.flags |= UpdateFlag::ChannelAmIn;
|
flags |= UpdateFlag::ChannelAmIn;
|
||||||
}
|
}
|
||||||
if (canViewAdmins != channel->canViewAdmins()
|
if (canViewAdmins != channel->canViewAdmins()
|
||||||
|| canViewMembers != channel->canViewMembers()
|
|| canViewMembers != channel->canViewMembers()
|
||||||
|| canAddMembers != channel->canAddMembers()) {
|
|| canAddMembers != channel->canAddMembers()) {
|
||||||
update.flags |= UpdateFlag::RightsChanged;
|
flags |= UpdateFlag::Rights;
|
||||||
}
|
}
|
||||||
}, [](const MTPDchatEmpty &) {
|
}, [](const MTPDchatEmpty &) {
|
||||||
});
|
});
|
||||||
|
@ -726,9 +722,8 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
|
||||||
} else if (result->loadedStatus != PeerData::FullLoaded) {
|
} else if (result->loadedStatus != PeerData::FullLoaded) {
|
||||||
result->loadedStatus = PeerData::FullLoaded;
|
result->loadedStatus = PeerData::FullLoaded;
|
||||||
}
|
}
|
||||||
if (update.flags) {
|
if (flags) {
|
||||||
update.peer = result;
|
session().changes().peerUpdated(result, flags);
|
||||||
Notify::peerUpdatedDelayed(update);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -841,6 +836,22 @@ void Session::deleteConversationLocally(not_null<PeerData*> peer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void Session::newMessageSent(not_null<History*> history) {
|
||||||
|
_newMessageSent.fire_copy(history);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<not_null<History*>> Session::newMessageSent() const {
|
||||||
|
return _newMessageSent.events();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Session::cancelForwarding(not_null<History*> history) {
|
||||||
|
history->setForwardDraft({});
|
||||||
|
_forwardDraftUpdated.fire_copy(history);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<not_null<History*>> Session::forwardDraftUpdates() const {
|
||||||
|
return _forwardDraftUpdated.events();
|
||||||
|
}
|
||||||
|
|
||||||
void Session::registerSendAction(
|
void Session::registerSendAction(
|
||||||
not_null<History*> history,
|
not_null<History*> history,
|
||||||
|
@ -1034,25 +1045,27 @@ void Session::forgetPassportCredentials() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::setupContactViewsViewer() {
|
void Session::setupContactViewsViewer() {
|
||||||
Notify::PeerUpdateViewer(
|
session().changes().peerUpdates(
|
||||||
Notify::PeerUpdate::Flag::UserIsContact
|
PeerUpdate::Flag::IsContact
|
||||||
) | rpl::map([](const Notify::PeerUpdate &update) {
|
) | rpl::map([](const PeerUpdate &update) {
|
||||||
return update.peer->asUser();
|
return update.peer->asUser();
|
||||||
}) | rpl::filter([](UserData *user) {
|
|
||||||
return user != nullptr;
|
|
||||||
}) | rpl::start_with_next([=](not_null<UserData*> user) {
|
}) | rpl::start_with_next([=](not_null<UserData*> user) {
|
||||||
userIsContactUpdated(user);
|
const auto i = _contactViews.find(peerToUser(user->id));
|
||||||
|
if (i != _contactViews.end()) {
|
||||||
|
for (const auto view : i->second) {
|
||||||
|
requestViewResize(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::setupChannelLeavingViewer() {
|
void Session::setupChannelLeavingViewer() {
|
||||||
Notify::PeerUpdateViewer(
|
session().changes().peerUpdates(
|
||||||
Notify::PeerUpdate::Flag::ChannelAmIn
|
PeerUpdate::Flag::ChannelAmIn
|
||||||
) | rpl::map([](const Notify::PeerUpdate &update) {
|
) | rpl::map([](const PeerUpdate &update) {
|
||||||
return update.peer->asChannel();
|
return update.peer->asChannel();
|
||||||
}) | rpl::filter([](ChannelData *channel) {
|
}) | rpl::filter([](not_null<ChannelData*> channel) {
|
||||||
return (channel != nullptr)
|
return !(channel->amIn());
|
||||||
&& !(channel->amIn());
|
|
||||||
}) | rpl::start_with_next([=](not_null<ChannelData*> channel) {
|
}) | rpl::start_with_next([=](not_null<ChannelData*> channel) {
|
||||||
// channel->clearFeed(); // #feed
|
// channel->clearFeed(); // #feed
|
||||||
if (const auto history = historyLoaded(channel->id)) {
|
if (const auto history = historyLoaded(channel->id)) {
|
||||||
|
@ -1064,23 +1077,21 @@ void Session::setupChannelLeavingViewer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::setupPeerNameViewer() {
|
void Session::setupPeerNameViewer() {
|
||||||
Notify::PeerUpdateViewer(
|
session().changes().realtimeNameUpdates(
|
||||||
Notify::PeerUpdate::Flag::NameChanged
|
) | rpl::start_with_next([=](const NameUpdate &update) {
|
||||||
) | rpl::start_with_next([=](const Notify::PeerUpdate &update) {
|
|
||||||
const auto peer = update.peer;
|
const auto peer = update.peer;
|
||||||
const auto &oldLetters = update.oldNameFirstLetters;
|
const auto &oldLetters = update.oldFirstLetters;
|
||||||
_contactsNoChatsList.peerNameChanged(peer, oldLetters);
|
_contactsNoChatsList.peerNameChanged(peer, oldLetters);
|
||||||
_contactsList.peerNameChanged(peer, oldLetters);
|
_contactsList.peerNameChanged(peer, oldLetters);
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::setupUserIsContactViewer() {
|
void Session::setupUserIsContactViewer() {
|
||||||
Notify::PeerUpdateViewer(
|
session().changes().peerUpdates(
|
||||||
Notify::PeerUpdate::Flag::UserIsContact
|
PeerUpdate::Flag::IsContact
|
||||||
) | rpl::filter([=](const Notify::PeerUpdate &update) {
|
) | rpl::start_with_next([=](const PeerUpdate &update) {
|
||||||
return update.peer->isUser();
|
|
||||||
}) | rpl::start_with_next([=](const Notify::PeerUpdate &update) {
|
|
||||||
const auto user = update.peer->asUser();
|
const auto user = update.peer->asUser();
|
||||||
|
Assert(user != nullptr);
|
||||||
if (user->loadedStatus != PeerData::FullLoaded) {
|
if (user->loadedStatus != PeerData::FullLoaded) {
|
||||||
LOG(("API Error: "
|
LOG(("API Error: "
|
||||||
"userIsContactChanged() called for a not loaded user!"));
|
"userIsContactChanged() called for a not loaded user!"));
|
||||||
|
@ -1505,15 +1516,6 @@ rpl::producer<not_null<UserData*>> Session::megagroupParticipantAdded(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::userIsContactUpdated(not_null<UserData*> user) {
|
|
||||||
const auto i = _contactViews.find(peerToUser(user->id));
|
|
||||||
if (i != _contactViews.end()) {
|
|
||||||
for (const auto view : i->second) {
|
|
||||||
requestViewResize(view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HistoryItemsList Session::idsToItems(
|
HistoryItemsList Session::idsToItems(
|
||||||
const MessageIdsList &ids) const {
|
const MessageIdsList &ids) const {
|
||||||
return ranges::view::all(
|
return ranges::view::all(
|
||||||
|
@ -1972,9 +1974,9 @@ void Session::updateNotifySettingsLocal(not_null<PeerData*> peer) {
|
||||||
if (history && history->changeMute(muted)) {
|
if (history && history->changeMute(muted)) {
|
||||||
// Notification already sent.
|
// Notification already sent.
|
||||||
} else {
|
} else {
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(
|
||||||
peer,
|
peer,
|
||||||
Notify::PeerUpdate::Flag::NotificationsEnabled);
|
PeerUpdate::Flag::Notifications);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (muted) {
|
if (muted) {
|
||||||
|
@ -3157,9 +3159,9 @@ void Session::registerContactItem(
|
||||||
_contactItems[contactId].insert(item);
|
_contactItems[contactId].insert(item);
|
||||||
|
|
||||||
if (contact && canShare != contact->canShareThisContact()) {
|
if (contact && canShare != contact->canShareThisContact()) {
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(
|
||||||
contact,
|
contact,
|
||||||
Notify::PeerUpdate::Flag::UserCanShareContact);
|
PeerUpdate::Flag::CanShareContact);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto i = _views.find(item); i != _views.end()) {
|
if (const auto i = _views.find(item); i != _views.end()) {
|
||||||
|
@ -3189,9 +3191,9 @@ void Session::unregisterContactItem(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contact && canShare != contact->canShareThisContact()) {
|
if (contact && canShare != contact->canShareThisContact()) {
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(
|
||||||
contact,
|
contact,
|
||||||
Notify::PeerUpdate::Flag::UserCanShareContact);
|
PeerUpdate::Flag::CanShareContact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3739,36 +3741,33 @@ MessageIdsList Session::takeMimeForwardIds() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::setTopPromoted(
|
void Session::setTopPromoted(
|
||||||
PeerData *promoted,
|
History *promoted,
|
||||||
const QString &type,
|
const QString &type,
|
||||||
const QString &message) {
|
const QString &message) {
|
||||||
const auto changed = (_topPromoted != promoted);
|
const auto changed = (_topPromoted != promoted);
|
||||||
const auto history = promoted ? this->history(promoted).get() : nullptr;
|
if (!changed
|
||||||
if (changed
|
&& (!promoted || promoted->topPromotionMessage() == message)) {
|
||||||
|| (history && history->topPromotionMessage() != message)) {
|
return;
|
||||||
if (changed) {
|
}
|
||||||
if (const auto history = historyLoaded(_topPromoted)) {
|
if (changed) {
|
||||||
history->cacheTopPromotion(false, QString(), QString());
|
if (_topPromoted) {
|
||||||
}
|
_topPromoted->cacheTopPromotion(false, QString(), QString());
|
||||||
}
|
|
||||||
const auto old = std::exchange(_topPromoted, promoted);
|
|
||||||
if (history) {
|
|
||||||
history->cacheTopPromotion(true, type, message);
|
|
||||||
history->requestChatListMessage();
|
|
||||||
Notify::peerUpdatedDelayed(
|
|
||||||
_topPromoted,
|
|
||||||
Notify::PeerUpdate::Flag::TopPromotedChanged);
|
|
||||||
}
|
|
||||||
if (changed && old) {
|
|
||||||
Notify::peerUpdatedDelayed(
|
|
||||||
old,
|
|
||||||
Notify::PeerUpdate::Flag::TopPromotedChanged);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
const auto old = std::exchange(_topPromoted, promoted);
|
||||||
|
if (_topPromoted) {
|
||||||
PeerData *Session::topPromoted() const {
|
histories().requestDialogEntry(_topPromoted);
|
||||||
return _topPromoted;
|
_topPromoted->cacheTopPromotion(true, type, message);
|
||||||
|
_topPromoted->requestChatListMessage();
|
||||||
|
session().changes().historyUpdated(
|
||||||
|
_topPromoted,
|
||||||
|
HistoryUpdate::Flag::TopPromoted);
|
||||||
|
}
|
||||||
|
if (changed && old) {
|
||||||
|
session().changes().historyUpdated(
|
||||||
|
old,
|
||||||
|
HistoryUpdate::Flag::TopPromoted);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Session::updateWallpapers(const MTPaccount_WallPapers &data) {
|
bool Session::updateWallpapers(const MTPaccount_WallPapers &data) {
|
||||||
|
|
|
@ -180,6 +180,11 @@ public:
|
||||||
|
|
||||||
void deleteConversationLocally(not_null<PeerData*> peer);
|
void deleteConversationLocally(not_null<PeerData*> peer);
|
||||||
|
|
||||||
|
void newMessageSent(not_null<History*> history);
|
||||||
|
[[nodiscard]] rpl::producer<not_null<History*>> newMessageSent() const;
|
||||||
|
void cancelForwarding(not_null<History*> history);
|
||||||
|
[[nodiscard]] rpl::producer<not_null<History*>> forwardDraftUpdates() const;
|
||||||
|
|
||||||
void registerSendAction(
|
void registerSendAction(
|
||||||
not_null<History*> history,
|
not_null<History*> history,
|
||||||
not_null<UserData*> user,
|
not_null<UserData*> user,
|
||||||
|
@ -624,10 +629,9 @@ public:
|
||||||
MessageIdsList takeMimeForwardIds();
|
MessageIdsList takeMimeForwardIds();
|
||||||
|
|
||||||
void setTopPromoted(
|
void setTopPromoted(
|
||||||
PeerData *promoted,
|
History *promoted,
|
||||||
const QString &type,
|
const QString &type,
|
||||||
const QString &message);
|
const QString &message);
|
||||||
PeerData *topPromoted() const;
|
|
||||||
|
|
||||||
bool updateWallpapers(const MTPaccount_WallPapers &data);
|
bool updateWallpapers(const MTPaccount_WallPapers &data);
|
||||||
void removeWallpaper(const WallPaper &paper);
|
void removeWallpaper(const WallPaper &paper);
|
||||||
|
@ -742,8 +746,6 @@ private:
|
||||||
not_null<Folder*> folder,
|
not_null<Folder*> folder,
|
||||||
const MTPDfolder &data);
|
const MTPDfolder &data);
|
||||||
|
|
||||||
void userIsContactUpdated(not_null<UserData*> user);
|
|
||||||
|
|
||||||
void setPinnedFromDialog(const Dialogs::Key &key, bool pinned);
|
void setPinnedFromDialog(const Dialogs::Key &key, bool pinned);
|
||||||
|
|
||||||
NotifySettings &defaultNotifySettings(not_null<const PeerData*> peer);
|
NotifySettings &defaultNotifySettings(not_null<const PeerData*> peer);
|
||||||
|
@ -878,6 +880,8 @@ private:
|
||||||
rpl::event_stream<not_null<WebPageData*>> _webpageUpdates;
|
rpl::event_stream<not_null<WebPageData*>> _webpageUpdates;
|
||||||
rpl::event_stream<not_null<ChannelData*>> _channelDifferenceTooLong;
|
rpl::event_stream<not_null<ChannelData*>> _channelDifferenceTooLong;
|
||||||
rpl::event_stream<not_null<History*>> _historyOutboxReads;
|
rpl::event_stream<not_null<History*>> _historyOutboxReads;
|
||||||
|
rpl::event_stream<not_null<History*>> _newMessageSent;
|
||||||
|
rpl::event_stream<not_null<History*>> _forwardDraftUpdated;
|
||||||
|
|
||||||
base::flat_multi_map<TimeId, not_null<PollData*>> _pollsClosings;
|
base::flat_multi_map<TimeId, not_null<PollData*>> _pollsClosings;
|
||||||
base::Timer _pollsClosingTimer;
|
base::Timer _pollsClosingTimer;
|
||||||
|
@ -893,7 +897,7 @@ private:
|
||||||
|
|
||||||
base::flat_set<not_null<ViewElement*>> _heavyViewParts;
|
base::flat_set<not_null<ViewElement*>> _heavyViewParts;
|
||||||
|
|
||||||
PeerData *_topPromoted = nullptr;
|
History *_topPromoted = nullptr;
|
||||||
|
|
||||||
NotifySettings _defaultUserNotifySettings;
|
NotifySettings _defaultUserNotifySettings;
|
||||||
NotifySettings _defaultChatNotifySettings;
|
NotifySettings _defaultChatNotifySettings;
|
||||||
|
|
|
@ -7,9 +7,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "ui/text_options.h"
|
#include "ui/text_options.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
@ -20,7 +20,7 @@ namespace {
|
||||||
// User with hidden last seen stays online in UI for such amount of seconds.
|
// User with hidden last seen stays online in UI for such amount of seconds.
|
||||||
constexpr auto kSetOnlineAfterActivity = TimeId(30);
|
constexpr auto kSetOnlineAfterActivity = TimeId(30);
|
||||||
|
|
||||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
using UpdateFlag = Data::PeerUpdate::Flag;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -65,9 +65,7 @@ void UserData::setIsContact(bool is) {
|
||||||
: ContactStatus::NotContact;
|
: ContactStatus::NotContact;
|
||||||
if (_contactStatus != status) {
|
if (_contactStatus != status) {
|
||||||
_contactStatus = status;
|
_contactStatus = status;
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(this, UpdateFlag::IsContact);
|
||||||
this,
|
|
||||||
Notify::PeerUpdate::Flag::UserIsContact);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,16 +90,16 @@ void UserData::setUnavailableReasons(
|
||||||
std::vector<Data::UnavailableReason> &&reasons) {
|
std::vector<Data::UnavailableReason> &&reasons) {
|
||||||
if (_unavailableReasons != reasons) {
|
if (_unavailableReasons != reasons) {
|
||||||
_unavailableReasons = std::move(reasons);
|
_unavailableReasons = std::move(reasons);
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(
|
||||||
this,
|
this,
|
||||||
Notify::PeerUpdate::Flag::UnavailableReasonChanged);
|
UpdateFlag::UnavailableReason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserData::setCommonChatsCount(int count) {
|
void UserData::setCommonChatsCount(int count) {
|
||||||
if (_commonChatsCount != count) {
|
if (_commonChatsCount != count) {
|
||||||
_commonChatsCount = count;
|
_commonChatsCount = count;
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::UserCommonChatsChanged);
|
session().changes().peerUpdated(this, UpdateFlag::CommonChats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,10 +211,10 @@ void UserData::madeAction(TimeId when) {
|
||||||
return;
|
return;
|
||||||
} else if (onlineTill <= 0 && -onlineTill < when) {
|
} else if (onlineTill <= 0 && -onlineTill < when) {
|
||||||
onlineTill = -when - kSetOnlineAfterActivity;
|
onlineTill = -when - kSetOnlineAfterActivity;
|
||||||
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::UserOnlineChanged);
|
session().changes().peerUpdated(this, UpdateFlag::OnlineStatus);
|
||||||
} else if (onlineTill > 0 && onlineTill < when + 1) {
|
} else if (onlineTill > 0 && onlineTill < when + 1) {
|
||||||
onlineTill = when + kSetOnlineAfterActivity;
|
onlineTill = when + kSetOnlineAfterActivity;
|
||||||
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::UserOnlineChanged);
|
session().changes().peerUpdated(this, UpdateFlag::OnlineStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,14 +239,14 @@ void UserData::setIsBlocked(bool is) {
|
||||||
} else {
|
} else {
|
||||||
_fullFlags.remove(MTPDuserFull::Flag::f_blocked);
|
_fullFlags.remove(MTPDuserFull::Flag::f_blocked);
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::UserIsBlocked);
|
session().changes().peerUpdated(this, UpdateFlag::IsBlocked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserData::setCallsStatus(CallsStatus callsStatus) {
|
void UserData::setCallsStatus(CallsStatus callsStatus) {
|
||||||
if (callsStatus != _callsStatus) {
|
if (callsStatus != _callsStatus) {
|
||||||
_callsStatus = callsStatus;
|
_callsStatus = callsStatus;
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::UserHasCalls);
|
session().changes().peerUpdated(this, UpdateFlag::HasCalls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,119 @@ rpl::producer<> Stickers::savedGifsUpdated() const {
|
||||||
return _savedGifsUpdated.events();
|
return _savedGifsUpdated.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Stickers::incrementSticker(not_null<DocumentData*> document) {
|
||||||
|
if (!document->sticker()
|
||||||
|
|| document->sticker()->set.type() == mtpc_inputStickerSetEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool writeRecentStickers = false;
|
||||||
|
auto &sets = setsRef();
|
||||||
|
auto it = sets.find(Data::Stickers::CloudRecentSetId);
|
||||||
|
if (it == sets.cend()) {
|
||||||
|
if (it == sets.cend()) {
|
||||||
|
it = sets.emplace(
|
||||||
|
Data::Stickers::CloudRecentSetId,
|
||||||
|
std::make_unique<Data::StickersSet>(
|
||||||
|
&session().data(),
|
||||||
|
Data::Stickers::CloudRecentSetId,
|
||||||
|
uint64(0),
|
||||||
|
tr::lng_recent_stickers(tr::now),
|
||||||
|
QString(),
|
||||||
|
0, // count
|
||||||
|
0, // hash
|
||||||
|
MTPDstickerSet_ClientFlag::f_special | 0,
|
||||||
|
TimeId(0))).first;
|
||||||
|
} else {
|
||||||
|
it->second->title = tr::lng_recent_stickers(tr::now);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const auto set = it->second.get();
|
||||||
|
auto removedFromEmoji = std::vector<not_null<EmojiPtr>>();
|
||||||
|
auto index = set->stickers.indexOf(document);
|
||||||
|
if (index > 0) {
|
||||||
|
if (set->dates.empty()) {
|
||||||
|
session().api().requestRecentStickersForce();
|
||||||
|
} else {
|
||||||
|
Assert(set->dates.size() == set->stickers.size());
|
||||||
|
set->dates.erase(set->dates.begin() + index);
|
||||||
|
}
|
||||||
|
set->stickers.removeAt(index);
|
||||||
|
for (auto i = set->emoji.begin(); i != set->emoji.end();) {
|
||||||
|
if (const auto index = i->indexOf(document); index >= 0) {
|
||||||
|
removedFromEmoji.emplace_back(i.key());
|
||||||
|
i->removeAt(index);
|
||||||
|
if (i->isEmpty()) {
|
||||||
|
i = set->emoji.erase(i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (index) {
|
||||||
|
if (set->dates.size() == set->stickers.size()) {
|
||||||
|
set->dates.insert(set->dates.begin(), base::unixtime::now());
|
||||||
|
}
|
||||||
|
set->stickers.push_front(document);
|
||||||
|
if (const auto emojiList = getEmojiListFromSet(document)) {
|
||||||
|
for (const auto emoji : *emojiList) {
|
||||||
|
set->emoji[emoji].push_front(document);
|
||||||
|
}
|
||||||
|
} else if (!removedFromEmoji.empty()) {
|
||||||
|
for (const auto emoji : removedFromEmoji) {
|
||||||
|
set->emoji[emoji].push_front(document);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
session().api().requestRecentStickersForce();
|
||||||
|
}
|
||||||
|
|
||||||
|
writeRecentStickers = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove that sticker from old recent, now it is in cloud recent stickers.
|
||||||
|
bool writeOldRecent = false;
|
||||||
|
auto &recent = getRecentPack();
|
||||||
|
for (auto i = recent.begin(), e = recent.end(); i != e; ++i) {
|
||||||
|
if (i->first == document) {
|
||||||
|
writeOldRecent = true;
|
||||||
|
recent.erase(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (!recent.isEmpty() && set->stickers.size() + recent.size() > Global::StickersRecentLimit()) {
|
||||||
|
writeOldRecent = true;
|
||||||
|
recent.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeOldRecent) {
|
||||||
|
session().local().writeSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove that sticker from custom stickers, now it is in cloud recent stickers.
|
||||||
|
bool writeInstalledStickers = false;
|
||||||
|
auto customIt = sets.find(Data::Stickers::CustomSetId);
|
||||||
|
if (customIt != sets.cend()) {
|
||||||
|
const auto custom = customIt->second.get();
|
||||||
|
int removeIndex = custom->stickers.indexOf(document);
|
||||||
|
if (removeIndex >= 0) {
|
||||||
|
custom->stickers.removeAt(removeIndex);
|
||||||
|
if (custom->stickers.isEmpty()) {
|
||||||
|
sets.erase(customIt);
|
||||||
|
}
|
||||||
|
writeInstalledStickers = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeInstalledStickers) {
|
||||||
|
session().local().writeInstalledStickers();
|
||||||
|
}
|
||||||
|
if (writeRecentStickers) {
|
||||||
|
session().local().writeRecentStickers();
|
||||||
|
}
|
||||||
|
notifyRecentUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
void Stickers::addSavedGif(not_null<DocumentData*> document) {
|
void Stickers::addSavedGif(not_null<DocumentData*> document) {
|
||||||
const auto index = _savedGifs.indexOf(document);
|
const auto index = _savedGifs.indexOf(document);
|
||||||
if (!index) {
|
if (!index) {
|
||||||
|
|
|
@ -55,6 +55,8 @@ public:
|
||||||
void notifySavedGifsUpdated();
|
void notifySavedGifsUpdated();
|
||||||
[[nodiscard]] rpl::producer<> savedGifsUpdated() const;
|
[[nodiscard]] rpl::producer<> savedGifsUpdated() const;
|
||||||
|
|
||||||
|
void incrementSticker(not_null<DocumentData*> document);
|
||||||
|
|
||||||
bool updateNeeded(crl::time now) const {
|
bool updateNeeded(crl::time now) const {
|
||||||
return updateNeeded(_lastUpdate, now);
|
return updateNeeded(_lastUpdate, now);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_histories.h"
|
#include "data/data_histories.h"
|
||||||
#include "data/data_chat_filters.h"
|
#include "data/data_chat_filters.h"
|
||||||
#include "data/data_cloud_file.h"
|
#include "data/data_cloud_file.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/stickers/data_stickers.h"
|
#include "data/stickers/data_stickers.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
@ -38,7 +39,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "storage/storage_account.h"
|
#include "storage/storage_account.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "window/notifications_manager.h"
|
#include "window/notifications_manager.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
@ -223,36 +223,40 @@ InnerWidget::InnerWidget(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
session().changes().historyUpdates(
|
||||||
auto changes = UpdateFlag::ChatPinnedChanged
|
Data::HistoryUpdate::Flag::IsPinned
|
||||||
| UpdateFlag::NameChanged
|
| Data::HistoryUpdate::Flag::ChatOccupied
|
||||||
| UpdateFlag::PhotoChanged
|
) | rpl::start_with_next([=](const Data::HistoryUpdate &update) {
|
||||||
| UpdateFlag::UserIsContact
|
if (update.flags & Data::HistoryUpdate::Flag::IsPinned) {
|
||||||
| UpdateFlag::UserOccupiedChanged
|
|
||||||
| UpdateFlag::MigrationChanged;
|
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(changes, [=](const Notify::PeerUpdate &update) {
|
|
||||||
if (update.flags & UpdateFlag::ChatPinnedChanged) {
|
|
||||||
stopReorderPinned();
|
stopReorderPinned();
|
||||||
}
|
}
|
||||||
if (update.flags & UpdateFlag::NameChanged) {
|
if (update.flags & Data::HistoryUpdate::Flag::ChatOccupied) {
|
||||||
this->update();
|
this->update();
|
||||||
|
_updated.fire({});
|
||||||
}
|
}
|
||||||
if (update.flags & (UpdateFlag::PhotoChanged | UpdateFlag::UserOccupiedChanged)) {
|
}, lifetime());
|
||||||
|
|
||||||
|
using UpdateFlag = Data::PeerUpdate::Flag;
|
||||||
|
session().changes().peerUpdates(
|
||||||
|
UpdateFlag::Name
|
||||||
|
| UpdateFlag::Photo
|
||||||
|
| UpdateFlag::IsContact
|
||||||
|
| UpdateFlag::Migration
|
||||||
|
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
|
||||||
|
if (update.flags & (UpdateFlag::Name | UpdateFlag::Photo)) {
|
||||||
this->update();
|
this->update();
|
||||||
emit controller->content()->dialogsUpdated();
|
_updated.fire({});
|
||||||
}
|
}
|
||||||
if (update.flags & UpdateFlag::UserIsContact) {
|
if (update.flags & UpdateFlag::IsContact) {
|
||||||
if (update.peer->isUser()) {
|
// contactsNoChatsList could've changed.
|
||||||
// contactsNoChatsList could've changed.
|
Ui::PostponeCall(this, [=] { refresh(); });
|
||||||
Ui::PostponeCall(this, [=] { refresh(); });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (update.flags & UpdateFlag::MigrationChanged) {
|
if (update.flags & UpdateFlag::Migration) {
|
||||||
if (const auto chat = update.peer->asChat()) {
|
if (const auto chat = update.peer->asChat()) {
|
||||||
handleChatMigration(chat);
|
handleChatMigration(chat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}, lifetime());
|
||||||
|
|
||||||
_controller->activeChatEntryValue(
|
_controller->activeChatEntryValue(
|
||||||
) | rpl::combine_previous(
|
) | rpl::combine_previous(
|
||||||
|
@ -1498,7 +1502,7 @@ void InnerWidget::removeDialog(Key key) {
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
emit _controller->content()->dialogsUpdated();
|
_updated.fire({});
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
@ -1963,6 +1967,10 @@ auto InnerWidget::chosenRow() const -> rpl::producer<ChosenRow> {
|
||||||
return _chosenRow.events();
|
return _chosenRow.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpl::producer<> InnerWidget::updated() const {
|
||||||
|
return _updated.events();
|
||||||
|
}
|
||||||
|
|
||||||
rpl::producer<> InnerWidget::listBottomReached() const {
|
rpl::producer<> InnerWidget::listBottomReached() const {
|
||||||
return _listBottomReached.events();
|
return _listBottomReached.events();
|
||||||
}
|
}
|
||||||
|
@ -2948,16 +2956,15 @@ MsgId InnerWidget::lastSearchMigratedId() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::setupOnlineStatusCheck() {
|
void InnerWidget::setupOnlineStatusCheck() {
|
||||||
using namespace Notify;
|
session().changes().peerUpdates(
|
||||||
subscribe(PeerUpdated(), PeerUpdatedHandler(
|
Data::PeerUpdate::Flag::OnlineStatus
|
||||||
PeerUpdate::Flag::UserOnlineChanged,
|
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
|
||||||
[=](const PeerUpdate &update) { userOnlineUpdated(update); }));
|
userOnlineUpdated(update.peer);
|
||||||
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::userOnlineUpdated(const Notify::PeerUpdate &update) {
|
void InnerWidget::userOnlineUpdated(not_null<PeerData*> peer) {
|
||||||
const auto user = update.peer->isSelf()
|
const auto user = peer->isSelf() ? nullptr : peer->asUser();
|
||||||
? nullptr
|
|
||||||
: update.peer->asUser();
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,6 @@ namespace Window {
|
||||||
class SessionController;
|
class SessionController;
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
||||||
namespace Notify {
|
|
||||||
struct PeerUpdate;
|
|
||||||
} // namespace Notify
|
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
class CloudImageView;
|
class CloudImageView;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
@ -131,7 +127,8 @@ public:
|
||||||
|
|
||||||
base::Observable<UserData*> searchFromUserChanged;
|
base::Observable<UserData*> searchFromUserChanged;
|
||||||
|
|
||||||
rpl::producer<ChosenRow> chosenRow() const;
|
[[nodiscard]] rpl::producer<ChosenRow> chosenRow() const;
|
||||||
|
[[nodiscard]] rpl::producer<> updated() const;
|
||||||
|
|
||||||
~InnerWidget();
|
~InnerWidget();
|
||||||
|
|
||||||
|
@ -228,7 +225,7 @@ private:
|
||||||
|
|
||||||
int defaultRowTop(not_null<Row*> row) const;
|
int defaultRowTop(not_null<Row*> row) const;
|
||||||
void setupOnlineStatusCheck();
|
void setupOnlineStatusCheck();
|
||||||
void userOnlineUpdated(const Notify::PeerUpdate &update);
|
void userOnlineUpdated(not_null<PeerData*> peer);
|
||||||
|
|
||||||
void setupShortcuts();
|
void setupShortcuts();
|
||||||
RowDescriptor computeJump(
|
RowDescriptor computeJump(
|
||||||
|
@ -406,6 +403,7 @@ private:
|
||||||
Fn<void()> _loadMoreCallback;
|
Fn<void()> _loadMoreCallback;
|
||||||
rpl::event_stream<> _listBottomReached;
|
rpl::event_stream<> _listBottomReached;
|
||||||
rpl::event_stream<ChosenRow> _chosenRow;
|
rpl::event_stream<ChosenRow> _chosenRow;
|
||||||
|
rpl::event_stream<> _updated;
|
||||||
|
|
||||||
base::unique_qptr<Ui::PopupMenu> _menu;
|
base::unique_qptr<Ui::PopupMenu> _menu;
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "dialogs/dialogs_main_list.h"
|
#include "dialogs/dialogs_main_list.h"
|
||||||
|
|
||||||
#include "observer_peer.h"
|
#include "data/data_changes.h"
|
||||||
|
#include "main/main_session.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
|
|
||||||
namespace Dialogs {
|
namespace Dialogs {
|
||||||
|
|
||||||
MainList::MainList(FilterId filterId, rpl::producer<int> pinnedLimit)
|
MainList::MainList(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
FilterId filterId,
|
||||||
|
rpl::producer<int> pinnedLimit)
|
||||||
: _filterId(filterId)
|
: _filterId(filterId)
|
||||||
, _all(SortMode::Date, filterId)
|
, _all(SortMode::Date, filterId)
|
||||||
, _pinned(filterId, 1) {
|
, _pinned(filterId, 1) {
|
||||||
|
@ -24,12 +28,9 @@ MainList::MainList(FilterId filterId, rpl::producer<int> pinnedLimit)
|
||||||
_pinned.setLimit(limit);
|
_pinned.setLimit(limit);
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
|
|
||||||
Notify::PeerUpdateViewer(
|
session->changes().realtimeNameUpdates(
|
||||||
Notify::PeerUpdate::Flag::NameChanged
|
) | rpl::start_with_next([=](const Data::NameUpdate &update) {
|
||||||
) | rpl::start_with_next([=](const Notify::PeerUpdate &update) {
|
_all.peerNameChanged(_filterId, update.peer, update.oldFirstLetters);
|
||||||
const auto peer = update.peer;
|
|
||||||
const auto &oldLetters = update.oldNameFirstLetters;
|
|
||||||
_all.peerNameChanged(_filterId, peer, oldLetters);
|
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "dialogs/dialogs_indexed_list.h"
|
#include "dialogs/dialogs_indexed_list.h"
|
||||||
#include "dialogs/dialogs_pinned_list.h"
|
#include "dialogs/dialogs_pinned_list.h"
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Session;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
namespace Dialogs {
|
namespace Dialogs {
|
||||||
|
|
||||||
class MainList final {
|
class MainList final {
|
||||||
public:
|
public:
|
||||||
MainList(FilterId filterId, rpl::producer<int> pinnedLimit);
|
MainList(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
FilterId filterId,
|
||||||
|
rpl::producer<int> pinnedLimit);
|
||||||
|
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
bool loaded() const;
|
bool loaded() const;
|
||||||
|
|
|
@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
|
|
||||||
|
|
|
@ -176,6 +176,11 @@ Widget::Widget(
|
||||||
, _singleMessageSearch(&controller->session()) {
|
, _singleMessageSearch(&controller->session()) {
|
||||||
_inner = _scroll->setOwnedWidget(object_ptr<InnerWidget>(this, controller));
|
_inner = _scroll->setOwnedWidget(object_ptr<InnerWidget>(this, controller));
|
||||||
|
|
||||||
|
_inner->updated(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
onListScroll();
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
session().api().dialogsLoadMayBlockByDate(),
|
session().api().dialogsLoadMayBlockByDate(),
|
||||||
session().api().dialogsLoadBlockedByDate()
|
session().api().dialogsLoadBlockedByDate()
|
||||||
|
@ -183,6 +188,11 @@ Widget::Widget(
|
||||||
refreshLoadMoreButton(mayBlock, isBlocked);
|
refreshLoadMoreButton(mayBlock, isBlocked);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
session().data().newMessageSent(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
jumpToTop();
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
fullSearchRefreshOn(session().settings().skipArchiveInSearchChanges(
|
fullSearchRefreshOn(session().settings().skipArchiveInSearchChanges(
|
||||||
) | rpl::map([] { return rpl::empty_value(); }));
|
) | rpl::map([] { return rpl::empty_value(); }));
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
|
@ -338,7 +337,6 @@ namespace internal {
|
||||||
|
|
||||||
struct Data {
|
struct Data {
|
||||||
SingleQueuedInvokation HandleUnreadCounterUpdate = { [] { Core::App().call_handleUnreadCounterUpdate(); } };
|
SingleQueuedInvokation HandleUnreadCounterUpdate = { [] { Core::App().call_handleUnreadCounterUpdate(); } };
|
||||||
SingleQueuedInvokation HandleDelayedPeerUpdates = { [] { Core::App().call_handleDelayedPeerUpdates(); } };
|
|
||||||
|
|
||||||
Adaptive::WindowLayout AdaptiveWindowLayout = Adaptive::WindowLayout::Normal;
|
Adaptive::WindowLayout AdaptiveWindowLayout = Adaptive::WindowLayout::Normal;
|
||||||
Adaptive::ChatLayout AdaptiveChatLayout = Adaptive::ChatLayout::Normal;
|
Adaptive::ChatLayout AdaptiveChatLayout = Adaptive::ChatLayout::Normal;
|
||||||
|
@ -458,7 +456,6 @@ void finish() {
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineRefVar(Global, SingleQueuedInvokation, HandleUnreadCounterUpdate);
|
DefineRefVar(Global, SingleQueuedInvokation, HandleUnreadCounterUpdate);
|
||||||
DefineRefVar(Global, SingleQueuedInvokation, HandleDelayedPeerUpdates);
|
|
||||||
|
|
||||||
DefineVar(Global, Adaptive::WindowLayout, AdaptiveWindowLayout);
|
DefineVar(Global, Adaptive::WindowLayout, AdaptiveWindowLayout);
|
||||||
DefineVar(Global, Adaptive::ChatLayout, AdaptiveChatLayout);
|
DefineVar(Global, Adaptive::ChatLayout, AdaptiveChatLayout);
|
||||||
|
|
|
@ -145,7 +145,6 @@ void start();
|
||||||
void finish();
|
void finish();
|
||||||
|
|
||||||
DeclareRefVar(SingleQueuedInvokation, HandleUnreadCounterUpdate);
|
DeclareRefVar(SingleQueuedInvokation, HandleUnreadCounterUpdate);
|
||||||
DeclareRefVar(SingleQueuedInvokation, HandleDelayedPeerUpdates);
|
|
||||||
|
|
||||||
DeclareVar(Adaptive::WindowLayout, AdaptiveWindowLayout);
|
DeclareVar(Adaptive::WindowLayout, AdaptiveWindowLayout);
|
||||||
DeclareVar(Adaptive::ChatLayout, AdaptiveChatLayout);
|
DeclareVar(Adaptive::ChatLayout, AdaptiveChatLayout);
|
||||||
|
|
|
@ -12,10 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/admin_log/history_admin_log_item.h"
|
#include "history/admin_log/history_admin_log_item.h"
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
|
|
||||||
namespace Notify {
|
|
||||||
struct PeerUpdate;
|
|
||||||
} // namespace Notify
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ScrollArea;
|
class ScrollArea;
|
||||||
class PlainShadow;
|
class PlainShadow;
|
||||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_media_types.h"
|
#include "data/data_media_types.h"
|
||||||
#include "data/data_channel_admins.h"
|
#include "data/data_channel_admins.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_chat_filters.h"
|
#include "data/data_chat_filters.h"
|
||||||
#include "data/data_scheduled_messages.h"
|
#include "data/data_scheduled_messages.h"
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
|
@ -30,7 +31,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "window/notifications_manager.h"
|
#include "window/notifications_manager.h"
|
||||||
#include "calls/calls_instance.h"
|
#include "calls/calls_instance.h"
|
||||||
|
@ -65,6 +65,8 @@ constexpr auto kSetMyActionForMs = 10000;
|
||||||
constexpr auto kNewBlockEachMessage = 50;
|
constexpr auto kNewBlockEachMessage = 50;
|
||||||
constexpr auto kSkipCloudDraftsFor = TimeId(3);
|
constexpr auto kSkipCloudDraftsFor = TimeId(3);
|
||||||
|
|
||||||
|
using UpdateFlag = Data::HistoryUpdate::Flag;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
History::History(not_null<Data::Session*> owner, PeerId peerId)
|
History::History(not_null<Data::Session*> owner, PeerId peerId)
|
||||||
|
@ -874,7 +876,7 @@ void History::eraseFromUnreadMentions(MsgId msgId) {
|
||||||
if (_unreadMentionsCount && *_unreadMentionsCount > 0) {
|
if (_unreadMentionsCount && *_unreadMentionsCount > 0) {
|
||||||
setUnreadMentionsCount(*_unreadMentionsCount - 1);
|
setUnreadMentionsCount(*_unreadMentionsCount - 1);
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(peer, Notify::PeerUpdate::Flag::UnreadMentionsChanged);
|
session().changes().historyUpdated(this, UpdateFlag::UnreadMentions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::addUnreadMentionsSlice(const MTPmessages_Messages &result) {
|
void History::addUnreadMentionsSlice(const MTPmessages_Messages &result) {
|
||||||
|
@ -929,7 +931,7 @@ void History::addUnreadMentionsSlice(const MTPmessages_Messages &result) {
|
||||||
count = _unreadMentions.size();
|
count = _unreadMentions.size();
|
||||||
}
|
}
|
||||||
setUnreadMentionsCount(count);
|
setUnreadMentionsCount(count);
|
||||||
Notify::peerUpdatedDelayed(peer, Notify::PeerUpdate::Flag::UnreadMentionsChanged);
|
session().changes().historyUpdated(this, UpdateFlag::UnreadMentions);
|
||||||
}
|
}
|
||||||
|
|
||||||
not_null<HistoryItem*> History::addNewToBack(
|
not_null<HistoryItem*> History::addNewToBack(
|
||||||
|
@ -987,7 +989,9 @@ not_null<HistoryItem*> History::addNewToBack(
|
||||||
lastAuthors->push_front(user);
|
lastAuthors->push_front(user);
|
||||||
}
|
}
|
||||||
if (auto megagroup = peer->asMegagroup()) {
|
if (auto megagroup = peer->asMegagroup()) {
|
||||||
Notify::peerUpdatedDelayed(peer, Notify::PeerUpdate::Flag::MembersChanged);
|
session().changes().peerUpdated(
|
||||||
|
peer,
|
||||||
|
Data::PeerUpdate::Flag::Members);
|
||||||
owner().addNewMegagroupParticipant(megagroup, user);
|
owner().addNewMegagroupParticipant(megagroup, user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1075,7 +1079,9 @@ void History::applyServiceChanges(
|
||||||
if (const auto user = owner().userLoaded(userId.v)) {
|
if (const auto user = owner().userLoaded(userId.v)) {
|
||||||
if (!base::contains(mgInfo->lastParticipants, user)) {
|
if (!base::contains(mgInfo->lastParticipants, user)) {
|
||||||
mgInfo->lastParticipants.push_front(user);
|
mgInfo->lastParticipants.push_front(user);
|
||||||
Notify::peerUpdatedDelayed(peer, Notify::PeerUpdate::Flag::MembersChanged);
|
session().changes().peerUpdated(
|
||||||
|
peer,
|
||||||
|
Data::PeerUpdate::Flag::Members);
|
||||||
owner().addNewMegagroupParticipant(megagroup, user);
|
owner().addNewMegagroupParticipant(megagroup, user);
|
||||||
}
|
}
|
||||||
if (user->isBot()) {
|
if (user->isBot()) {
|
||||||
|
@ -1097,7 +1103,9 @@ void History::applyServiceChanges(
|
||||||
if (auto user = item->from()->asUser()) {
|
if (auto user = item->from()->asUser()) {
|
||||||
if (!base::contains(mgInfo->lastParticipants, user)) {
|
if (!base::contains(mgInfo->lastParticipants, user)) {
|
||||||
mgInfo->lastParticipants.push_front(user);
|
mgInfo->lastParticipants.push_front(user);
|
||||||
Notify::peerUpdatedDelayed(peer, Notify::PeerUpdate::Flag::MembersChanged);
|
session().changes().peerUpdated(
|
||||||
|
peer,
|
||||||
|
Data::PeerUpdate::Flag::Members);
|
||||||
owner().addNewMegagroupParticipant(megagroup, user);
|
owner().addNewMegagroupParticipant(megagroup, user);
|
||||||
}
|
}
|
||||||
if (user->isBot()) {
|
if (user->isBot()) {
|
||||||
|
@ -1132,7 +1140,9 @@ void History::applyServiceChanges(
|
||||||
[](not_null<UserData*> user) { return user.get(); });
|
[](not_null<UserData*> user) { return user.get(); });
|
||||||
if (i != mgInfo->lastParticipants.end()) {
|
if (i != mgInfo->lastParticipants.end()) {
|
||||||
mgInfo->lastParticipants.erase(i);
|
mgInfo->lastParticipants.erase(i);
|
||||||
Notify::peerUpdatedDelayed(peer, Notify::PeerUpdate::Flag::MembersChanged);
|
session().changes().peerUpdated(
|
||||||
|
peer,
|
||||||
|
Data::PeerUpdate::Flag::Members);
|
||||||
}
|
}
|
||||||
owner().removeMegagroupParticipant(megagroup, user);
|
owner().removeMegagroupParticipant(megagroup, user);
|
||||||
if (megagroup->membersCount() > 1) {
|
if (megagroup->membersCount() > 1) {
|
||||||
|
@ -1146,7 +1156,9 @@ void History::applyServiceChanges(
|
||||||
if (megagroup->adminsCount() > 1) {
|
if (megagroup->adminsCount() > 1) {
|
||||||
megagroup->setAdminsCount(megagroup->adminsCount() - 1);
|
megagroup->setAdminsCount(megagroup->adminsCount() - 1);
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(peer, Notify::PeerUpdate::Flag::AdminsChanged);
|
session().changes().peerUpdated(
|
||||||
|
peer,
|
||||||
|
Data::PeerUpdate::Flag::Admins);
|
||||||
}
|
}
|
||||||
mgInfo->bots.remove(user);
|
mgInfo->bots.remove(user);
|
||||||
if (mgInfo->bots.empty() && mgInfo->botStatus > 0) {
|
if (mgInfo->bots.empty() && mgInfo->botStatus > 0) {
|
||||||
|
@ -1310,22 +1322,14 @@ void History::registerLocalMessage(not_null<HistoryItem*> item) {
|
||||||
Expects(IsClientMsgId(item->id));
|
Expects(IsClientMsgId(item->id));
|
||||||
|
|
||||||
_localMessages.emplace(item);
|
_localMessages.emplace(item);
|
||||||
if (peer->isChannel()) {
|
session().changes().historyUpdated(this, UpdateFlag::LocalMessages);
|
||||||
Notify::peerUpdatedDelayed(
|
|
||||||
peer,
|
|
||||||
Notify::PeerUpdate::Flag::ChannelLocalMessages);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::unregisterLocalMessage(not_null<HistoryItem*> item) {
|
void History::unregisterLocalMessage(not_null<HistoryItem*> item) {
|
||||||
const auto removed = _localMessages.remove(item);
|
const auto removed = _localMessages.remove(item);
|
||||||
Assert(removed);
|
Assert(removed);
|
||||||
|
|
||||||
if (peer->isChannel()) {
|
session().changes().historyUpdated(this, UpdateFlag::LocalMessages);
|
||||||
Notify::peerUpdatedDelayed(
|
|
||||||
peer,
|
|
||||||
Notify::PeerUpdate::Flag::ChannelLocalMessages);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem *History::latestSendingMessage() const {
|
HistoryItem *History::latestSendingMessage() const {
|
||||||
|
@ -1805,9 +1809,7 @@ void History::setUnreadCount(int newUnreadCount) {
|
||||||
if (wasForBadge != (unreadCountForBadge() > 0)) {
|
if (wasForBadge != (unreadCountForBadge() > 0)) {
|
||||||
owner().chatsFilters().refreshHistory(this);
|
owner().chatsFilters().refreshHistory(this);
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().historyUpdated(this, UpdateFlag::UnreadView);
|
||||||
peer,
|
|
||||||
Notify::PeerUpdate::Flag::UnreadViewChanged);
|
|
||||||
});
|
});
|
||||||
const auto notifier = unreadStateChangeNotifier(true);
|
const auto notifier = unreadStateChangeNotifier(true);
|
||||||
_unreadCount = newUnreadCount;
|
_unreadCount = newUnreadCount;
|
||||||
|
@ -1844,9 +1846,7 @@ void History::setUnreadMark(bool unread) {
|
||||||
owner().chatsFilters().refreshHistory(this);
|
owner().chatsFilters().refreshHistory(this);
|
||||||
updateChatListEntry();
|
updateChatListEntry();
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().historyUpdated(this, UpdateFlag::UnreadView);
|
||||||
peer,
|
|
||||||
Notify::PeerUpdate::Flag::UnreadViewChanged);
|
|
||||||
});
|
});
|
||||||
const auto notifier = unreadStateChangeNotifier(noUnreadMessages);
|
const auto notifier = unreadStateChangeNotifier(noUnreadMessages);
|
||||||
_unreadMark = unread;
|
_unreadMark = unread;
|
||||||
|
@ -1886,9 +1886,9 @@ bool History::changeMute(bool newMute) {
|
||||||
owner().chatsFilters().refreshHistory(this);
|
owner().chatsFilters().refreshHistory(this);
|
||||||
updateChatListEntry();
|
updateChatListEntry();
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().peerUpdated(
|
||||||
peer,
|
peer,
|
||||||
Notify::PeerUpdate::Flag::NotificationsEnabled);
|
Data::PeerUpdate::Flag::Notifications);
|
||||||
});
|
});
|
||||||
const auto notify = (unreadCountForBadge() > 0);
|
const auto notify = (unreadCountForBadge() > 0);
|
||||||
const auto notifier = unreadStateChangeNotifier(notify);
|
const auto notifier = unreadStateChangeNotifier(notify);
|
||||||
|
@ -1986,9 +1986,7 @@ void History::setFolderPointer(Data::Folder *folder) {
|
||||||
if (folder) {
|
if (folder) {
|
||||||
folder->registerOne(this);
|
folder->registerOne(this);
|
||||||
}
|
}
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().historyUpdated(this, UpdateFlag::Folder);
|
||||||
peer,
|
|
||||||
Notify::PeerUpdate::Flag::FolderChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::applyPinnedUpdate(const MTPDupdateDialogPinned &data) {
|
void History::applyPinnedUpdate(const MTPDupdateDialogPinned &data) {
|
||||||
|
@ -3294,9 +3292,7 @@ void History::applyGroupAdminChanges(const base::flat_set<UserId> &changes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::changedChatListPinHook() {
|
void History::changedChatListPinHook() {
|
||||||
Notify::peerUpdatedDelayed(
|
session().changes().historyUpdated(this, UpdateFlag::IsPinned);
|
||||||
peer,
|
|
||||||
Notify::PeerUpdate::Flag::ChatPinnedChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::removeBlock(not_null<HistoryBlock*> block) {
|
void History::removeBlock(not_null<HistoryBlock*> block) {
|
||||||
|
|
|
@ -34,6 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/crash_reports.h"
|
#include "core/crash_reports.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "data/data_scheduled_messages.h" // kScheduledUntilOnlineTimestamp
|
#include "data/data_scheduled_messages.h" // kScheduledUntilOnlineTimestamp
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_messages.h"
|
#include "data/data_messages.h"
|
||||||
#include "data/data_media_types.h"
|
#include "data/data_media_types.h"
|
||||||
|
@ -41,7 +42,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
#include "styles/style_dialogs.h"
|
#include "styles/style_dialogs.h"
|
||||||
#include "styles/style_history.h"
|
#include "styles/style_history.h"
|
||||||
|
@ -725,11 +725,9 @@ void HistoryItem::sendFailed() {
|
||||||
|
|
||||||
_clientFlags = (_clientFlags | MTPDmessage_ClientFlag::f_failed)
|
_clientFlags = (_clientFlags | MTPDmessage_ClientFlag::f_failed)
|
||||||
& ~MTPDmessage_ClientFlag::f_sending;
|
& ~MTPDmessage_ClientFlag::f_sending;
|
||||||
if (history()->peer->isChannel()) {
|
history()->session().changes().historyUpdated(
|
||||||
Notify::peerUpdatedDelayed(
|
history(),
|
||||||
history()->peer,
|
Data::HistoryUpdate::Flag::LocalMessages);
|
||||||
Notify::PeerUpdate::Flag::ChannelLocalMessages);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryItem::needCheck() const {
|
bool HistoryItem::needCheck() const {
|
||||||
|
|
|
@ -32,9 +32,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "window/notifications_manager.h"
|
#include "window/notifications_manager.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "storage/storage_shared_media.h"
|
#include "storage/storage_shared_media.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_game.h"
|
#include "data/data_game.h"
|
||||||
#include "data/data_media_types.h"
|
#include "data/data_media_types.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
|
@ -1152,9 +1152,9 @@ void HistoryMessage::contributeToSlowmode(TimeId realDate) {
|
||||||
void HistoryMessage::addToUnreadMentions(UnreadMentionType type) {
|
void HistoryMessage::addToUnreadMentions(UnreadMentionType type) {
|
||||||
if (IsServerMsgId(id) && isUnreadMention()) {
|
if (IsServerMsgId(id) && isUnreadMention()) {
|
||||||
if (history()->addToUnreadMentions(id, type)) {
|
if (history()->addToUnreadMentions(id, type)) {
|
||||||
Notify::peerUpdatedDelayed(
|
history()->session().changes().historyUpdated(
|
||||||
history()->peer,
|
history(),
|
||||||
Notify::PeerUpdate::Flag::UnreadMentionsChanged);
|
Data::HistoryUpdate::Flag::UnreadMentions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/event_filter.h"
|
#include "base/event_filter.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "base/call_delayed.h"
|
#include "base/call_delayed.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_drafts.h"
|
#include "data/data_drafts.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_web_page.h"
|
#include "data/data_web_page.h"
|
||||||
|
@ -78,7 +79,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "history/view/history_view_top_bar_widget.h"
|
#include "history/view/history_view_top_bar_widget.h"
|
||||||
#include "history/view/history_view_contact_status.h"
|
#include "history/view/history_view_contact_status.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "base/qthelp_regex.h"
|
#include "base/qthelp_regex.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/text_options.h"
|
#include "ui/text_options.h"
|
||||||
|
@ -162,9 +162,9 @@ object_ptr<Ui::FlatButton> SetupDiscussButton(
|
||||||
return history ? history->peer->asChannel() : nullptr;
|
return history ? history->peer->asChannel() : nullptr;
|
||||||
}) | rpl::map([=](ChannelData *channel) -> rpl::producer<ChannelData*> {
|
}) | rpl::map([=](ChannelData *channel) -> rpl::producer<ChannelData*> {
|
||||||
if (channel && channel->isBroadcast()) {
|
if (channel && channel->isBroadcast()) {
|
||||||
return PeerUpdateValue(
|
return channel->session().changes().peerFlagsValue(
|
||||||
channel,
|
channel,
|
||||||
Notify::PeerUpdate::Flag::ChannelLinkedChat
|
Data::PeerUpdate::Flag::ChannelLinkedChat
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return channel->linkedChat();
|
return channel->linkedChat();
|
||||||
});
|
});
|
||||||
|
@ -175,11 +175,19 @@ object_ptr<Ui::FlatButton> SetupDiscussButton(
|
||||||
) | rpl::map([=](ChannelData *chat)
|
) | rpl::map([=](ChannelData *chat)
|
||||||
-> rpl::producer<std::tuple<int, bool>> {
|
-> rpl::producer<std::tuple<int, bool>> {
|
||||||
if (chat) {
|
if (chat) {
|
||||||
return PeerUpdateValue(
|
using UpdateFlag = Data::PeerUpdate::Flag;
|
||||||
chat,
|
auto to_empty = rpl::map([=] { return rpl::empty_value(); });
|
||||||
Notify::PeerUpdate::Flag::UnreadViewChanged
|
return rpl::merge(
|
||||||
| Notify::PeerUpdate::Flag::NotificationsEnabled
|
chat->session().changes().historyUpdates(
|
||||||
| Notify::PeerUpdate::Flag::ChannelAmIn
|
Data::HistoryUpdate::Flag::UnreadView
|
||||||
|
) | rpl::filter([=](const Data::HistoryUpdate &update) {
|
||||||
|
return (update.history->peer == chat);
|
||||||
|
}) | to_empty,
|
||||||
|
|
||||||
|
chat->session().changes().peerFlagsValue(
|
||||||
|
chat,
|
||||||
|
UpdateFlag::Notifications | UpdateFlag::ChannelAmIn
|
||||||
|
) | to_empty
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
const auto history = chat->amIn()
|
const auto history = chat->amIn()
|
||||||
? chat->owner().historyLoaded(chat)
|
? chat->owner().historyLoaded(chat)
|
||||||
|
@ -546,83 +554,111 @@ HistoryWidget::HistoryWidget(
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
session().data().forwardDraftUpdates(
|
||||||
|
) | rpl::filter([=](not_null<History*> history) {
|
||||||
|
return (_history == history.get());
|
||||||
|
}) | rpl::start_with_next([=](not_null<History*> history) {
|
||||||
|
updateForwarding();
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
|
session().data().newMessageSent(
|
||||||
|
) | rpl::filter([=](not_null<History*> history) {
|
||||||
|
return (_history == history.get());
|
||||||
|
}) | rpl::start_with_next([=] {
|
||||||
|
synteticScrollToY(_scroll->scrollTopMax());
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
subscribe(Media::Player::instance()->switchToNextNotifier(), [this](const Media::Player::Instance::Switch &pair) {
|
subscribe(Media::Player::instance()->switchToNextNotifier(), [this](const Media::Player::Instance::Switch &pair) {
|
||||||
if (pair.from.type() == AudioMsgId::Type::Voice) {
|
if (pair.from.type() == AudioMsgId::Type::Voice) {
|
||||||
scrollToCurrentVoiceMessage(pair.from.contextId(), pair.to);
|
scrollToCurrentVoiceMessage(pair.from.contextId(), pair.to);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
|
||||||
auto changes = UpdateFlag::RightsChanged
|
session().changes().historyUpdates(
|
||||||
| UpdateFlag::UnreadMentionsChanged
|
Data::HistoryUpdate::Flag::UnreadMentions
|
||||||
| UpdateFlag::UnreadViewChanged
|
| Data::HistoryUpdate::Flag::UnreadView
|
||||||
| UpdateFlag::MigrationChanged
|
| Data::HistoryUpdate::Flag::TopPromoted
|
||||||
| UpdateFlag::UnavailableReasonChanged
|
| Data::HistoryUpdate::Flag::LocalMessages
|
||||||
| UpdateFlag::PinnedMessageChanged
|
) | rpl::filter([=](const Data::HistoryUpdate &update) {
|
||||||
| UpdateFlag::TopPromotedChanged
|
return (update.history->peer.get() == _peer);
|
||||||
| UpdateFlag::UserIsBlocked
|
}) | rpl::map([](const Data::HistoryUpdate &update) {
|
||||||
| UpdateFlag::AdminsChanged
|
return update.flags;
|
||||||
| UpdateFlag::MembersChanged
|
}) | rpl::start_with_next([=](Data::HistoryUpdate::Flags flags) {
|
||||||
| UpdateFlag::UserOnlineChanged
|
if (flags & Data::HistoryUpdate::Flag::LocalMessages) {
|
||||||
| UpdateFlag::NotificationsEnabled
|
updateSendButtonType();
|
||||||
|
}
|
||||||
|
if (flags & Data::HistoryUpdate::Flag::UnreadMentions) {
|
||||||
|
updateUnreadMentionsVisibility();
|
||||||
|
}
|
||||||
|
if (flags & Data::HistoryUpdate::Flag::UnreadView) {
|
||||||
|
unreadCountUpdated();
|
||||||
|
}
|
||||||
|
if (flags & Data::HistoryUpdate::Flag::TopPromoted) {
|
||||||
|
updateHistoryGeometry();
|
||||||
|
updateControlsVisibility();
|
||||||
|
updateControlsGeometry();
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
|
using UpdateFlag = Data::PeerUpdate::Flag;
|
||||||
|
session().changes().peerUpdates(
|
||||||
|
UpdateFlag::Rights
|
||||||
|
| UpdateFlag::Migration
|
||||||
|
| UpdateFlag::UnavailableReason
|
||||||
|
| UpdateFlag::PinnedMessage
|
||||||
|
| UpdateFlag::IsBlocked
|
||||||
|
| UpdateFlag::Admins
|
||||||
|
| UpdateFlag::Members
|
||||||
|
| UpdateFlag::OnlineStatus
|
||||||
|
| UpdateFlag::Notifications
|
||||||
| UpdateFlag::ChannelAmIn
|
| UpdateFlag::ChannelAmIn
|
||||||
| UpdateFlag::ChannelLinkedChat
|
| UpdateFlag::ChannelLinkedChat
|
||||||
| UpdateFlag::ChannelSlowmode
|
| UpdateFlag::Slowmode
|
||||||
| UpdateFlag::ChannelLocalMessages;
|
) | rpl::filter([=](const Data::PeerUpdate &update) {
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(changes, [=](const Notify::PeerUpdate &update) {
|
return (update.peer.get() == _peer);
|
||||||
if (update.peer == _peer) {
|
}) | rpl::map([](const Data::PeerUpdate &update) {
|
||||||
if (update.flags & UpdateFlag::RightsChanged) {
|
return update.flags;
|
||||||
checkPreview();
|
}) | rpl::start_with_next([=](Data::PeerUpdate::Flags flags) {
|
||||||
updateStickersByEmoji();
|
if (flags & UpdateFlag::Rights) {
|
||||||
|
checkPreview();
|
||||||
|
updateStickersByEmoji();
|
||||||
|
}
|
||||||
|
if (flags & UpdateFlag::Migration) {
|
||||||
|
handlePeerMigration();
|
||||||
|
}
|
||||||
|
if (flags & UpdateFlag::Notifications) {
|
||||||
|
updateNotifyControls();
|
||||||
|
}
|
||||||
|
if (flags & UpdateFlag::UnavailableReason) {
|
||||||
|
const auto unavailable = _peer->computeUnavailableReason();
|
||||||
|
if (!unavailable.isEmpty()) {
|
||||||
|
controller->showBackFromStack();
|
||||||
|
Ui::show(Box<InformBox>(unavailable));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (update.flags & UpdateFlag::UnreadMentionsChanged) {
|
}
|
||||||
updateUnreadMentionsVisibility();
|
if (flags & UpdateFlag::PinnedMessage) {
|
||||||
}
|
if (pinnedMsgVisibilityUpdated()) {
|
||||||
if (update.flags & UpdateFlag::UnreadViewChanged) {
|
|
||||||
unreadCountUpdated();
|
|
||||||
}
|
|
||||||
if (update.flags & UpdateFlag::MigrationChanged) {
|
|
||||||
handlePeerMigration();
|
|
||||||
}
|
|
||||||
if (update.flags & UpdateFlag::NotificationsEnabled) {
|
|
||||||
updateNotifyControls();
|
|
||||||
}
|
|
||||||
if (update.flags & UpdateFlag::UnavailableReasonChanged) {
|
|
||||||
const auto unavailable = _peer->computeUnavailableReason();
|
|
||||||
if (!unavailable.isEmpty()) {
|
|
||||||
controller->showBackFromStack();
|
|
||||||
Ui::show(Box<InformBox>(unavailable));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (update.flags & UpdateFlag::PinnedMessageChanged) {
|
|
||||||
if (pinnedMsgVisibilityUpdated()) {
|
|
||||||
updateHistoryGeometry();
|
|
||||||
updateControlsVisibility();
|
|
||||||
updateControlsGeometry();
|
|
||||||
this->update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (update.flags & UpdateFlag::TopPromotedChanged) {
|
|
||||||
updateHistoryGeometry();
|
updateHistoryGeometry();
|
||||||
updateControlsVisibility();
|
updateControlsVisibility();
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
if (update.flags & (UpdateFlag::ChannelSlowmode
|
|
||||||
| UpdateFlag::ChannelLocalMessages)) {
|
|
||||||
updateSendButtonType();
|
|
||||||
}
|
|
||||||
if (update.flags & (UpdateFlag::UserIsBlocked
|
|
||||||
| UpdateFlag::AdminsChanged
|
|
||||||
| UpdateFlag::MembersChanged
|
|
||||||
| UpdateFlag::UserOnlineChanged
|
|
||||||
| UpdateFlag::RightsChanged
|
|
||||||
| UpdateFlag::ChannelAmIn
|
|
||||||
| UpdateFlag::ChannelLinkedChat)) {
|
|
||||||
handlePeerUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}));
|
if (flags & UpdateFlag::Slowmode) {
|
||||||
|
updateSendButtonType();
|
||||||
|
}
|
||||||
|
if (flags & (UpdateFlag::IsBlocked
|
||||||
|
| UpdateFlag::Admins
|
||||||
|
| UpdateFlag::Members
|
||||||
|
| UpdateFlag::OnlineStatus
|
||||||
|
| UpdateFlag::Rights
|
||||||
|
| UpdateFlag::ChannelAmIn
|
||||||
|
| UpdateFlag::ChannelLinkedChat)) {
|
||||||
|
handlePeerUpdate();
|
||||||
|
}
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
rpl::merge(
|
rpl::merge(
|
||||||
session().data().defaultUserNotifyUpdates(),
|
session().data().defaultUserNotifyUpdates(),
|
||||||
|
@ -1074,7 +1110,7 @@ void HistoryWidget::onHashtagOrBotCommandInsert(
|
||||||
// Send bot command at once, if it was not inserted by pressing Tab.
|
// Send bot command at once, if it was not inserted by pressing Tab.
|
||||||
if (str.at(0) == '/' && method != FieldAutocomplete::ChooseMethod::ByTab) {
|
if (str.at(0) == '/' && method != FieldAutocomplete::ChooseMethod::ByTab) {
|
||||||
App::sendBotCommand(_peer, nullptr, str, replyToId());
|
App::sendBotCommand(_peer, nullptr, str, replyToId());
|
||||||
controller()->content()->finishForwarding(Api::SendAction(_history));
|
session().api().finishForwarding(Api::SendAction(_history));
|
||||||
setFieldText(_field->getTextWithTagsPart(_field->textCursor().position()));
|
setFieldText(_field->getTextWithTagsPart(_field->textCursor().position()));
|
||||||
} else {
|
} else {
|
||||||
_field->insertTag(str);
|
_field->insertTag(str);
|
||||||
|
@ -2381,16 +2417,6 @@ void HistoryWidget::unreadMessageAdded(not_null<HistoryItem*> item) {
|
||||||
session().notifications().clearFromHistory(_history);
|
session().notifications().clearFromHistory(_history);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::historyToDown(History *history) {
|
|
||||||
history->forgetScrollState();
|
|
||||||
if (auto migrated = history->owner().historyLoaded(history->peer->migrateFrom())) {
|
|
||||||
migrated->forgetScrollState();
|
|
||||||
}
|
|
||||||
if (history == _history) {
|
|
||||||
synteticScrollToY(_scroll->scrollTopMax());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HistoryWidget::unreadCountUpdated() {
|
void HistoryWidget::unreadCountUpdated() {
|
||||||
if (_history->chatListUnreadMark()) {
|
if (_history->chatListUnreadMark()) {
|
||||||
crl::on_main(this, [=, history = _history] {
|
crl::on_main(this, [=, history = _history] {
|
||||||
|
@ -3151,8 +3177,7 @@ void HistoryWidget::send(Api::SendOptions options) {
|
||||||
if (!_keyboard->hasMarkup() && _keyboard->forceReply() && !_kbReplyTo) {
|
if (!_keyboard->hasMarkup() && _keyboard->forceReply() && !_kbReplyTo) {
|
||||||
toggleKeyboard();
|
toggleKeyboard();
|
||||||
}
|
}
|
||||||
controller()->content()->historyToDown(_history);
|
session().data().newMessageSent(_history);
|
||||||
controller()->content()->dialogsToUp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::sendWithModifiers(Qt::KeyboardModifiers modifiers) {
|
void HistoryWidget::sendWithModifiers(Qt::KeyboardModifiers modifiers) {
|
||||||
|
@ -4093,6 +4118,9 @@ void HistoryWidget::setMembersShowAreaActive(bool active) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::onMembersDropdownShow() {
|
void HistoryWidget::onMembersDropdownShow() {
|
||||||
|
if (!_peer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!_membersDropdown) {
|
if (!_membersDropdown) {
|
||||||
_membersDropdown.create(this, st::membersInnerDropdown);
|
_membersDropdown.create(this, st::membersInnerDropdown);
|
||||||
_membersDropdown->setOwnedWidget(object_ptr<Profile::GroupMembersWidget>(this, _peer, st::membersInnerItem));
|
_membersDropdown->setOwnedWidget(object_ptr<Profile::GroupMembersWidget>(this, _peer, st::membersInnerItem));
|
||||||
|
@ -4856,10 +4884,7 @@ void HistoryWidget::sendFileConfirmed(
|
||||||
}
|
}
|
||||||
|
|
||||||
session().data().sendHistoryChangeNotifications();
|
session().data().sendHistoryChangeNotifications();
|
||||||
if (_peer && file->to.peer == _peer->id) {
|
session().data().newMessageSent(history);
|
||||||
controller()->content()->historyToDown(_history);
|
|
||||||
}
|
|
||||||
controller()->content()->dialogsToUp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::photoUploaded(
|
void HistoryWidget::photoUploaded(
|
||||||
|
@ -5591,7 +5616,7 @@ void HistoryWidget::mousePressEvent(QMouseEvent *e) {
|
||||||
} else if (_inReplyEditForward) {
|
} else if (_inReplyEditForward) {
|
||||||
if (readyToForward()) {
|
if (readyToForward()) {
|
||||||
const auto items = std::move(_toForward);
|
const auto items = std::move(_toForward);
|
||||||
controller()->content()->cancelForwarding(_history);
|
session().data().cancelForwarding(_history);
|
||||||
auto list = ranges::view::all(
|
auto list = ranges::view::all(
|
||||||
items
|
items
|
||||||
) | ranges::view::transform(
|
) | ranges::view::transform(
|
||||||
|
@ -6049,7 +6074,7 @@ void HistoryWidget::replyToMessage(not_null<HistoryItem*> item) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
controller()->content()->cancelForwarding(_history);
|
session().data().cancelForwarding(_history);
|
||||||
|
|
||||||
if (_editMsgId) {
|
if (_editMsgId) {
|
||||||
if (auto localDraft = _history->localDraft()) {
|
if (auto localDraft = _history->localDraft()) {
|
||||||
|
@ -6317,7 +6342,7 @@ void HistoryWidget::cancelFieldAreaState() {
|
||||||
} else if (_editMsgId) {
|
} else if (_editMsgId) {
|
||||||
cancelEdit();
|
cancelEdit();
|
||||||
} else if (readyToForward()) {
|
} else if (readyToForward()) {
|
||||||
controller()->content()->cancelForwarding(_history);
|
session().data().cancelForwarding(_history);
|
||||||
} else if (_replyToId) {
|
} else if (_replyToId) {
|
||||||
cancelReply();
|
cancelReply();
|
||||||
} else if (_kbReplyTo) {
|
} else if (_kbReplyTo) {
|
||||||
|
|
|
@ -135,8 +135,6 @@ public:
|
||||||
void firstLoadMessages();
|
void firstLoadMessages();
|
||||||
void delayedShowAt(MsgId showAtMsgId);
|
void delayedShowAt(MsgId showAtMsgId);
|
||||||
|
|
||||||
void historyToDown(History *history);
|
|
||||||
|
|
||||||
QRect historyRect() const;
|
QRect historyRect() const;
|
||||||
|
|
||||||
void updateFieldPlaceholder();
|
void updateFieldPlaceholder();
|
||||||
|
|
|
@ -22,10 +22,6 @@ namespace Api {
|
||||||
struct SendOptions;
|
struct SendOptions;
|
||||||
} // namespace Api
|
} // namespace Api
|
||||||
|
|
||||||
namespace Notify {
|
|
||||||
struct PeerUpdate;
|
|
||||||
} // namespace Notify
|
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
struct PreparedList;
|
struct PreparedList;
|
||||||
} // namespace Storage
|
} // namespace Storage
|
||||||
|
|
|
@ -35,9 +35,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "support/support_helper.h"
|
#include "support/support_helper.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
#include "styles/style_window.h"
|
#include "styles/style_window.h"
|
||||||
|
@ -113,20 +113,22 @@ TopBarWidget::TopBarWidget(
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
using UpdateFlag = Data::PeerUpdate::Flag;
|
||||||
auto flags = UpdateFlag::UserHasCalls
|
session().changes().peerUpdates(
|
||||||
| UpdateFlag::UserOnlineChanged
|
UpdateFlag::HasCalls
|
||||||
| UpdateFlag::MembersChanged
|
| UpdateFlag::OnlineStatus
|
||||||
| UpdateFlag::UserSupportInfoChanged;
|
| UpdateFlag::Members
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(flags, [=](const Notify::PeerUpdate &update) {
|
| UpdateFlag::SupportInfo
|
||||||
if (update.flags & UpdateFlag::UserHasCalls) {
|
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
|
||||||
|
if (update.flags & UpdateFlag::HasCalls) {
|
||||||
if (update.peer->isUser()) {
|
if (update.peer->isUser()) {
|
||||||
updateControlsVisibility();
|
updateControlsVisibility();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
updateOnlineDisplay();
|
updateOnlineDisplay();
|
||||||
}
|
}
|
||||||
}));
|
}, lifetime());
|
||||||
|
|
||||||
subscribe(Global::RefPhoneCallsEnabledChanged(), [this] {
|
subscribe(Global::RefPhoneCallsEnabledChanged(), [this] {
|
||||||
updateControlsVisibility();
|
updateControlsVisibility();
|
||||||
});
|
});
|
||||||
|
@ -286,7 +288,7 @@ bool TopBarWidget::eventFilter(QObject *obj, QEvent *e) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TWidget::eventFilter(obj, e);
|
return RpWidget::eventFilter(obj, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TopBarWidget::resizeGetHeight(int newWidth) {
|
int TopBarWidget::resizeGetHeight(int newWidth) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "info/info_content_widget.h"
|
#include "info/info_content_widget.h"
|
||||||
#include "info/info_memento.h"
|
#include "info/info_memento.h"
|
||||||
#include "info/media/info_media_widget.h"
|
#include "info/media/info_media_widget.h"
|
||||||
#include "observer_peer.h"
|
#include "data/data_changes.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
|
@ -153,22 +153,22 @@ void Controller::setupMigrationViewer() {
|
||||||
if (!peer || (!peer->isChat() && !peer->isChannel()) || _migrated) {
|
if (!peer || (!peer->isChat() && !peer->isChannel()) || _migrated) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Notify::PeerUpdateValue(
|
peer->session().changes().peerFlagsValue(
|
||||||
peer,
|
peer,
|
||||||
Notify::PeerUpdate::Flag::MigrationChanged
|
Data::PeerUpdate::Flag::Migration
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::filter([=] {
|
||||||
if (peer->migrateTo() || (peer->migrateFrom() != _migrated)) {
|
return peer->migrateTo() || (peer->migrateFrom() != _migrated);
|
||||||
const auto window = parentController();
|
}) | rpl::start_with_next([=] {
|
||||||
const auto section = _section;
|
const auto window = parentController();
|
||||||
InvokeQueued(_widget, [=] {
|
const auto section = _section;
|
||||||
window->showSection(
|
InvokeQueued(_widget, [=] {
|
||||||
Memento(peer, section),
|
window->showSection(
|
||||||
Window::SectionShow(
|
Memento(peer, section),
|
||||||
Window::SectionShow::Way::Backward,
|
Window::SectionShow(
|
||||||
anim::type::instant,
|
Window::SectionShow::Way::Backward,
|
||||||
anim::activation::background));
|
anim::type::instant,
|
||||||
});
|
anim::activation::background));
|
||||||
}
|
});
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
@ -482,9 +483,9 @@ void WrapWidget::addProfileCallsButton() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Notify::PeerUpdateValue(
|
user->session().changes().peerFlagsValue(
|
||||||
user,
|
user,
|
||||||
Notify::PeerUpdate::Flag::UserHasCalls
|
Data::PeerUpdate::Flag::HasCalls
|
||||||
) | rpl::filter([=] {
|
) | rpl::filter([=] {
|
||||||
return user->hasCalls();
|
return user->hasCalls();
|
||||||
}) | rpl::take(
|
}) | rpl::take(
|
||||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
#include "ui/wrap/padding_wrap.h"
|
#include "ui/wrap/padding_wrap.h"
|
||||||
|
@ -556,9 +557,9 @@ void ActionsFiller::addBotCommandActions(not_null<UserData*> user) {
|
||||||
return QString();
|
return QString();
|
||||||
};
|
};
|
||||||
auto hasBotCommandValue = [=](const QString &command) {
|
auto hasBotCommandValue = [=](const QString &command) {
|
||||||
return Notify::PeerUpdateValue(
|
return user->session().changes().peerFlagsValue(
|
||||||
user,
|
user,
|
||||||
Notify::PeerUpdate::Flag::BotCommandsChanged
|
Data::PeerUpdate::Flag::BotCommands
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return !findBotCommand(command).isEmpty();
|
return !findBotCommand(command).isEmpty();
|
||||||
});
|
});
|
||||||
|
@ -597,10 +598,10 @@ void ActionsFiller::addReportAction() {
|
||||||
void ActionsFiller::addBlockAction(not_null<UserData*> user) {
|
void ActionsFiller::addBlockAction(not_null<UserData*> user) {
|
||||||
const auto window = &_controller->parentController()->window();
|
const auto window = &_controller->parentController()->window();
|
||||||
|
|
||||||
auto text = Notify::PeerUpdateValue(
|
auto text = user->session().changes().peerFlagsValue(
|
||||||
user,
|
user,
|
||||||
Notify::PeerUpdate::Flag::UserIsBlocked
|
Data::PeerUpdate::Flag::IsBlocked
|
||||||
) | rpl::map([user] {
|
) | rpl::map([=] {
|
||||||
switch (user->blockStatus()) {
|
switch (user->blockStatus()) {
|
||||||
case UserData::BlockStatus::Blocked:
|
case UserData::BlockStatus::Blocked:
|
||||||
return ((user->isBot() && !user->isSupport())
|
return ((user->isBot() && !user->isSupport())
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "info/profile/info_profile_values.h"
|
#include "info/profile/info_profile_values.h"
|
||||||
#include "info/info_controller.h"
|
#include "info/info_controller.h"
|
||||||
#include "info/info_memento.h"
|
#include "info/info_memento.h"
|
||||||
|
@ -24,7 +25,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/unread_badge.h"
|
#include "ui/unread_badge.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
|
@ -298,7 +298,7 @@ Cover *Cover::setOnlineCount(rpl::producer<int> &&count) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cover::initViewers(rpl::producer<QString> title) {
|
void Cover::initViewers(rpl::producer<QString> title) {
|
||||||
using Flag = Notify::PeerUpdate::Flag;
|
using Flag = Data::PeerUpdate::Flag;
|
||||||
std::move(
|
std::move(
|
||||||
title
|
title
|
||||||
) | rpl::start_with_next([=](const QString &title) {
|
) | rpl::start_with_next([=](const QString &title) {
|
||||||
|
@ -306,16 +306,16 @@ void Cover::initViewers(rpl::producer<QString> title) {
|
||||||
refreshNameGeometry(width());
|
refreshNameGeometry(width());
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
Notify::PeerUpdateValue(
|
_peer->session().changes().peerFlagsValue(
|
||||||
_peer,
|
_peer,
|
||||||
Flag::UserOnlineChanged | Flag::MembersChanged
|
Flag::OnlineStatus | Flag::Members
|
||||||
) | rpl::start_with_next(
|
) | rpl::start_with_next(
|
||||||
[=] { refreshStatusText(); },
|
[=] { refreshStatusText(); },
|
||||||
lifetime());
|
lifetime());
|
||||||
if (!_peer->isUser()) {
|
if (!_peer->isUser()) {
|
||||||
Notify::PeerUpdateValue(
|
_peer->session().changes().peerFlagsValue(
|
||||||
_peer,
|
_peer,
|
||||||
Flag::RightsChanged
|
Flag::Rights
|
||||||
) | rpl::start_with_next(
|
) | rpl::start_with_next(
|
||||||
[=] { refreshUploadPhotoOverlay(); },
|
[=] { refreshUploadPhotoOverlay(); },
|
||||||
lifetime());
|
lifetime());
|
||||||
|
|
|
@ -15,7 +15,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
|
|
@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "info/profile/info_profile_values.h"
|
#include "info/profile/info_profile_values.h"
|
||||||
|
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "ui/wrap/slide_wrap.h"
|
#include "ui/wrap/slide_wrap.h"
|
||||||
|
@ -16,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
#include "data/data_shared_media.h"
|
#include "data/data_shared_media.h"
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
@ -27,17 +27,21 @@ namespace Info {
|
||||||
namespace Profile {
|
namespace Profile {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using UpdateFlag = Data::PeerUpdate::Flag;
|
||||||
|
|
||||||
auto PlainBioValue(not_null<UserData*> user) {
|
auto PlainBioValue(not_null<UserData*> user) {
|
||||||
return Notify::PeerUpdateValue(
|
return user->session().changes().peerFlagsValue(
|
||||||
user,
|
user,
|
||||||
Notify::PeerUpdate::Flag::AboutChanged
|
UpdateFlag::About
|
||||||
) | rpl::map([=] { return user->about(); });
|
) | rpl::map([=] {
|
||||||
|
return user->about();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto PlainUsernameValue(not_null<PeerData*> peer) {
|
auto PlainUsernameValue(not_null<PeerData*> peer) {
|
||||||
return Notify::PeerUpdateValue(
|
return peer->session().changes().peerFlagsValue(
|
||||||
peer,
|
peer,
|
||||||
Notify::PeerUpdate::Flag::UsernameChanged
|
UpdateFlag::Username
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return peer->userName();
|
return peer->userName();
|
||||||
});
|
});
|
||||||
|
@ -46,19 +50,19 @@ auto PlainUsernameValue(not_null<PeerData*> peer) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
rpl::producer<TextWithEntities> NameValue(not_null<PeerData*> peer) {
|
rpl::producer<TextWithEntities> NameValue(not_null<PeerData*> peer) {
|
||||||
return Notify::PeerUpdateValue(
|
return peer->session().changes().peerFlagsValue(
|
||||||
peer,
|
peer,
|
||||||
Notify::PeerUpdate::Flag::NameChanged
|
UpdateFlag::Name
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return peer->name;
|
return peer->name;
|
||||||
}) | Ui::Text::ToWithEntities();
|
}) | Ui::Text::ToWithEntities();;
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<TextWithEntities> PhoneValue(not_null<UserData*> user) {
|
rpl::producer<TextWithEntities> PhoneValue(not_null<UserData*> user) {
|
||||||
return Notify::PeerUpdateValue(
|
return user->session().changes().peerFlagsValue(
|
||||||
user,
|
user,
|
||||||
Notify::PeerUpdate::Flag::UserPhoneChanged
|
UpdateFlag::PhoneNumber
|
||||||
) | rpl::map([user] {
|
) | rpl::map([=] {
|
||||||
return App::formatPhone(user->phone());
|
return App::formatPhone(user->phone());
|
||||||
}) | Ui::Text::ToWithEntities();
|
}) | Ui::Text::ToWithEntities();
|
||||||
}
|
}
|
||||||
|
@ -102,10 +106,12 @@ rpl::producer<QString> PlainAboutValue(not_null<PeerData*> peer) {
|
||||||
return rpl::single(QString());
|
return rpl::single(QString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Notify::PeerUpdateValue(
|
return peer->session().changes().peerFlagsValue(
|
||||||
peer,
|
peer,
|
||||||
Notify::PeerUpdate::Flag::AboutChanged
|
UpdateFlag::About
|
||||||
) | rpl::map([=] { return peer->about(); });
|
) | rpl::map([=] {
|
||||||
|
return peer->about();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<TextWithEntities> AboutValue(not_null<PeerData*> peer) {
|
rpl::producer<TextWithEntities> AboutValue(not_null<PeerData*> peer) {
|
||||||
|
@ -136,9 +142,9 @@ rpl::producer<QString> LinkValue(not_null<PeerData*> peer) {
|
||||||
|
|
||||||
rpl::producer<const ChannelLocation*> LocationValue(
|
rpl::producer<const ChannelLocation*> LocationValue(
|
||||||
not_null<ChannelData*> channel) {
|
not_null<ChannelData*> channel) {
|
||||||
return Notify::PeerUpdateValue(
|
return channel->session().changes().peerFlagsValue(
|
||||||
channel,
|
channel,
|
||||||
Notify::PeerUpdate::Flag::ChannelLocation
|
UpdateFlag::ChannelLocation
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return channel->getLocation();
|
return channel->getLocation();
|
||||||
});
|
});
|
||||||
|
@ -146,9 +152,9 @@ rpl::producer<const ChannelLocation*> LocationValue(
|
||||||
|
|
||||||
rpl::producer<bool> NotificationsEnabledValue(not_null<PeerData*> peer) {
|
rpl::producer<bool> NotificationsEnabledValue(not_null<PeerData*> peer) {
|
||||||
return rpl::merge(
|
return rpl::merge(
|
||||||
Notify::PeerUpdateValue(
|
peer->session().changes().peerFlagsValue(
|
||||||
peer,
|
peer,
|
||||||
Notify::PeerUpdate::Flag::NotificationsEnabled
|
UpdateFlag::Notifications
|
||||||
) | rpl::map([] { return rpl::empty_value(); }),
|
) | rpl::map([] { return rpl::empty_value(); }),
|
||||||
peer->owner().defaultNotifyUpdates(peer)
|
peer->owner().defaultNotifyUpdates(peer)
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
|
@ -157,29 +163,31 @@ rpl::producer<bool> NotificationsEnabledValue(not_null<PeerData*> peer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<bool> IsContactValue(not_null<UserData*> user) {
|
rpl::producer<bool> IsContactValue(not_null<UserData*> user) {
|
||||||
return Notify::PeerUpdateValue(
|
return user->session().changes().peerFlagsValue(
|
||||||
user,
|
user,
|
||||||
Notify::PeerUpdate::Flag::UserIsContact
|
UpdateFlag::IsContact
|
||||||
) | rpl::map([user] { return user->isContact(); });
|
) | rpl::map([=] {
|
||||||
|
return user->isContact();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<bool> CanInviteBotToGroupValue(not_null<UserData*> user) {
|
rpl::producer<bool> CanInviteBotToGroupValue(not_null<UserData*> user) {
|
||||||
if (!user->isBot() || user->isSupport()) {
|
if (!user->isBot() || user->isSupport()) {
|
||||||
return rpl::single(false);
|
return rpl::single(false);
|
||||||
}
|
}
|
||||||
return Notify::PeerUpdateValue(
|
return user->session().changes().peerFlagsValue(
|
||||||
user,
|
user,
|
||||||
Notify::PeerUpdate::Flag::BotCanAddToGroups
|
UpdateFlag::BotCanBeInvited
|
||||||
) | rpl::map([user] {
|
) | rpl::map([=] {
|
||||||
return !user->botInfo->cantJoinGroups;
|
return !user->botInfo->cantJoinGroups;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<bool> CanShareContactValue(not_null<UserData*> user) {
|
rpl::producer<bool> CanShareContactValue(not_null<UserData*> user) {
|
||||||
return Notify::PeerUpdateValue(
|
return user->session().changes().peerFlagsValue(
|
||||||
user,
|
user,
|
||||||
Notify::PeerUpdate::Flag::UserCanShareContact
|
UpdateFlag::CanShareContact
|
||||||
) | rpl::map([user] {
|
) | rpl::map([=] {
|
||||||
return user->canShareThisContact();
|
return user->canShareThisContact();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -195,28 +203,29 @@ rpl::producer<bool> CanAddContactValue(not_null<UserData*> user) {
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<bool> AmInChannelValue(not_null<ChannelData*> channel) {
|
rpl::producer<bool> AmInChannelValue(not_null<ChannelData*> channel) {
|
||||||
return Notify::PeerUpdateValue(
|
return channel->session().changes().peerFlagsValue(
|
||||||
channel,
|
channel,
|
||||||
Notify::PeerUpdate::Flag::ChannelAmIn
|
UpdateFlag::ChannelAmIn
|
||||||
) | rpl::map([channel] { return channel->amIn(); });
|
) | rpl::map([=] {
|
||||||
|
return channel->amIn();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<int> MembersCountValue(not_null<PeerData*> peer) {
|
rpl::producer<int> MembersCountValue(not_null<PeerData*> peer) {
|
||||||
using Flag = Notify::PeerUpdate::Flag;
|
|
||||||
if (const auto chat = peer->asChat()) {
|
if (const auto chat = peer->asChat()) {
|
||||||
return Notify::PeerUpdateValue(
|
return peer->session().changes().peerFlagsValue(
|
||||||
peer,
|
peer,
|
||||||
Flag::MembersChanged
|
UpdateFlag::Members
|
||||||
) | rpl::map([chat] {
|
) | rpl::map([=] {
|
||||||
return chat->amIn()
|
return chat->amIn()
|
||||||
? std::max(chat->count, int(chat->participants.size()))
|
? std::max(chat->count, int(chat->participants.size()))
|
||||||
: 0;
|
: 0;
|
||||||
});
|
});
|
||||||
} else if (const auto channel = peer->asChannel()) {
|
} else if (const auto channel = peer->asChannel()) {
|
||||||
return Notify::PeerUpdateValue(
|
return peer->session().changes().peerFlagsValue(
|
||||||
channel,
|
peer,
|
||||||
Flag::MembersChanged
|
UpdateFlag::Members
|
||||||
) | rpl::map([channel] {
|
) | rpl::map([=] {
|
||||||
return channel->membersCount();
|
return channel->membersCount();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -224,20 +233,19 @@ rpl::producer<int> MembersCountValue(not_null<PeerData*> peer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<int> AdminsCountValue(not_null<PeerData*> peer) {
|
rpl::producer<int> AdminsCountValue(not_null<PeerData*> peer) {
|
||||||
using Flag = Notify::PeerUpdate::Flag;
|
|
||||||
if (const auto chat = peer->asChat()) {
|
if (const auto chat = peer->asChat()) {
|
||||||
return Notify::PeerUpdateValue(
|
return peer->session().changes().peerFlagsValue(
|
||||||
chat,
|
peer,
|
||||||
Flag::AdminsChanged | Flag::RightsChanged
|
UpdateFlag::Admins | UpdateFlag::Rights
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return chat->participants.empty()
|
return chat->participants.empty()
|
||||||
? 0
|
? 0
|
||||||
: int(chat->admins.size() + 1); // + creator
|
: int(chat->admins.size() + 1); // + creator
|
||||||
});
|
});
|
||||||
} else if (const auto channel = peer->asChannel()) {
|
} else if (const auto channel = peer->asChannel()) {
|
||||||
return Notify::PeerUpdateValue(
|
return peer->session().changes().peerFlagsValue(
|
||||||
channel,
|
peer,
|
||||||
Flag::AdminsChanged | Flag::RightsChanged
|
UpdateFlag::Admins | UpdateFlag::Rights
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return channel->canViewAdmins()
|
return channel->canViewAdmins()
|
||||||
? channel->adminsCount()
|
? channel->adminsCount()
|
||||||
|
@ -257,18 +265,17 @@ rpl::producer<int> RestrictionsCountValue(not_null<PeerData*> peer) {
|
||||||
return int(Data::ListOfRestrictions().size()) - count;
|
return int(Data::ListOfRestrictions().size()) - count;
|
||||||
};
|
};
|
||||||
|
|
||||||
using Flag = Notify::PeerUpdate::Flag;
|
|
||||||
if (const auto chat = peer->asChat()) {
|
if (const auto chat = peer->asChat()) {
|
||||||
return Notify::PeerUpdateValue(
|
return peer->session().changes().peerFlagsValue(
|
||||||
chat,
|
peer,
|
||||||
Flag::RightsChanged
|
UpdateFlag::Rights
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return countOfRestrictions(chat->defaultRestrictions());
|
return countOfRestrictions(chat->defaultRestrictions());
|
||||||
});
|
});
|
||||||
} else if (const auto channel = peer->asChannel()) {
|
} else if (const auto channel = peer->asChannel()) {
|
||||||
return Notify::PeerUpdateValue(
|
return peer->session().changes().peerFlagsValue(
|
||||||
channel,
|
peer,
|
||||||
Flag::RightsChanged
|
UpdateFlag::Rights
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return countOfRestrictions(channel->defaultRestrictions());
|
return countOfRestrictions(channel->defaultRestrictions());
|
||||||
});
|
});
|
||||||
|
@ -278,11 +285,10 @@ rpl::producer<int> RestrictionsCountValue(not_null<PeerData*> peer) {
|
||||||
|
|
||||||
rpl::producer<not_null<PeerData*>> MigratedOrMeValue(
|
rpl::producer<not_null<PeerData*>> MigratedOrMeValue(
|
||||||
not_null<PeerData*> peer) {
|
not_null<PeerData*> peer) {
|
||||||
using Flag = Notify::PeerUpdate::Flag;
|
|
||||||
if (const auto chat = peer->asChat()) {
|
if (const auto chat = peer->asChat()) {
|
||||||
return Notify::PeerUpdateValue(
|
return peer->session().changes().peerFlagsValue(
|
||||||
chat,
|
peer,
|
||||||
Flag::MigrationChanged
|
UpdateFlag::Migration
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return chat->migrateToOrMe();
|
return chat->migrateToOrMe();
|
||||||
});
|
});
|
||||||
|
@ -292,10 +298,9 @@ rpl::producer<not_null<PeerData*>> MigratedOrMeValue(
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<int> RestrictedCountValue(not_null<ChannelData*> channel) {
|
rpl::producer<int> RestrictedCountValue(not_null<ChannelData*> channel) {
|
||||||
using Flag = Notify::PeerUpdate::Flag;
|
return channel->session().changes().peerFlagsValue(
|
||||||
return Notify::PeerUpdateValue(
|
|
||||||
channel,
|
channel,
|
||||||
Flag::BannedUsersChanged | Flag::RightsChanged
|
UpdateFlag::BannedUsers | UpdateFlag::Rights
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return channel->canViewBanned()
|
return channel->canViewBanned()
|
||||||
? channel->restrictedCount()
|
? channel->restrictedCount()
|
||||||
|
@ -304,10 +309,9 @@ rpl::producer<int> RestrictedCountValue(not_null<ChannelData*> channel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<int> KickedCountValue(not_null<ChannelData*> channel) {
|
rpl::producer<int> KickedCountValue(not_null<ChannelData*> channel) {
|
||||||
using Flag = Notify::PeerUpdate::Flag;
|
return channel->session().changes().peerFlagsValue(
|
||||||
return Notify::PeerUpdateValue(
|
|
||||||
channel,
|
channel,
|
||||||
Flag::BannedUsersChanged | Flag::RightsChanged
|
UpdateFlag::BannedUsers | UpdateFlag::Rights
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return channel->canViewBanned()
|
return channel->canViewBanned()
|
||||||
? channel->kickedCount()
|
? channel->kickedCount()
|
||||||
|
@ -338,26 +342,26 @@ rpl::producer<int> SharedMediaCountValue(
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<int> CommonGroupsCountValue(not_null<UserData*> user) {
|
rpl::producer<int> CommonGroupsCountValue(not_null<UserData*> user) {
|
||||||
return Notify::PeerUpdateValue(
|
return user->session().changes().peerFlagsValue(
|
||||||
user,
|
user,
|
||||||
Notify::PeerUpdate::Flag::UserCommonChatsChanged
|
UpdateFlag::CommonChats
|
||||||
) | rpl::map([user] {
|
) | rpl::map([=] {
|
||||||
return user->commonChatsCount();
|
return user->commonChatsCount();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<bool> CanAddMemberValue(not_null<PeerData*> peer) {
|
rpl::producer<bool> CanAddMemberValue(not_null<PeerData*> peer) {
|
||||||
if (const auto chat = peer->asChat()) {
|
if (const auto chat = peer->asChat()) {
|
||||||
return Notify::PeerUpdateValue(
|
return peer->session().changes().peerFlagsValue(
|
||||||
chat,
|
peer,
|
||||||
Notify::PeerUpdate::Flag::RightsChanged
|
UpdateFlag::Rights
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return chat->canAddMembers();
|
return chat->canAddMembers();
|
||||||
});
|
});
|
||||||
} else if (const auto channel = peer->asChannel()) {
|
} else if (const auto channel = peer->asChannel()) {
|
||||||
return Notify::PeerUpdateValue(
|
return peer->session().changes().peerFlagsValue(
|
||||||
channel,
|
peer,
|
||||||
Notify::PeerUpdate::Flag::RightsChanged
|
UpdateFlag::Rights
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return channel->canAddMembers();
|
return channel->canAddMembers();
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include <rpl/producer.h>
|
#include <rpl/producer.h>
|
||||||
#include <rpl/map.h>
|
#include <rpl/map.h>
|
||||||
#include "observer_peer.h"
|
|
||||||
|
|
||||||
struct ChannelLocation;
|
struct ChannelLocation;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_file_origin.h"
|
#include "data/data_file_origin.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/shadow.h"
|
#include "ui/widgets/shadow.h"
|
||||||
#include "ui/effects/ripple_animation.h"
|
#include "ui/effects/ripple_animation.h"
|
||||||
|
@ -29,7 +30,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "ui/widgets/scroll_area.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "history/view/history_view_cursor_state.h"
|
#include "history/view/history_view_cursor_state.h"
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
@ -49,7 +49,7 @@ constexpr auto kInlineBotRequestDelay = 400;
|
||||||
Inner::Inner(
|
Inner::Inner(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<Window::SessionController*> controller)
|
not_null<Window::SessionController*> controller)
|
||||||
: TWidget(parent)
|
: RpWidget(parent)
|
||||||
, _controller(controller)
|
, _controller(controller)
|
||||||
, _updateInlineItems([=] { updateInlineItems(); })
|
, _updateInlineItems([=] { updateInlineItems(); })
|
||||||
, _previewTimer([=] { showPreview(); }) {
|
, _previewTimer([=] { showPreview(); }) {
|
||||||
|
@ -66,15 +66,18 @@ Inner::Inner(
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::RightsChanged, [this](const Notify::PeerUpdate &update) {
|
|
||||||
if (update.peer == _inlineQueryPeer) {
|
_controller->session().changes().peerUpdates(
|
||||||
auto isRestricted = (_restrictedLabel != nullptr);
|
Data::PeerUpdate::Flag::Rights
|
||||||
if (isRestricted != isRestrictedView()) {
|
) | rpl::filter([=](const Data::PeerUpdate &update) {
|
||||||
auto h = countHeight();
|
return (update.peer.get() == _inlineQueryPeer);
|
||||||
if (h != height()) resize(width(), h);
|
}) | rpl::start_with_next([=] {
|
||||||
}
|
auto isRestricted = (_restrictedLabel != nullptr);
|
||||||
|
if (isRestricted != isRestrictedView()) {
|
||||||
|
auto h = countHeight();
|
||||||
|
if (h != height()) resize(width(), h);
|
||||||
}
|
}
|
||||||
}));
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inner::visibleTopBottomUpdated(
|
void Inner::visibleTopBottomUpdated(
|
||||||
|
|
|
@ -25,7 +25,7 @@ class LinkButton;
|
||||||
class RoundButton;
|
class RoundButton;
|
||||||
class FlatLabel;
|
class FlatLabel;
|
||||||
class RippleAnimation;
|
class RippleAnimation;
|
||||||
} // namesapce Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
class SessionController;
|
class SessionController;
|
||||||
|
@ -52,7 +52,7 @@ struct CacheEntry {
|
||||||
};
|
};
|
||||||
|
|
||||||
class Inner
|
class Inner
|
||||||
: public TWidget
|
: public Ui::RpWidget
|
||||||
, public Ui::AbstractTooltipShower
|
, public Ui::AbstractTooltipShower
|
||||||
, public Context
|
, public Context
|
||||||
, private base::Subscriber {
|
, private base::Subscriber {
|
||||||
|
|
|
@ -15,11 +15,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "media/audio/media_audio.h"
|
#include "media/audio/media_audio.h"
|
||||||
#include "ui/image/image.h"
|
#include "ui/image/image.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "api/api_updates.h"
|
#include "api/api_updates.h"
|
||||||
#include "main/main_app_config.h"
|
#include "main/main_app_config.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
@ -377,7 +377,7 @@ void Account::startMtp() {
|
||||||
|
|
||||||
if (sessionExists()) {
|
if (sessionExists()) {
|
||||||
// Skip all pending self updates so that we won't local().writeSelf.
|
// Skip all pending self updates so that we won't local().writeSelf.
|
||||||
Notify::peerUpdatedSendDelayed();
|
session().changes().sendNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
_mtpValue = _mtp.get();
|
_mtpValue = _mtp.get();
|
||||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "storage/storage_facade.h"
|
#include "storage/storage_facade.h"
|
||||||
#include "storage/storage_account.h"
|
#include "storage/storage_account.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "window/notifications_manager.h"
|
#include "window/notifications_manager.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
@ -28,7 +29,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
//#include "platform/platform_specific.h"
|
//#include "platform/platform_specific.h"
|
||||||
#include "calls/calls_instance.h"
|
#include "calls/calls_instance.h"
|
||||||
#include "support/support_helper.h"
|
#include "support/support_helper.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
|
|
||||||
#ifndef TDESKTOP_DISABLE_SPELLCHECK
|
#ifndef TDESKTOP_DISABLE_SPELLCHECK
|
||||||
|
@ -56,6 +56,7 @@ Session::Session(
|
||||||
, _uploader(std::make_unique<Storage::Uploader>(_api.get()))
|
, _uploader(std::make_unique<Storage::Uploader>(_api.get()))
|
||||||
, _storage(std::make_unique<Storage::Facade>())
|
, _storage(std::make_unique<Storage::Facade>())
|
||||||
, _notifications(std::make_unique<Window::Notifications::System>(this))
|
, _notifications(std::make_unique<Window::Notifications::System>(this))
|
||||||
|
, _changes(std::make_unique<Data::Changes>(this))
|
||||||
, _data(std::make_unique<Data::Session>(this))
|
, _data(std::make_unique<Data::Session>(this))
|
||||||
, _user(_data->processUser(user))
|
, _user(_data->processUser(user))
|
||||||
, _emojiStickersPack(std::make_unique<Stickers::EmojiPack>(this))
|
, _emojiStickersPack(std::make_unique<Stickers::EmojiPack>(this))
|
||||||
|
@ -74,21 +75,17 @@ Session::Session(
|
||||||
_api->requestFullPeer(_user);
|
_api->requestFullPeer(_user);
|
||||||
|
|
||||||
crl::on_main(this, [=] {
|
crl::on_main(this, [=] {
|
||||||
using Flag = Notify::PeerUpdate::Flag;
|
using Flag = Data::PeerUpdate::Flag;
|
||||||
const auto events = Flag::NameChanged
|
changes().peerUpdates(
|
||||||
| Flag::UsernameChanged
|
_user,
|
||||||
| Flag::PhotoChanged
|
Flag::Name
|
||||||
| Flag::AboutChanged
|
| Flag::Username
|
||||||
| Flag::UserPhoneChanged;
|
| Flag::Photo
|
||||||
subscribe(
|
| Flag::About
|
||||||
Notify::PeerUpdated(),
|
| Flag::PhoneNumber
|
||||||
Notify::PeerUpdatedHandler(
|
) | rpl::start_with_next([=] {
|
||||||
events,
|
local().writeSelf();
|
||||||
[=](const Notify::PeerUpdate &update) {
|
}, _lifetime);
|
||||||
if (update.peer == _user) {
|
|
||||||
local().writeSelf();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (_settings.hadLegacyCallsPeerToPeerNobody()) {
|
if (_settings.hadLegacyCallsPeerToPeerNobody()) {
|
||||||
api().savePrivacy(
|
api().savePrivacy(
|
||||||
|
|
|
@ -30,6 +30,7 @@ class Templates;
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
class Session;
|
class Session;
|
||||||
|
class Changes;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
|
@ -104,11 +105,12 @@ public:
|
||||||
[[nodiscard]] Stickers::DicePacks &diceStickersPacks() const {
|
[[nodiscard]] Stickers::DicePacks &diceStickersPacks() const {
|
||||||
return *_diceStickersPacks;
|
return *_diceStickersPacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] Window::Notifications::System ¬ifications() {
|
[[nodiscard]] Window::Notifications::System ¬ifications() {
|
||||||
return *_notifications;
|
return *_notifications;
|
||||||
}
|
}
|
||||||
|
[[nodiscard]] Data::Changes &changes() {
|
||||||
|
return *_changes;
|
||||||
|
}
|
||||||
[[nodiscard]] Data::Session &data() {
|
[[nodiscard]] Data::Session &data() {
|
||||||
return *_data;
|
return *_data;
|
||||||
}
|
}
|
||||||
|
@ -164,6 +166,7 @@ private:
|
||||||
const std::unique_ptr<Window::Notifications::System> _notifications;
|
const std::unique_ptr<Window::Notifications::System> _notifications;
|
||||||
|
|
||||||
// _data depends on _downloader / _uploader / _notifications.
|
// _data depends on _downloader / _uploader / _notifications.
|
||||||
|
const std::unique_ptr<Data::Changes> _changes;
|
||||||
const std::unique_ptr<Data::Session> _data;
|
const std::unique_ptr<Data::Session> _data;
|
||||||
const not_null<UserData*> _user;
|
const not_null<UserData*> _user;
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "chat_helpers/message_field.h"
|
#include "chat_helpers/message_field.h"
|
||||||
#include "info/info_memento.h"
|
#include "info/info_memento.h"
|
||||||
#include "info/info_controller.h"
|
#include "info/info_controller.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "dialogs/dialogs_widget.h"
|
#include "dialogs/dialogs_widget.h"
|
||||||
#include "dialogs/dialogs_key.h"
|
#include "dialogs/dialogs_key.h"
|
||||||
|
@ -241,9 +240,9 @@ MainWidget::MainWidget(
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
// Load current userpic and keep it loaded.
|
// Load current userpic and keep it loaded.
|
||||||
Notify::PeerUpdateValue(
|
session().changes().peerFlagsValue(
|
||||||
session().user(),
|
session().user(),
|
||||||
Notify::PeerUpdate::Flag::PhotoChanged
|
Data::PeerUpdate::Flag::Photo
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
[[maybe_unused]] const auto image = session().user()->currentUserpic(
|
[[maybe_unused]] const auto image = session().user()->currentUserpic(
|
||||||
_selfUserpicView);
|
_selfUserpicView);
|
||||||
|
@ -253,7 +252,6 @@ MainWidget::MainWidget(
|
||||||
setupConnectingWidget();
|
setupConnectingWidget();
|
||||||
|
|
||||||
connect(_dialogs, SIGNAL(cancelled()), this, SLOT(dialogsCancelled()));
|
connect(_dialogs, SIGNAL(cancelled()), this, SLOT(dialogsCancelled()));
|
||||||
connect(this, SIGNAL(dialogsUpdated()), _dialogs, SLOT(onListScroll()));
|
|
||||||
connect(_history, &HistoryWidget::cancelled, [=] { handleHistoryBack(); });
|
connect(_history, &HistoryWidget::cancelled, [=] { handleHistoryBack(); });
|
||||||
|
|
||||||
Media::Player::instance()->updatedNotifier(
|
Media::Player::instance()->updatedNotifier(
|
||||||
|
@ -283,6 +281,16 @@ MainWidget::MainWidget(
|
||||||
[this] { updateControlsGeometry(); },
|
[this] { updateControlsGeometry(); },
|
||||||
lifetime());
|
lifetime());
|
||||||
|
|
||||||
|
session().data().newMessageSent(
|
||||||
|
) | rpl::start_with_next([=](not_null<History*> history) {
|
||||||
|
history->forgetScrollState();
|
||||||
|
if (const auto from = history->peer->migrateFrom()) {
|
||||||
|
if (const auto migrated = history->owner().historyLoaded(from)) {
|
||||||
|
migrated->forgetScrollState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
// MSVC BUG + REGRESSION rpl::mappers::tuple :(
|
// MSVC BUG + REGRESSION rpl::mappers::tuple :(
|
||||||
using namespace rpl::mappers;
|
using namespace rpl::mappers;
|
||||||
_controller->activeChatValue(
|
_controller->activeChatValue(
|
||||||
|
@ -542,29 +550,6 @@ bool MainWidget::inlineSwitchChosen(PeerId peerId, const QString &botAndQuery) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::cancelForwarding(not_null<History*> history) {
|
|
||||||
history->setForwardDraft({});
|
|
||||||
_history->updateForwarding();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWidget::finishForwarding(Api::SendAction action) {
|
|
||||||
const auto history = action.history;
|
|
||||||
auto toForward = history->validateForwardDraft();
|
|
||||||
if (!toForward.empty()) {
|
|
||||||
const auto error = GetErrorTextForSending(history->peer, toForward);
|
|
||||||
if (!error.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
session().api().forwardMessages(std::move(toForward), action);
|
|
||||||
cancelForwarding(history);
|
|
||||||
}
|
|
||||||
|
|
||||||
session().data().sendHistoryChangeNotifications();
|
|
||||||
historyToDown(history);
|
|
||||||
dialogsToUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MainWidget::sendPaths(PeerId peerId) {
|
bool MainWidget::sendPaths(PeerId peerId) {
|
||||||
Expects(peerId != 0);
|
Expects(peerId != 0);
|
||||||
|
|
||||||
|
@ -1989,10 +1974,6 @@ void MainWidget::windowShown() {
|
||||||
_history->windowShown();
|
_history->windowShown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::historyToDown(History *history) {
|
|
||||||
_history->historyToDown(history);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWidget::dialogsToUp() {
|
void MainWidget::dialogsToUp() {
|
||||||
_dialogs->jumpToTop();
|
_dialogs->jumpToTop();
|
||||||
}
|
}
|
||||||
|
@ -2775,120 +2756,6 @@ void MainWidget::usernameResolveFail(const RPCError &error, const QString &usern
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::incrementSticker(DocumentData *sticker) {
|
|
||||||
if (!sticker
|
|
||||||
|| !sticker->sticker()
|
|
||||||
|| sticker->sticker()->set.type() == mtpc_inputStickerSetEmpty) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool writeRecentStickers = false;
|
|
||||||
auto &sets = session().data().stickers().setsRef();
|
|
||||||
auto it = sets.find(Data::Stickers::CloudRecentSetId);
|
|
||||||
if (it == sets.cend()) {
|
|
||||||
if (it == sets.cend()) {
|
|
||||||
it = sets.emplace(
|
|
||||||
Data::Stickers::CloudRecentSetId,
|
|
||||||
std::make_unique<Data::StickersSet>(
|
|
||||||
&session().data(),
|
|
||||||
Data::Stickers::CloudRecentSetId,
|
|
||||||
uint64(0),
|
|
||||||
tr::lng_recent_stickers(tr::now),
|
|
||||||
QString(),
|
|
||||||
0, // count
|
|
||||||
0, // hash
|
|
||||||
MTPDstickerSet_ClientFlag::f_special | 0,
|
|
||||||
TimeId(0))).first;
|
|
||||||
} else {
|
|
||||||
it->second->title = tr::lng_recent_stickers(tr::now);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const auto set = it->second.get();
|
|
||||||
auto removedFromEmoji = std::vector<not_null<EmojiPtr>>();
|
|
||||||
auto index = set->stickers.indexOf(sticker);
|
|
||||||
if (index > 0) {
|
|
||||||
if (set->dates.empty()) {
|
|
||||||
session().api().requestRecentStickersForce();
|
|
||||||
} else {
|
|
||||||
Assert(set->dates.size() == set->stickers.size());
|
|
||||||
set->dates.erase(set->dates.begin() + index);
|
|
||||||
}
|
|
||||||
set->stickers.removeAt(index);
|
|
||||||
for (auto i = set->emoji.begin(); i != set->emoji.end();) {
|
|
||||||
if (const auto index = i->indexOf(sticker); index >= 0) {
|
|
||||||
removedFromEmoji.emplace_back(i.key());
|
|
||||||
i->removeAt(index);
|
|
||||||
if (i->isEmpty()) {
|
|
||||||
i = set->emoji.erase(i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (index) {
|
|
||||||
if (set->dates.size() == set->stickers.size()) {
|
|
||||||
set->dates.insert(set->dates.begin(), base::unixtime::now());
|
|
||||||
}
|
|
||||||
set->stickers.push_front(sticker);
|
|
||||||
if (const auto emojiList = session().data().stickers().getEmojiListFromSet(sticker)) {
|
|
||||||
for (const auto emoji : *emojiList) {
|
|
||||||
set->emoji[emoji].push_front(sticker);
|
|
||||||
}
|
|
||||||
} else if (!removedFromEmoji.empty()) {
|
|
||||||
for (const auto emoji : removedFromEmoji) {
|
|
||||||
set->emoji[emoji].push_front(sticker);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
session().api().requestRecentStickersForce();
|
|
||||||
}
|
|
||||||
|
|
||||||
writeRecentStickers = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove that sticker from old recent, now it is in cloud recent stickers.
|
|
||||||
bool writeOldRecent = false;
|
|
||||||
auto &recent = session().data().stickers().getRecentPack();
|
|
||||||
for (auto i = recent.begin(), e = recent.end(); i != e; ++i) {
|
|
||||||
if (i->first == sticker) {
|
|
||||||
writeOldRecent = true;
|
|
||||||
recent.erase(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (!recent.isEmpty() && set->stickers.size() + recent.size() > Global::StickersRecentLimit()) {
|
|
||||||
writeOldRecent = true;
|
|
||||||
recent.pop_back();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (writeOldRecent) {
|
|
||||||
session().local().writeSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove that sticker from custom stickers, now it is in cloud recent stickers.
|
|
||||||
bool writeInstalledStickers = false;
|
|
||||||
auto customIt = sets.find(Data::Stickers::CustomSetId);
|
|
||||||
if (customIt != sets.cend()) {
|
|
||||||
const auto custom = customIt->second.get();
|
|
||||||
int removeIndex = custom->stickers.indexOf(sticker);
|
|
||||||
if (removeIndex >= 0) {
|
|
||||||
custom->stickers.removeAt(removeIndex);
|
|
||||||
if (custom->stickers.isEmpty()) {
|
|
||||||
sets.erase(customIt);
|
|
||||||
}
|
|
||||||
writeInstalledStickers = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (writeInstalledStickers) {
|
|
||||||
session().local().writeInstalledStickers();
|
|
||||||
}
|
|
||||||
if (writeRecentStickers) {
|
|
||||||
session().local().writeRecentStickers();
|
|
||||||
}
|
|
||||||
_controller->tabbedSelector()->refreshStickers();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWidget::activate() {
|
void MainWidget::activate() {
|
||||||
if (_a_show.animating()) {
|
if (_a_show.animating()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -32,10 +32,6 @@ namespace Main {
|
||||||
class Session;
|
class Session;
|
||||||
} // namespace Main
|
} // namespace Main
|
||||||
|
|
||||||
namespace Notify {
|
|
||||||
struct PeerUpdate;
|
|
||||||
} // namespace Notify
|
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
class WallPaper;
|
class WallPaper;
|
||||||
class CloudImageView;
|
class CloudImageView;
|
||||||
|
@ -131,9 +127,6 @@ public:
|
||||||
FullMsgId clickFromMessageId = FullMsgId());
|
FullMsgId clickFromMessageId = FullMsgId());
|
||||||
|
|
||||||
bool started();
|
bool started();
|
||||||
|
|
||||||
void incrementSticker(DocumentData *sticker);
|
|
||||||
|
|
||||||
void activate();
|
void activate();
|
||||||
|
|
||||||
void refreshDialog(Dialogs::Key key);
|
void refreshDialog(Dialogs::Key key);
|
||||||
|
@ -144,7 +137,6 @@ public:
|
||||||
|
|
||||||
void windowShown();
|
void windowShown();
|
||||||
|
|
||||||
void historyToDown(History *hist);
|
|
||||||
void dialogsToUp();
|
void dialogsToUp();
|
||||||
void checkHistoryActivation();
|
void checkHistoryActivation();
|
||||||
|
|
||||||
|
@ -226,9 +218,6 @@ public:
|
||||||
|
|
||||||
void pushReplyReturn(not_null<HistoryItem*> item);
|
void pushReplyReturn(not_null<HistoryItem*> item);
|
||||||
|
|
||||||
void cancelForwarding(not_null<History*> history);
|
|
||||||
void finishForwarding(Api::SendAction action);
|
|
||||||
|
|
||||||
// Does offerPeer or showPeerHistory.
|
// Does offerPeer or showPeerHistory.
|
||||||
void choosePeer(PeerId peerId, MsgId showAtMsgId);
|
void choosePeer(PeerId peerId, MsgId showAtMsgId);
|
||||||
void clearBotStartToken(PeerData *peer);
|
void clearBotStartToken(PeerData *peer);
|
||||||
|
@ -260,9 +249,6 @@ public:
|
||||||
|
|
||||||
void closeBothPlayers();
|
void closeBothPlayers();
|
||||||
|
|
||||||
signals:
|
|
||||||
void dialogsUpdated();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void inlineResultLoadProgress(FileLoader *loader);
|
void inlineResultLoadProgress(FileLoader *loader);
|
||||||
void inlineResultLoadFailed(FileLoader *loader, bool started);
|
void inlineResultLoadFailed(FileLoader *loader, bool started);
|
||||||
|
|
|
@ -32,7 +32,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
#include "boxes/add_contact_box.h"
|
#include "boxes/add_contact_box.h"
|
||||||
#include "boxes/connection_box.h"
|
#include "boxes/connection_box.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "storage/storage_account.h"
|
#include "storage/storage_account.h"
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
|
|
|
@ -49,7 +49,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_account.h" // Account::sessionValue.
|
#include "main/main_account.h" // Account::sessionValue.
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "storage/file_download.h"
|
#include "storage/file_download.h"
|
||||||
|
|
|
@ -34,10 +34,6 @@ struct Preview;
|
||||||
} // namespace Theme
|
} // namespace Theme
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
||||||
namespace Notify {
|
|
||||||
struct PeerUpdate;
|
|
||||||
} // namespace Notify
|
|
||||||
|
|
||||||
namespace Media {
|
namespace Media {
|
||||||
namespace Player {
|
namespace Player {
|
||||||
struct TrackState;
|
struct TrackState;
|
||||||
|
|
|
@ -1,129 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Telegram Desktop,
|
|
||||||
the official desktop application for the Telegram messaging service.
|
|
||||||
|
|
||||||
For license and copyright information please follow this link:
|
|
||||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
||||||
*/
|
|
||||||
#include "observer_peer.h"
|
|
||||||
|
|
||||||
#include "base/observer.h"
|
|
||||||
#include "facades.h"
|
|
||||||
|
|
||||||
namespace Notify {
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
using SmallUpdatesList = QVector<PeerUpdate>;
|
|
||||||
NeverFreedPointer<SmallUpdatesList> SmallUpdates;
|
|
||||||
using AllUpdatesList = QMap<PeerData*, PeerUpdate>;
|
|
||||||
NeverFreedPointer<AllUpdatesList> AllUpdates;
|
|
||||||
|
|
||||||
void StartCallback() {
|
|
||||||
SmallUpdates.createIfNull();
|
|
||||||
AllUpdates.createIfNull();
|
|
||||||
}
|
|
||||||
void FinishCallback() {
|
|
||||||
SmallUpdates.clear();
|
|
||||||
AllUpdates.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
base::Observable<PeerUpdate, PeerUpdatedHandler> PeerUpdatedObservable;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void mergePeerUpdate(PeerUpdate &mergeTo, const PeerUpdate &mergeFrom) {
|
|
||||||
if (!(mergeTo.flags & PeerUpdate::Flag::NameChanged)) {
|
|
||||||
if (mergeFrom.flags & PeerUpdate::Flag::NameChanged) {
|
|
||||||
mergeTo.oldNameFirstLetters = mergeFrom.oldNameFirstLetters;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mergeTo.flags |= mergeFrom.flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
void peerUpdatedDelayed(const PeerUpdate &update) {
|
|
||||||
SmallUpdates.createIfNull();
|
|
||||||
AllUpdates.createIfNull();
|
|
||||||
|
|
||||||
Global::RefHandleDelayedPeerUpdates().call();
|
|
||||||
|
|
||||||
int existingUpdatesCount = SmallUpdates->size();
|
|
||||||
for (int i = 0; i < existingUpdatesCount; ++i) {
|
|
||||||
auto &existingUpdate = (*SmallUpdates)[i];
|
|
||||||
if (existingUpdate.peer == update.peer) {
|
|
||||||
mergePeerUpdate(existingUpdate, update);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AllUpdates->isEmpty()) {
|
|
||||||
if (existingUpdatesCount < 5) {
|
|
||||||
SmallUpdates->push_back(update);
|
|
||||||
} else {
|
|
||||||
AllUpdates->insert(update.peer, update);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
auto it = AllUpdates->find(update.peer);
|
|
||||||
if (it != AllUpdates->cend()) {
|
|
||||||
mergePeerUpdate(it.value(), update);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
AllUpdates->insert(update.peer, update);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void peerUpdatedSendDelayed() {
|
|
||||||
if (!SmallUpdates || !AllUpdates || SmallUpdates->empty()) return;
|
|
||||||
|
|
||||||
auto smallList = base::take(*SmallUpdates);
|
|
||||||
auto allList = base::take(*AllUpdates);
|
|
||||||
for (auto &update : smallList) {
|
|
||||||
PeerUpdated().notify(std::move(update), true);
|
|
||||||
}
|
|
||||||
for (auto &update : allList) {
|
|
||||||
PeerUpdated().notify(std::move(update), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SmallUpdates->isEmpty()) {
|
|
||||||
std::swap(smallList, *SmallUpdates);
|
|
||||||
SmallUpdates->resize(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
base::Observable<PeerUpdate, PeerUpdatedHandler> &PeerUpdated() {
|
|
||||||
return PeerUpdatedObservable;
|
|
||||||
}
|
|
||||||
|
|
||||||
rpl::producer<PeerUpdate> PeerUpdateViewer(
|
|
||||||
PeerUpdate::Flags flags) {
|
|
||||||
return [=](const auto &consumer) {
|
|
||||||
auto lifetime = rpl::lifetime();
|
|
||||||
lifetime.make_state<base::Subscription>(
|
|
||||||
PeerUpdated().add_subscription({ flags, [=](
|
|
||||||
const PeerUpdate &update) {
|
|
||||||
consumer.put_next_copy(update);
|
|
||||||
}}));
|
|
||||||
return lifetime;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
rpl::producer<PeerUpdate> PeerUpdateViewer(
|
|
||||||
not_null<PeerData*> peer,
|
|
||||||
PeerUpdate::Flags flags) {
|
|
||||||
return PeerUpdateViewer(
|
|
||||||
flags
|
|
||||||
) | rpl::filter([=](const PeerUpdate &update) {
|
|
||||||
return (update.peer == peer);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
rpl::producer<PeerUpdate> PeerUpdateValue(
|
|
||||||
not_null<PeerData*> peer,
|
|
||||||
PeerUpdate::Flags flags) {
|
|
||||||
auto initial = PeerUpdate(peer);
|
|
||||||
initial.flags = flags;
|
|
||||||
return rpl::single(
|
|
||||||
initial
|
|
||||||
) | rpl::then(PeerUpdateViewer(peer, flags));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Notify
|
|
|
@ -1,123 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Telegram Desktop,
|
|
||||||
the official desktop application for the Telegram messaging service.
|
|
||||||
|
|
||||||
For license and copyright information please follow this link:
|
|
||||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <rpl/producer.h>
|
|
||||||
#include <rpl/filter.h>
|
|
||||||
#include <rpl/then.h>
|
|
||||||
#include <rpl/range.h>
|
|
||||||
#include "base/observer.h"
|
|
||||||
#include "base/flags.h"
|
|
||||||
|
|
||||||
namespace Notify {
|
|
||||||
|
|
||||||
// Generic notifications about updates of some PeerData.
|
|
||||||
// You can subscribe to them by Notify::registerPeerObserver().
|
|
||||||
// 0x0000FFFFU for general peer updates (valid for any peer).
|
|
||||||
// 0xFFFF0000U for specific peer updates (valid for user / chat / channel).
|
|
||||||
struct PeerUpdate {
|
|
||||||
PeerUpdate(PeerData *updated = nullptr) : peer(updated) {
|
|
||||||
}
|
|
||||||
PeerData *peer;
|
|
||||||
|
|
||||||
enum class Flag : uint32 {
|
|
||||||
None = 0,
|
|
||||||
|
|
||||||
// Common flags
|
|
||||||
NameChanged = (1 << 0),
|
|
||||||
UsernameChanged = (1 << 1),
|
|
||||||
PhotoChanged = (1 << 2),
|
|
||||||
AboutChanged = (1 << 3),
|
|
||||||
NotificationsEnabled = (1 << 4),
|
|
||||||
MigrationChanged = (1 << 6),
|
|
||||||
ChatPinnedChanged = (1 << 7),
|
|
||||||
UnavailableReasonChanged = (1 << 8),
|
|
||||||
UnreadViewChanged = (1 << 9),
|
|
||||||
PinnedMessageChanged = (1 << 10),
|
|
||||||
TopPromotedChanged = (1 << 11),
|
|
||||||
FolderChanged = (1 << 12),
|
|
||||||
|
|
||||||
// For chats and channels
|
|
||||||
InviteLinkChanged = (1 << 13),
|
|
||||||
MembersChanged = (1 << 14),
|
|
||||||
AdminsChanged = (1 << 15),
|
|
||||||
BannedUsersChanged = (1 << 16),
|
|
||||||
UnreadMentionsChanged = (1 << 17),
|
|
||||||
RightsChanged = (1 << 18),
|
|
||||||
|
|
||||||
// For users
|
|
||||||
UserCanShareContact = (1 << 19),
|
|
||||||
UserIsContact = (1 << 20),
|
|
||||||
UserPhoneChanged = (1 << 21),
|
|
||||||
UserIsBlocked = (1 << 22),
|
|
||||||
BotCommandsChanged = (1 << 23),
|
|
||||||
UserOnlineChanged = (1 << 24),
|
|
||||||
BotCanAddToGroups = (1 << 25),
|
|
||||||
UserCommonChatsChanged = (1 << 26),
|
|
||||||
UserHasCalls = (1 << 27),
|
|
||||||
UserOccupiedChanged = (1 << 28),
|
|
||||||
UserSupportInfoChanged = (1 << 29),
|
|
||||||
UserIsBotChanged = (1 << 30),
|
|
||||||
|
|
||||||
// For channels
|
|
||||||
ChannelAmIn = (1 << 19),
|
|
||||||
ChannelStickersChanged = (1 << 20),
|
|
||||||
ChannelPromotedChanged = (1 << 21),
|
|
||||||
ChannelLinkedChat = (1 << 22),
|
|
||||||
ChannelLocation = (1 << 23),
|
|
||||||
ChannelSlowmode = (1 << 24),
|
|
||||||
ChannelLocalMessages = (1 << 25),
|
|
||||||
};
|
|
||||||
using Flags = base::flags<Flag>;
|
|
||||||
friend inline constexpr auto is_flag_type(Flag) { return true; }
|
|
||||||
|
|
||||||
Flags flags = 0;
|
|
||||||
|
|
||||||
// NameChanged data
|
|
||||||
base::flat_set<QChar> oldNameFirstLetters;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
void peerUpdatedDelayed(const PeerUpdate &update);
|
|
||||||
inline void peerUpdatedDelayed(PeerData *peer, PeerUpdate::Flags events) {
|
|
||||||
PeerUpdate update(peer);
|
|
||||||
update.flags = events;
|
|
||||||
peerUpdatedDelayed(update);
|
|
||||||
}
|
|
||||||
void peerUpdatedSendDelayed();
|
|
||||||
|
|
||||||
class PeerUpdatedHandler {
|
|
||||||
public:
|
|
||||||
template <typename Lambda>
|
|
||||||
PeerUpdatedHandler(PeerUpdate::Flags events, Lambda &&handler) : _events(events), _handler(std::move(handler)) {
|
|
||||||
}
|
|
||||||
void operator()(const PeerUpdate &update) const {
|
|
||||||
if (update.flags & _events) {
|
|
||||||
_handler(update);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
PeerUpdate::Flags _events;
|
|
||||||
Fn<void(const PeerUpdate&)> _handler;
|
|
||||||
|
|
||||||
};
|
|
||||||
base::Observable<PeerUpdate, PeerUpdatedHandler> &PeerUpdated();
|
|
||||||
|
|
||||||
rpl::producer<PeerUpdate> PeerUpdateViewer(
|
|
||||||
PeerUpdate::Flags flags);
|
|
||||||
|
|
||||||
rpl::producer<PeerUpdate> PeerUpdateViewer(
|
|
||||||
not_null<PeerData*> peer,
|
|
||||||
PeerUpdate::Flags flags);
|
|
||||||
|
|
||||||
rpl::producer<PeerUpdate> PeerUpdateValue(
|
|
||||||
not_null<PeerData*> peer,
|
|
||||||
PeerUpdate::Flags flags);
|
|
||||||
|
|
||||||
} // namespace Notify
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "data/data_file_origin.h"
|
#include "data/data_file_origin.h"
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_cloud_file.h"
|
#include "data/data_cloud_file.h"
|
||||||
#include "data/stickers/data_stickers.h"
|
#include "data/stickers/data_stickers.h"
|
||||||
|
@ -30,7 +31,6 @@
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "base/platform/mac/base_utilities_mac.h"
|
#include "base/platform/mac/base_utilities_mac.h"
|
||||||
#include "styles/style_dialogs.h"
|
#include "styles/style_dialogs.h"
|
||||||
#include "styles/style_media_player.h"
|
#include "styles/style_media_player.h"
|
||||||
|
@ -576,24 +576,24 @@ void AppendEmojiPacks(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_userpicView = _peer->createUserpicView();
|
_userpicView = _peer->createUserpicView();
|
||||||
Notify::PeerUpdateViewer(
|
_peer->session().changes().peerUpdates(
|
||||||
_peer,
|
_peer,
|
||||||
Notify::PeerUpdate::Flag::PhotoChanged
|
Data::PeerUpdate::Flag::Photo
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
isWaitingUserpicLoad = true;
|
isWaitingUserpicLoad = true;
|
||||||
[self updateUserpic];
|
[self updateUserpic];
|
||||||
}, _peerChangedLifetime);
|
}, _peerChangedLifetime);
|
||||||
|
|
||||||
Notify::PeerUpdateViewer(
|
_peer->session().changes().historyUpdates(
|
||||||
_peer,
|
_peer->session().history(_peer),
|
||||||
Notify::PeerUpdate::Flag::UnreadViewChanged
|
Data::HistoryUpdate::Flag::UnreadView
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
[self updateBadge];
|
[self updateBadge];
|
||||||
}, _peerChangedLifetime);
|
}, _peerChangedLifetime);
|
||||||
|
|
||||||
Notify::PeerUpdateViewer(
|
_peer->session().changes().peerUpdates(
|
||||||
_peer,
|
_peer,
|
||||||
Notify::PeerUpdate::Flag::UserOnlineChanged
|
Data::PeerUpdate::Flag::OnlineStatus
|
||||||
) | rpl::filter([=] {
|
) | rpl::filter([=] {
|
||||||
return UnreadCount(_peer) == 0;
|
return UnreadCount(_peer) == 0;
|
||||||
}) | rpl::start_with_next([=] {
|
}) | rpl::start_with_next([=] {
|
||||||
|
|
|
@ -18,9 +18,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
|
@ -28,7 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Profile {
|
namespace Profile {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using UpdateFlag = Notify::PeerUpdate::Flag;
|
using UpdateFlag = Data::PeerUpdate::Flag;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -41,18 +41,19 @@ not_null<UserData*> GroupMembersWidget::Member::user() const {
|
||||||
|
|
||||||
GroupMembersWidget::GroupMembersWidget(
|
GroupMembersWidget::GroupMembersWidget(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
PeerData *peer,
|
not_null<PeerData*> peer,
|
||||||
const style::PeerListItem &st)
|
const style::PeerListItem &st)
|
||||||
: PeerListWidget(parent, peer, QString(), st, tr::lng_profile_kick(tr::now)) {
|
: PeerListWidget(parent, peer, QString(), st, tr::lng_profile_kick(tr::now)) {
|
||||||
_updateOnlineTimer.setSingleShot(true);
|
_updateOnlineTimer.setSingleShot(true);
|
||||||
connect(&_updateOnlineTimer, SIGNAL(timeout()), this, SLOT(onUpdateOnlineDisplay()));
|
connect(&_updateOnlineTimer, SIGNAL(timeout()), this, SLOT(onUpdateOnlineDisplay()));
|
||||||
|
|
||||||
auto observeEvents = UpdateFlag::AdminsChanged
|
peer->session().changes().peerUpdates(
|
||||||
| UpdateFlag::MembersChanged
|
UpdateFlag::Admins
|
||||||
| UpdateFlag::UserOnlineChanged;
|
| UpdateFlag::Members
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) {
|
| UpdateFlag::OnlineStatus
|
||||||
|
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
|
||||||
notifyPeerUpdated(update);
|
notifyPeerUpdated(update);
|
||||||
}));
|
}, lifetime());
|
||||||
|
|
||||||
setRemovedCallback([=](PeerData *selectedPeer) {
|
setRemovedCallback([=](PeerData *selectedPeer) {
|
||||||
removePeer(selectedPeer);
|
removePeer(selectedPeer);
|
||||||
|
@ -104,9 +105,9 @@ void GroupMembersWidget::removePeer(PeerData *selectedPeer) {
|
||||||
crl::guard(&peer->session(), callback)));
|
crl::guard(&peer->session(), callback)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupMembersWidget::notifyPeerUpdated(const Notify::PeerUpdate &update) {
|
void GroupMembersWidget::notifyPeerUpdated(const Data::PeerUpdate &update) {
|
||||||
if (update.peer != peer()) {
|
if (update.peer != peer()) {
|
||||||
if (update.flags & UpdateFlag::UserOnlineChanged) {
|
if (update.flags & UpdateFlag::OnlineStatus) {
|
||||||
if (auto user = update.peer->asUser()) {
|
if (auto user = update.peer->asUser()) {
|
||||||
refreshUserOnline(user);
|
refreshUserOnline(user);
|
||||||
}
|
}
|
||||||
|
@ -114,11 +115,11 @@ void GroupMembersWidget::notifyPeerUpdated(const Notify::PeerUpdate &update) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update.flags & UpdateFlag::MembersChanged) {
|
if (update.flags & UpdateFlag::Members) {
|
||||||
refreshMembers();
|
refreshMembers();
|
||||||
contentSizeUpdated();
|
contentSizeUpdated();
|
||||||
}
|
}
|
||||||
if (update.flags & UpdateFlag::AdminsChanged) {
|
if (update.flags & UpdateFlag::Admins) {
|
||||||
if (const auto chat = peer()->asChat()) {
|
if (const auto chat = peer()->asChat()) {
|
||||||
for (const auto item : items()) {
|
for (const auto item : items()) {
|
||||||
setItemFlags(getMember(item), chat);
|
setItemFlags(getMember(item), chat);
|
||||||
|
|
|
@ -15,9 +15,9 @@ namespace Ui {
|
||||||
class FlatLabel;
|
class FlatLabel;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Notify {
|
namespace Data {
|
||||||
struct PeerUpdate;
|
struct PeerUpdate;
|
||||||
} // namespace Notify
|
} // namespace Data
|
||||||
|
|
||||||
namespace Profile {
|
namespace Profile {
|
||||||
|
|
||||||
|
@ -25,7 +25,10 @@ class GroupMembersWidget : public PeerListWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GroupMembersWidget(QWidget *parent, PeerData *peer, const style::PeerListItem &st);
|
GroupMembersWidget(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const style::PeerListItem &st);
|
||||||
|
|
||||||
int onlineCount() const {
|
int onlineCount() const {
|
||||||
return _onlineCount;
|
return _onlineCount;
|
||||||
|
@ -41,7 +44,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Observed notifications.
|
// Observed notifications.
|
||||||
void notifyPeerUpdated(const Notify::PeerUpdate &update);
|
void notifyPeerUpdated(const Data::PeerUpdate &update);
|
||||||
|
|
||||||
void removePeer(PeerData *selectedPeer);
|
void removePeer(PeerData *selectedPeer);
|
||||||
void refreshMembers();
|
void refreshMembers();
|
||||||
|
|
|
@ -18,10 +18,6 @@ class RippleAnimation;
|
||||||
class PopupMenu;
|
class PopupMenu;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Notify {
|
|
||||||
struct PeerUpdate;
|
|
||||||
} // namespace Notify
|
|
||||||
|
|
||||||
namespace style {
|
namespace style {
|
||||||
struct PeerListItem;
|
struct PeerListItem;
|
||||||
} // namespace style
|
} // namespace style
|
||||||
|
|
|
@ -10,11 +10,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "settings/settings_common.h"
|
#include "settings/settings_common.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "history/admin_log/history_admin_log_item.h"
|
#include "history/admin_log/history_admin_log_item.h"
|
||||||
#include "history/view/history_view_element.h"
|
#include "history/view/history_view_element.h"
|
||||||
#include "history/view/history_view_message.h"
|
#include "history/view/history_view_message.h"
|
||||||
|
@ -86,14 +86,16 @@ Main::Session &BlockUserBoxController::session() const {
|
||||||
|
|
||||||
void BlockUserBoxController::prepareViewHook() {
|
void BlockUserBoxController::prepareViewHook() {
|
||||||
delegate()->peerListSetTitle(tr::lng_blocked_list_add_title());
|
delegate()->peerListSetTitle(tr::lng_blocked_list_add_title());
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::UserIsBlocked, [this](const Notify::PeerUpdate &update) {
|
session().changes().peerUpdates(
|
||||||
if (auto user = update.peer->asUser()) {
|
Data::PeerUpdate::Flag::IsBlocked
|
||||||
|
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
|
||||||
|
if (const auto user = update.peer->asUser()) {
|
||||||
if (auto row = delegate()->peerListFindRow(user->id)) {
|
if (auto row = delegate()->peerListFindRow(user->id)) {
|
||||||
updateIsBlocked(row, user);
|
updateIsBlocked(row, user);
|
||||||
delegate()->peerListUpdateRow(row);
|
delegate()->peerListUpdateRow(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockUserBoxController::updateIsBlocked(not_null<PeerListRow*> row, UserData *user) const {
|
void BlockUserBoxController::updateIsBlocked(not_null<PeerListRow*> row, UserData *user) const {
|
||||||
|
@ -192,11 +194,13 @@ void BlockedBoxController::prepare() {
|
||||||
setDescriptionText(tr::lng_contacts_loading(tr::now));
|
setDescriptionText(tr::lng_contacts_loading(tr::now));
|
||||||
delegate()->peerListRefreshRows();
|
delegate()->peerListRefreshRows();
|
||||||
|
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::UserIsBlocked, [this](const Notify::PeerUpdate &update) {
|
session().changes().peerUpdates(
|
||||||
|
Data::PeerUpdate::Flag::IsBlocked
|
||||||
|
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
|
||||||
if (const auto user = update.peer->asUser()) {
|
if (const auto user = update.peer->asUser()) {
|
||||||
handleBlockedEvent(user);
|
handleBlockedEvent(user);
|
||||||
}
|
}
|
||||||
}));
|
}, lifetime());
|
||||||
|
|
||||||
_loadRequestId = -1;
|
_loadRequestId = -1;
|
||||||
_window->session().api().blockedUsersSlice(
|
_window->session().api().blockedUsersSlice(
|
||||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_drafts.h"
|
#include "data/data_drafts.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "api/api_text_entities.h"
|
#include "api/api_text_entities.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
|
@ -27,7 +28,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "storage/localimageloader.h"
|
#include "storage/localimageloader.h"
|
||||||
#include "core/sandbox.h"
|
#include "core/sandbox.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
|
@ -334,14 +334,14 @@ void Helper::cloudDraftChanged(not_null<History*> history) {
|
||||||
void Helper::chatOccupiedUpdated(not_null<History*> history) {
|
void Helper::chatOccupiedUpdated(not_null<History*> history) {
|
||||||
if (const auto till = OccupiedBySomeoneTill(history)) {
|
if (const auto till = OccupiedBySomeoneTill(history)) {
|
||||||
_occupiedChats[history] = till + 2;
|
_occupiedChats[history] = till + 2;
|
||||||
Notify::peerUpdatedDelayed(
|
history->session().changes().historyUpdated(
|
||||||
history->peer,
|
history,
|
||||||
Notify::PeerUpdate::Flag::UserOccupiedChanged);
|
Data::HistoryUpdate::Flag::ChatOccupied);
|
||||||
checkOccupiedChats();
|
checkOccupiedChats();
|
||||||
} else if (_occupiedChats.take(history)) {
|
} else if (_occupiedChats.take(history)) {
|
||||||
Notify::peerUpdatedDelayed(
|
history->session().changes().historyUpdated(
|
||||||
history->peer,
|
history,
|
||||||
Notify::PeerUpdate::Flag::UserOccupiedChanged);
|
Data::HistoryUpdate::Flag::ChatOccupied);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,9 +355,9 @@ void Helper::checkOccupiedChats() {
|
||||||
if (nearest->second <= now) {
|
if (nearest->second <= now) {
|
||||||
const auto history = nearest->first;
|
const auto history = nearest->first;
|
||||||
_occupiedChats.erase(nearest);
|
_occupiedChats.erase(nearest);
|
||||||
Notify::peerUpdatedDelayed(
|
history->session().changes().historyUpdated(
|
||||||
history->peer,
|
history,
|
||||||
Notify::PeerUpdate::Flag::UserOccupiedChanged);
|
Data::HistoryUpdate::Flag::ChatOccupied);
|
||||||
} else {
|
} else {
|
||||||
_checkOccupiedTimer.callOnce(
|
_checkOccupiedTimer.callOnce(
|
||||||
(nearest->second - now) * crl::time(1000));
|
(nearest->second - now) * crl::time(1000));
|
||||||
|
@ -440,9 +440,9 @@ void Helper::applyInfo(
|
||||||
not_null<UserData*> user,
|
not_null<UserData*> user,
|
||||||
const MTPhelp_UserInfo &result) {
|
const MTPhelp_UserInfo &result) {
|
||||||
const auto notify = [&] {
|
const auto notify = [&] {
|
||||||
Notify::peerUpdatedDelayed(
|
user->session().changes().peerUpdated(
|
||||||
user,
|
user,
|
||||||
Notify::PeerUpdate::Flag::UserSupportInfoChanged);
|
Data::PeerUpdate::Flag::SupportInfo);
|
||||||
};
|
};
|
||||||
const auto remove = [&] {
|
const auto remove = [&] {
|
||||||
if (_userInformation.take(user)) {
|
if (_userInformation.take(user)) {
|
||||||
|
@ -468,9 +468,9 @@ void Helper::applyInfo(
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<UserInfo> Helper::infoValue(not_null<UserData*> user) const {
|
rpl::producer<UserInfo> Helper::infoValue(not_null<UserData*> user) const {
|
||||||
return Notify::PeerUpdateValue(
|
return user->session().changes().peerFlagsValue(
|
||||||
user,
|
user,
|
||||||
Notify::PeerUpdate::Flag::UserSupportInfoChanged
|
Data::PeerUpdate::Flag::SupportInfo
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return infoCurrent(user);
|
return infoCurrent(user);
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_cloud_file.h"
|
#include "data/data_cloud_file.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "core/file_utilities.h"
|
#include "core/file_utilities.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
|
@ -30,7 +31,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
|
@ -631,9 +631,9 @@ void UserpicButton::openPeerPhoto() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserpicButton::setupPeerViewers() {
|
void UserpicButton::setupPeerViewers() {
|
||||||
Notify::PeerUpdateViewer(
|
_peer->session().changes().peerUpdates(
|
||||||
_peer,
|
_peer,
|
||||||
Notify::PeerUpdate::Flag::PhotoChanged
|
Data::PeerUpdate::Flag::Photo
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
processNewPeerPhoto();
|
processNewPeerPhoto();
|
||||||
update();
|
update();
|
||||||
|
@ -653,6 +653,7 @@ void UserpicButton::setupPeerViewers() {
|
||||||
|
|
||||||
void UserpicButton::paintEvent(QPaintEvent *e) {
|
void UserpicButton::paintEvent(QPaintEvent *e) {
|
||||||
Painter p(this);
|
Painter p(this);
|
||||||
|
|
||||||
if (!_waiting && _notShownYet) {
|
if (!_waiting && _notShownYet) {
|
||||||
_notShownYet = false;
|
_notShownYet = false;
|
||||||
startAnimation();
|
startAnimation();
|
||||||
|
|
|
@ -27,11 +27,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "calls/calls_box_controller.h"
|
#include "calls/calls_box_controller.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
@ -213,11 +213,14 @@ MainMenu::MainMenu(
|
||||||
_version->setLink(2, std::make_shared<LambdaClickHandler>([] { Ui::show(Box<AboutBox>()); }));
|
_version->setLink(2, std::make_shared<LambdaClickHandler>([] { Ui::show(Box<AboutBox>()); }));
|
||||||
|
|
||||||
subscribe(_controller->session().downloaderTaskFinished(), [=] { update(); });
|
subscribe(_controller->session().downloaderTaskFinished(), [=] { update(); });
|
||||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::UserPhoneChanged, [this](const Notify::PeerUpdate &update) {
|
|
||||||
if (update.peer->isSelf()) {
|
_controller->session().changes().peerUpdates(
|
||||||
updatePhone();
|
_controller->session().user(),
|
||||||
}
|
Data::PeerUpdate::Flag::PhoneNumber
|
||||||
}));
|
) | rpl::start_with_next([=] {
|
||||||
|
updatePhone();
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
subscribe(Global::RefPhoneCallsEnabledChanged(), [this] { refreshMenu(); });
|
subscribe(Global::RefPhoneCallsEnabledChanged(), [this] { refreshMenu(); });
|
||||||
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &update) {
|
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &update) {
|
||||||
if (update.type == Window::Theme::BackgroundUpdate::Type::ApplyingTheme) {
|
if (update.type == Window::Theme::BackgroundUpdate::Type::ApplyingTheme) {
|
||||||
|
|
|
@ -24,7 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "observer_peer.h"
|
|
||||||
#include "api/api_common.h"
|
#include "api/api_common.h"
|
||||||
#include "api/api_chat_filters.h"
|
#include "api/api_chat_filters.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
|
@ -37,6 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "info/info_controller.h"
|
#include "info/info_controller.h"
|
||||||
//#include "info/feed/info_feed_channels_controllers.h" // #feed
|
//#include "info/feed/info_feed_channels_controllers.h" // #feed
|
||||||
#include "info/profile/info_profile_values.h"
|
#include "info/profile/info_profile_values.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
#include "data/data_poll.h"
|
#include "data/data_poll.h"
|
||||||
|
@ -306,31 +306,23 @@ void Filler::addHidePromotion() {
|
||||||
void Filler::addTogglePin() {
|
void Filler::addTogglePin() {
|
||||||
const auto filterId = _filterId;
|
const auto filterId = _filterId;
|
||||||
const auto peer = _peer;
|
const auto peer = _peer;
|
||||||
auto isPinned = false;
|
const auto history = peer->owner().history(peer);
|
||||||
if (const auto history = peer->owner().historyLoaded(peer)) {
|
const auto pinText = [=] {
|
||||||
isPinned = history->isPinnedDialog(filterId);
|
return history->isPinnedDialog(filterId)
|
||||||
}
|
|
||||||
const auto pinText = [](bool isPinned) {
|
|
||||||
return isPinned
|
|
||||||
? tr::lng_context_unpin_from_top(tr::now)
|
? tr::lng_context_unpin_from_top(tr::now)
|
||||||
: tr::lng_context_pin_to_top(tr::now);
|
: tr::lng_context_pin_to_top(tr::now);
|
||||||
};
|
};
|
||||||
const auto pinToggle = [=] {
|
const auto pinToggle = [=] {
|
||||||
TogglePinnedDialog(
|
TogglePinnedDialog(_controller, history, filterId);
|
||||||
_controller,
|
|
||||||
peer->owner().history(peer),
|
|
||||||
filterId);
|
|
||||||
};
|
};
|
||||||
const auto pinAction = _addAction(pinText(isPinned), pinToggle);
|
const auto pinAction = _addAction(pinText(), pinToggle);
|
||||||
|
|
||||||
const auto lifetime = Ui::CreateChild<rpl::lifetime>(pinAction);
|
const auto lifetime = Ui::CreateChild<rpl::lifetime>(pinAction);
|
||||||
Notify::PeerUpdateViewer(
|
history->session().changes().historyUpdates(
|
||||||
peer,
|
history,
|
||||||
Notify::PeerUpdate::Flag::ChatPinnedChanged
|
Data::HistoryUpdate::Flag::IsPinned
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
const auto history = peer->owner().history(peer);
|
pinAction->setText(pinText());
|
||||||
const auto isPinned = history->isPinnedDialog(filterId);
|
|
||||||
pinAction->setText(pinText(isPinned));
|
|
||||||
}, *lifetime);
|
}, *lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,20 +349,18 @@ void Filler::addInfo() {
|
||||||
|
|
||||||
void Filler::addToggleUnreadMark() {
|
void Filler::addToggleUnreadMark() {
|
||||||
const auto peer = _peer;
|
const auto peer = _peer;
|
||||||
const auto isUnread = [](not_null<PeerData*> peer) {
|
const auto history = peer->owner().history(peer);
|
||||||
if (const auto history = peer->owner().historyLoaded(peer)) {
|
const auto isUnread = [=] {
|
||||||
return (history->chatListUnreadCount() > 0)
|
return (history->chatListUnreadCount() > 0)
|
||||||
|| (history->chatListUnreadMark());
|
|| (history->chatListUnreadMark());
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
const auto label = [=](not_null<PeerData*> peer) {
|
const auto label = [=] {
|
||||||
return isUnread(peer)
|
return isUnread()
|
||||||
? tr::lng_context_mark_read(tr::now)
|
? tr::lng_context_mark_read(tr::now)
|
||||||
: tr::lng_context_mark_unread(tr::now);
|
: tr::lng_context_mark_unread(tr::now);
|
||||||
};
|
};
|
||||||
auto action = _addAction(label(peer), [=] {
|
auto action = _addAction(label(), [=] {
|
||||||
const auto markAsRead = isUnread(peer);
|
const auto markAsRead = isUnread();
|
||||||
const auto handle = [&](not_null<History*> history) {
|
const auto handle = [&](not_null<History*> history) {
|
||||||
if (markAsRead) {
|
if (markAsRead) {
|
||||||
peer->owner().histories().readInbox(history);
|
peer->owner().histories().readInbox(history);
|
||||||
|
@ -380,7 +370,6 @@ void Filler::addToggleUnreadMark() {
|
||||||
!markAsRead);
|
!markAsRead);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const auto history = peer->owner().history(peer);
|
|
||||||
handle(history);
|
handle(history);
|
||||||
if (markAsRead) {
|
if (markAsRead) {
|
||||||
if (const auto migrated = history->migrateSibling()) {
|
if (const auto migrated = history->migrateSibling()) {
|
||||||
|
@ -390,24 +379,22 @@ void Filler::addToggleUnreadMark() {
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto lifetime = Ui::CreateChild<rpl::lifetime>(action);
|
const auto lifetime = Ui::CreateChild<rpl::lifetime>(action);
|
||||||
Notify::PeerUpdateViewer(
|
history->session().changes().historyUpdates(
|
||||||
_peer,
|
history,
|
||||||
Notify::PeerUpdate::Flag::UnreadViewChanged
|
Data::HistoryUpdate::Flag::UnreadView
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
action->setText(label(peer));
|
action->setText(label());
|
||||||
}, *lifetime);
|
}, *lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Filler::addToggleArchive() {
|
void Filler::addToggleArchive() {
|
||||||
const auto peer = _peer;
|
const auto peer = _peer;
|
||||||
|
const auto history = peer->owner().history(peer);
|
||||||
const auto isArchived = [=] {
|
const auto isArchived = [=] {
|
||||||
const auto history = peer->owner().historyLoaded(peer);
|
return (history->folder() != nullptr);
|
||||||
return history && history->folder();
|
|
||||||
};
|
};
|
||||||
const auto toggle = [=] {
|
const auto toggle = [=] {
|
||||||
ToggleHistoryArchived(
|
ToggleHistoryArchived(history, !isArchived());
|
||||||
peer->owner().history(peer),
|
|
||||||
!isArchived());
|
|
||||||
};
|
};
|
||||||
const auto archiveAction = _addAction(
|
const auto archiveAction = _addAction(
|
||||||
(isArchived()
|
(isArchived()
|
||||||
|
@ -416,9 +403,9 @@ void Filler::addToggleArchive() {
|
||||||
toggle);
|
toggle);
|
||||||
|
|
||||||
const auto lifetime = Ui::CreateChild<rpl::lifetime>(archiveAction);
|
const auto lifetime = Ui::CreateChild<rpl::lifetime>(archiveAction);
|
||||||
Notify::PeerUpdateViewer(
|
history->session().changes().historyUpdates(
|
||||||
peer,
|
history,
|
||||||
Notify::PeerUpdate::Flag::FolderChanged
|
Data::HistoryUpdate::Flag::Folder
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
archiveAction->setText(isArchived()
|
archiveAction->setText(isArchived()
|
||||||
? tr::lng_archived_remove(tr::now)
|
? tr::lng_archived_remove(tr::now)
|
||||||
|
@ -448,9 +435,9 @@ void Filler::addBlockUser(not_null<UserData*> user) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto lifetime = Ui::CreateChild<rpl::lifetime>(blockAction);
|
const auto lifetime = Ui::CreateChild<rpl::lifetime>(blockAction);
|
||||||
Notify::PeerUpdateViewer(
|
_peer->session().changes().peerUpdates(
|
||||||
_peer,
|
_peer,
|
||||||
Notify::PeerUpdate::Flag::UserIsBlocked
|
Data::PeerUpdate::Flag::IsBlocked
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
blockAction->setText(blockText(user));
|
blockAction->setText(blockText(user));
|
||||||
}, *lifetime);
|
}, *lifetime);
|
||||||
|
|
Loading…
Add table
Reference in a new issue