mirror of https://github.com/procxx/kepka.git
ReportSpamPanel -> HistoryView::ContactStatus.
This commit is contained in:
parent
30dea3a2e7
commit
5e3734d7bf
|
@ -1189,12 +1189,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_ban_user" = "Ban User";
|
"lng_ban_user" = "Ban User";
|
||||||
"lng_delete_all_from" = "Delete all from this user";
|
"lng_delete_all_from" = "Delete all from this user";
|
||||||
"lng_report_spam" = "Report Spam";
|
"lng_report_spam" = "Report Spam";
|
||||||
"lng_report_spam_hide" = "Hide";
|
|
||||||
"lng_report_spam_thanks" = "Thank you for your report!";
|
|
||||||
"lng_report_spam_sure" = "Are you sure you want to report spam from this user?";
|
"lng_report_spam_sure" = "Are you sure you want to report spam from this user?";
|
||||||
"lng_report_spam_sure_group" = "Are you sure you want to report spam in this group?";
|
"lng_report_spam_sure_group" = "Are you sure you want to report spam in this group?";
|
||||||
"lng_report_spam_sure_channel" = "Are you sure you want to report spam in this channel?";
|
"lng_report_spam_sure_channel" = "Are you sure you want to report spam in this channel?";
|
||||||
"lng_report_spam_ok" = "Report";
|
"lng_report_spam_ok" = "Report";
|
||||||
|
"lng_new_contact_block" = "Block user";
|
||||||
|
"lng_new_contact_add" = "Add contact";
|
||||||
|
"lng_new_contact_share" = "Share my phone number";
|
||||||
"lng_cant_send_to_not_contact" = "Sorry, you can only send messages to\nmutual contacts at the moment.\n{more_info}";
|
"lng_cant_send_to_not_contact" = "Sorry, you can only send messages to\nmutual contacts at the moment.\n{more_info}";
|
||||||
"lng_cant_invite_not_contact" = "Sorry, you can only add mutual contacts\nto groups at the moment.\n{more_info}";
|
"lng_cant_invite_not_contact" = "Sorry, you can only add mutual contacts\nto groups at the moment.\n{more_info}";
|
||||||
"lng_cant_more_info" = "More info »";
|
"lng_cant_more_info" = "More info »";
|
||||||
|
|
|
@ -1316,6 +1316,22 @@ void ApiWrap::requestPeer(not_null<PeerData*> peer) {
|
||||||
_peerRequests.insert(peer, requestId);
|
_peerRequests.insert(peer, requestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ApiWrap::requestPeerSettings(not_null<PeerData*> peer) {
|
||||||
|
if (!_requestedPeerSettings.emplace(peer).second) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
request(MTPmessages_GetPeerSettings(
|
||||||
|
peer->input
|
||||||
|
)).done([=](const MTPPeerSettings &result) {
|
||||||
|
peer->setSettings(result.match([&](const MTPDpeerSettings &data) {
|
||||||
|
return data.vflags.v;
|
||||||
|
}));
|
||||||
|
_requestedPeerSettings.erase(peer);
|
||||||
|
}).fail([=](const RPCError &error) {
|
||||||
|
_requestedPeerSettings.erase(peer);
|
||||||
|
}).send();
|
||||||
|
}
|
||||||
|
|
||||||
void ApiWrap::migrateChat(
|
void ApiWrap::migrateChat(
|
||||||
not_null<ChatData*> chat,
|
not_null<ChatData*> chat,
|
||||||
FnMut<void(not_null<ChannelData*>)> done,
|
FnMut<void(not_null<ChannelData*>)> done,
|
||||||
|
@ -2191,7 +2207,7 @@ void ApiWrap::blockUser(not_null<UserData*> user) {
|
||||||
} 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);
|
||||||
user->setBlockStatus(UserData::BlockStatus::Blocked);
|
user->setIsBlocked(true);
|
||||||
if (_blockedUsersSlice) {
|
if (_blockedUsersSlice) {
|
||||||
_blockedUsersSlice->list.insert(
|
_blockedUsersSlice->list.insert(
|
||||||
_blockedUsersSlice->list.begin(),
|
_blockedUsersSlice->list.begin(),
|
||||||
|
@ -2217,7 +2233,7 @@ void ApiWrap::unblockUser(not_null<UserData*> user) {
|
||||||
user->inputUser
|
user->inputUser
|
||||||
)).done([=](const MTPBool &result) {
|
)).done([=](const MTPBool &result) {
|
||||||
_blockRequests.erase(user);
|
_blockRequests.erase(user);
|
||||||
user->setBlockStatus(UserData::BlockStatus::NotBlocked);
|
user->setIsBlocked(false);
|
||||||
if (_blockedUsersSlice) {
|
if (_blockedUsersSlice) {
|
||||||
auto &list = _blockedUsersSlice->list;
|
auto &list = _blockedUsersSlice->list;
|
||||||
for (auto i = list.begin(); i != list.end(); ++i) {
|
for (auto i = list.begin(); i != list.end(); ++i) {
|
||||||
|
@ -2513,9 +2529,6 @@ void ApiWrap::deleteHistory(not_null<PeerData*> peer, bool justClear, bool revok
|
||||||
const auto offset = applyAffectedHistory(peer, result);
|
const auto offset = applyAffectedHistory(peer, result);
|
||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
deleteHistory(peer, justClear, revoke);
|
deleteHistory(peer, justClear, revoke);
|
||||||
} else if (!justClear && cReportSpamStatuses().contains(peer->id)) {
|
|
||||||
cRefReportSpamStatuses().remove(peer->id);
|
|
||||||
Local::writeReportSpamStatuses();
|
|
||||||
}
|
}
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
|
@ -5793,7 +5806,7 @@ void ApiWrap::reloadBlockedUsers() {
|
||||||
const auto user = _session->data().userLoaded(
|
const auto user = _session->data().userLoaded(
|
||||||
data.vuser_id.v);
|
data.vuser_id.v);
|
||||||
if (user) {
|
if (user) {
|
||||||
user->setBlockStatus(UserData::BlockStatus::Blocked);
|
user->setIsBlocked(true);
|
||||||
slice.list.push_back({ user, data.vdate.v });
|
slice.list.push_back({ user, data.vdate.v });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -150,6 +150,7 @@ public:
|
||||||
void requestFullPeer(not_null<PeerData*> peer);
|
void requestFullPeer(not_null<PeerData*> peer);
|
||||||
void requestPeer(not_null<PeerData*> peer);
|
void requestPeer(not_null<PeerData*> peer);
|
||||||
void requestPeers(const QList<PeerData*> &peers);
|
void requestPeers(const QList<PeerData*> &peers);
|
||||||
|
void requestPeerSettings(not_null<PeerData*> peer);
|
||||||
void requestLastParticipants(not_null<ChannelData*> channel);
|
void requestLastParticipants(not_null<ChannelData*> channel);
|
||||||
void requestBots(not_null<ChannelData*> channel);
|
void requestBots(not_null<ChannelData*> channel);
|
||||||
void requestAdmins(not_null<ChannelData*> channel);
|
void requestAdmins(not_null<ChannelData*> channel);
|
||||||
|
@ -689,6 +690,7 @@ private:
|
||||||
using PeerRequests = QMap<PeerData*, mtpRequestId>;
|
using PeerRequests = QMap<PeerData*, mtpRequestId>;
|
||||||
PeerRequests _fullPeerRequests;
|
PeerRequests _fullPeerRequests;
|
||||||
PeerRequests _peerRequests;
|
PeerRequests _peerRequests;
|
||||||
|
base::flat_set<not_null<PeerData*>> _requestedPeerSettings;
|
||||||
|
|
||||||
PeerRequests _participantsRequests;
|
PeerRequests _participantsRequests;
|
||||||
PeerRequests _botsRequests;
|
PeerRequests _botsRequests;
|
||||||
|
|
|
@ -142,48 +142,13 @@ namespace App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//void feedUserLink(MTPint userId, const MTPContactLink &myLink, const MTPContactLink &foreignLink) {
|
|
||||||
// if (const auto user = Auth().data().userLoaded(userId.v)) {
|
|
||||||
// const auto wasShowPhone = (user->contactStatus() == UserData::ContactStatus::CanAdd);
|
|
||||||
// switch (myLink.type()) {
|
|
||||||
// case mtpc_contactLinkContact:
|
|
||||||
// user->setContactStatus(UserData::ContactStatus::Contact);
|
|
||||||
// break;
|
|
||||||
// case mtpc_contactLinkNone:
|
|
||||||
// case mtpc_contactLinkUnknown:
|
|
||||||
// user->setContactStatus(UserData::ContactStatus::PhoneUnknown);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// if (user->contactStatus() == UserData::ContactStatus::PhoneUnknown
|
|
||||||
// && !user->phone().isEmpty()
|
|
||||||
// && user->id != Auth().userPeerId()) {
|
|
||||||
// user->setContactStatus(UserData::ContactStatus::CanAdd);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const auto showPhone = !user->isServiceUser()
|
|
||||||
// && !user->isSelf()
|
|
||||||
// && user->contactStatus() == UserData::ContactStatus::CanAdd;
|
|
||||||
// const auto showPhoneChanged = !user->isServiceUser()
|
|
||||||
// && !user->isSelf()
|
|
||||||
// && (showPhone != wasShowPhone);
|
|
||||||
// if (showPhoneChanged) {
|
|
||||||
// user->setName(
|
|
||||||
// TextUtilities::SingleLine(user->firstName),
|
|
||||||
// TextUtilities::SingleLine(user->lastName),
|
|
||||||
// showPhone
|
|
||||||
// ? App::formatPhone(user->phone())
|
|
||||||
// : QString(),
|
|
||||||
// TextUtilities::SingleLine(user->username));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
QString peerName(const PeerData *peer, bool forDialogs) {
|
QString peerName(const PeerData *peer, bool forDialogs) {
|
||||||
return peer ? ((forDialogs && peer->isUser() && !peer->asUser()->nameOrPhone.isEmpty()) ? peer->asUser()->nameOrPhone : peer->name) : lang(lng_deleted);
|
return peer ? ((forDialogs && peer->isUser() && !peer->asUser()->nameOrPhone.isEmpty()) ? peer->asUser()->nameOrPhone : peer->name) : lang(lng_deleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepareCorners(RoundCorners index, int32 radius, const QBrush &brush, const style::color *shadow = nullptr, QImage *cors = nullptr) {
|
void prepareCorners(RoundCorners index, int32 radius, const QBrush &brush, const style::color *shadow = nullptr, QImage *cors = nullptr) {
|
||||||
Expects(::corners.size() > index);
|
Expects(::corners.size() > index);
|
||||||
|
|
||||||
int32 r = radius * cIntRetinaFactor(), s = st::msgShadow * cIntRetinaFactor();
|
int32 r = radius * cIntRetinaFactor(), s = st::msgShadow * cIntRetinaFactor();
|
||||||
QImage rect(r * 3, r * 3 + (shadow ? s : 0), QImage::Format_ARGB32_Premultiplied), localCors[4];
|
QImage rect(r * 3, r * 3 + (shadow ? s : 0), QImage::Format_ARGB32_Premultiplied), localCors[4];
|
||||||
{
|
{
|
||||||
|
|
|
@ -341,15 +341,6 @@ QNetworkProxy ToNetworkProxy(const ProxyData &proxy);
|
||||||
|
|
||||||
static const int MatrixRowShift = 40000;
|
static const int MatrixRowShift = 40000;
|
||||||
|
|
||||||
enum DBIPeerReportSpamStatus {
|
|
||||||
dbiprsNoButton = 0, // hidden, but not in the cloud settings yet
|
|
||||||
dbiprsUnknown = 1, // contacts not loaded yet
|
|
||||||
dbiprsShowButton = 2, // show report spam button, each show peer request setting from cloud
|
|
||||||
dbiprsReportSent = 3, // report sent, but the report spam panel is not hidden yet
|
|
||||||
dbiprsHidden = 4, // hidden in the cloud or not needed (bots, contacts, etc), no more requests
|
|
||||||
dbiprsRequesting = 5, // requesting the cloud setting right now
|
|
||||||
};
|
|
||||||
|
|
||||||
inline int rowscount(int fullCount, int countPerRow) {
|
inline int rowscount(int fullCount, int countPerRow) {
|
||||||
return (fullCount + countPerRow - 1) / countPerRow;
|
return (fullCount + countPerRow - 1) / countPerRow;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,15 @@ protected:
|
||||||
PeerData &operator=(const PeerData &other) = delete;
|
PeerData &operator=(const PeerData &other) = delete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static constexpr auto kEssentialSettings = 0
|
||||||
|
| MTPDpeerSettings::Flag::f_report_spam
|
||||||
|
| MTPDpeerSettings::Flag::f_add_contact
|
||||||
|
| MTPDpeerSettings::Flag::f_block_contact
|
||||||
|
| MTPDpeerSettings::Flag::f_share_contact;
|
||||||
|
using Settings = Data::Flags<
|
||||||
|
MTPDpeerSettings::Flags,
|
||||||
|
kEssentialSettings.value()>;
|
||||||
|
|
||||||
virtual ~PeerData();
|
virtual ~PeerData();
|
||||||
|
|
||||||
static constexpr auto kServiceNotificationsId = peerFromUser(777000);
|
static constexpr auto kServiceNotificationsId = peerFromUser(777000);
|
||||||
|
@ -289,6 +298,20 @@ public:
|
||||||
|
|
||||||
void checkFolder(FolderId folderId);
|
void checkFolder(FolderId folderId);
|
||||||
|
|
||||||
|
void setSettings(MTPDpeerSettings::Flags which) {
|
||||||
|
_settings.set(which);
|
||||||
|
}
|
||||||
|
auto settings() const {
|
||||||
|
return (_settings.current() & kSettingsUnknown)
|
||||||
|
? std::nullopt
|
||||||
|
: std::make_optional(_settings.current());
|
||||||
|
}
|
||||||
|
auto settingsValue() const {
|
||||||
|
return (_settings.current() & kSettingsUnknown)
|
||||||
|
? _settings.changes()
|
||||||
|
: _settings.value();
|
||||||
|
}
|
||||||
|
|
||||||
enum LoadedStatus {
|
enum LoadedStatus {
|
||||||
NotLoaded = 0x00,
|
NotLoaded = 0x00,
|
||||||
MinimalLoaded = 0x01,
|
MinimalLoaded = 0x01,
|
||||||
|
@ -342,6 +365,11 @@ private:
|
||||||
crl::time _lastFullUpdate = 0;
|
crl::time _lastFullUpdate = 0;
|
||||||
MsgId _pinnedMessageId = 0;
|
MsgId _pinnedMessageId = 0;
|
||||||
|
|
||||||
|
static constexpr auto kSettingsUnknown = MTPDpeerSettings::Flag(1U << 9);
|
||||||
|
static_assert(!(kEssentialSettings & kSettingsUnknown));
|
||||||
|
|
||||||
|
Settings _settings = { kSettingsUnknown };
|
||||||
|
|
||||||
QString _about;
|
QString _about;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -216,7 +216,6 @@ void Session::clear() {
|
||||||
_sentMessagesData.clear();
|
_sentMessagesData.clear();
|
||||||
cSetRecentInlineBots(RecentInlineBots());
|
cSetRecentInlineBots(RecentInlineBots());
|
||||||
cSetRecentStickers(RecentStickerPack());
|
cSetRecentStickers(RecentStickerPack());
|
||||||
cSetReportSpamStatuses(ReportSpamStatuses());
|
|
||||||
App::clearMousedItems();
|
App::clearMousedItems();
|
||||||
_histories.clear();
|
_histories.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,17 +59,15 @@ bool UserData::canShareThisContact() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserData::setIsContact(bool is) {
|
void UserData::setIsContact(bool is) {
|
||||||
if (_isContact != is) {
|
const auto status = is
|
||||||
_isContact = is;
|
? ContactStatus::Contact
|
||||||
|
: ContactStatus::NotContact;
|
||||||
|
if (_contactStatus != status) {
|
||||||
|
_contactStatus = status;
|
||||||
Notify::peerUpdatedDelayed(
|
Notify::peerUpdatedDelayed(
|
||||||
this,
|
this,
|
||||||
Notify::PeerUpdate::Flag::UserIsContact);
|
Notify::PeerUpdate::Flag::UserIsContact);
|
||||||
}
|
}
|
||||||
if (_isContact
|
|
||||||
&& cReportSpamStatuses().value(id, dbiprsHidden) != dbiprsHidden) {
|
|
||||||
cRefReportSpamStatuses().insert(id, dbiprsHidden);
|
|
||||||
Local::writeReportSpamStatuses();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// see Local::readPeer as well
|
// see Local::readPeer as well
|
||||||
|
@ -231,9 +229,12 @@ void UserData::setAccessHash(uint64 accessHash) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserData::setBlockStatus(BlockStatus blockStatus) {
|
void UserData::setIsBlocked(bool is) {
|
||||||
if (blockStatus != _blockStatus) {
|
const auto status = is
|
||||||
_blockStatus = blockStatus;
|
? BlockStatus::Blocked
|
||||||
|
: BlockStatus::NotBlocked;
|
||||||
|
if (_blockStatus != status) {
|
||||||
|
_blockStatus = status;
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::UserIsBlocked);
|
Notify::peerUpdatedDelayed(this, UpdateFlag::UserIsBlocked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,13 +258,11 @@ void ApplyUserUpdate(not_null<UserData*> user, const MTPDuserFull &update) {
|
||||||
if (update.has_profile_photo()) {
|
if (update.has_profile_photo()) {
|
||||||
user->owner().processPhoto(update.vprofile_photo);
|
user->owner().processPhoto(update.vprofile_photo);
|
||||||
}
|
}
|
||||||
update.vsettings.match([&](const MTPDpeerSettings &data) {
|
const auto settings = update.vsettings.match([&](
|
||||||
//user->owner().processUserSettings(data);
|
const MTPDpeerSettings &data) {
|
||||||
//App::feedUserLink(
|
return data.vflags.v;
|
||||||
// MTP_int(peerToUser(user->id)),
|
|
||||||
// link.vmy_link,
|
|
||||||
// link.vforeign_link);
|
|
||||||
});
|
});
|
||||||
|
user->setSettings(settings);
|
||||||
user->session().api().applyNotifySettings(
|
user->session().api().applyNotifySettings(
|
||||||
MTP_inputNotifyPeer(user->input),
|
MTP_inputNotifyPeer(user->input),
|
||||||
update.vnotify_settings);
|
update.vnotify_settings);
|
||||||
|
@ -279,9 +278,7 @@ void ApplyUserUpdate(not_null<UserData*> user, const MTPDuserFull &update) {
|
||||||
user->clearPinnedMessage();
|
user->clearPinnedMessage();
|
||||||
}
|
}
|
||||||
user->setFullFlags(update.vflags.v);
|
user->setFullFlags(update.vflags.v);
|
||||||
user->setBlockStatus(update.is_blocked()
|
user->setIsBlocked(update.is_blocked());
|
||||||
? UserData::BlockStatus::Blocked
|
|
||||||
: UserData::BlockStatus::NotBlocked);
|
|
||||||
user->setCallsStatus(update.is_phone_calls_private()
|
user->setCallsStatus(update.is_phone_calls_private()
|
||||||
? UserData::CallsStatus::Private
|
? UserData::CallsStatus::Private
|
||||||
: update.is_phone_calls_available()
|
: update.is_phone_calls_available()
|
||||||
|
|
|
@ -163,8 +163,16 @@ public:
|
||||||
Text phoneText;
|
Text phoneText;
|
||||||
TimeId onlineTill = 0;
|
TimeId onlineTill = 0;
|
||||||
|
|
||||||
|
enum class ContactStatus : char {
|
||||||
|
Unknown,
|
||||||
|
Contact,
|
||||||
|
NotContact,
|
||||||
|
};
|
||||||
|
[[nodiscard]] ContactStatus contactStatus() const {
|
||||||
|
return _contactStatus;
|
||||||
|
}
|
||||||
[[nodiscard]] bool isContact() const {
|
[[nodiscard]] bool isContact() const {
|
||||||
return _isContact;
|
return (contactStatus() == ContactStatus::Contact);
|
||||||
}
|
}
|
||||||
void setIsContact(bool is);
|
void setIsContact(bool is);
|
||||||
|
|
||||||
|
@ -179,7 +187,7 @@ public:
|
||||||
bool isBlocked() const {
|
bool isBlocked() const {
|
||||||
return (blockStatus() == BlockStatus::Blocked);
|
return (blockStatus() == BlockStatus::Blocked);
|
||||||
}
|
}
|
||||||
void setBlockStatus(BlockStatus blockStatus);
|
void setIsBlocked(bool is);
|
||||||
|
|
||||||
enum class CallsStatus : char {
|
enum class CallsStatus : char {
|
||||||
Unknown,
|
Unknown,
|
||||||
|
@ -209,7 +217,7 @@ private:
|
||||||
|
|
||||||
QString _unavailableReason;
|
QString _unavailableReason;
|
||||||
QString _phone;
|
QString _phone;
|
||||||
bool _isContact = false;
|
ContactStatus _contactStatus = ContactStatus::Unknown;
|
||||||
BlockStatus _blockStatus = BlockStatus::Unknown;
|
BlockStatus _blockStatus = BlockStatus::Unknown;
|
||||||
CallsStatus _callsStatus = CallsStatus::Unknown;
|
CallsStatus _callsStatus = CallsStatus::Unknown;
|
||||||
int _commonChatsCount = 0;
|
int _commonChatsCount = 0;
|
||||||
|
|
|
@ -302,23 +302,6 @@ historyReplyCancel: IconButton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reportSpamHide: FlatButton {
|
|
||||||
color: windowActiveTextFg;
|
|
||||||
overColor: windowActiveTextFg;
|
|
||||||
|
|
||||||
bgColor: transparent;
|
|
||||||
overBgColor: transparent;
|
|
||||||
|
|
||||||
width: -40px;
|
|
||||||
height: 46px;
|
|
||||||
|
|
||||||
textTop: 15px;
|
|
||||||
|
|
||||||
font: font(fsize);
|
|
||||||
overFont: font(fsize underline);
|
|
||||||
}
|
|
||||||
reportSpamSeparator: 30px;
|
|
||||||
|
|
||||||
msgBotKbDuration: 200;
|
msgBotKbDuration: 200;
|
||||||
msgBotKbFont: semiboldFont;
|
msgBotKbFont: semiboldFont;
|
||||||
msgBotKbIconPadding: 2px;
|
msgBotKbIconPadding: 2px;
|
||||||
|
|
|
@ -65,6 +65,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#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 "observer_peer.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"
|
||||||
|
@ -238,49 +239,6 @@ object_ptr<Ui::FlatButton> SetupDiscussButton(
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ReportSpamPanel::ReportSpamPanel(QWidget *parent) : TWidget(parent),
|
|
||||||
_report(this, lang(lng_report_spam), st::reportSpamHide),
|
|
||||||
_hide(this, lang(lng_report_spam_hide), st::reportSpamHide),
|
|
||||||
_clear(this, lang(lng_profile_delete_conversation)) {
|
|
||||||
resize(parent->width(), _hide->height() + st::lineWidth);
|
|
||||||
|
|
||||||
connect(_report, SIGNAL(clicked()), this, SIGNAL(reportClicked()));
|
|
||||||
connect(_hide, SIGNAL(clicked()), this, SIGNAL(hideClicked()));
|
|
||||||
connect(_clear, SIGNAL(clicked()), this, SIGNAL(clearClicked()));
|
|
||||||
|
|
||||||
_clear->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReportSpamPanel::resizeEvent(QResizeEvent *e) {
|
|
||||||
_report->resize(width() - (_hide->width() + st::reportSpamSeparator) * 2, _report->height());
|
|
||||||
_report->moveToLeft(_hide->width() + st::reportSpamSeparator, 0);
|
|
||||||
_hide->moveToRight(0, 0);
|
|
||||||
_clear->move((width() - _clear->width()) / 2, height() - _clear->height() - ((height() - st::msgFont->height - _clear->height()) / 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReportSpamPanel::paintEvent(QPaintEvent *e) {
|
|
||||||
Painter p(this);
|
|
||||||
p.fillRect(QRect(0, 0, width(), height() - st::lineWidth), st::historyPinnedBg);
|
|
||||||
p.fillRect(Adaptive::OneColumn() ? 0 : st::lineWidth, height() - st::lineWidth, width() - (Adaptive::OneColumn() ? 0 : st::lineWidth), st::lineWidth, st::shadowFg);
|
|
||||||
if (!_clear->isHidden()) {
|
|
||||||
p.setPen(st::historyComposeAreaFg);
|
|
||||||
p.setFont(st::msgFont);
|
|
||||||
p.drawText(QRect(_report->x(), (_clear->y() - st::msgFont->height) / 2, _report->width(), st::msgFont->height), lang(lng_report_spam_thanks), style::al_top);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReportSpamPanel::setReported(bool reported, PeerData *onPeer) {
|
|
||||||
if (reported) {
|
|
||||||
_report->hide();
|
|
||||||
_clear->setText(lang(onPeer->isChannel() ? (onPeer->isMegagroup() ? lng_profile_leave_group : lng_profile_leave_channel) : lng_profile_delete_conversation));
|
|
||||||
_clear->show();
|
|
||||||
} else {
|
|
||||||
_report->show();
|
|
||||||
_clear->hide();
|
|
||||||
}
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
HistoryWidget::HistoryWidget(
|
HistoryWidget::HistoryWidget(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<Window::SessionController*> controller)
|
not_null<Window::SessionController*> controller)
|
||||||
|
@ -520,14 +478,6 @@ HistoryWidget::HistoryWidget(
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
session().data().contactsLoaded().changes(
|
|
||||||
) | rpl::start_with_next([=] {
|
|
||||||
if (_peer) {
|
|
||||||
updateReportSpamStatus();
|
|
||||||
updateControlsVisibility();
|
|
||||||
}
|
|
||||||
}, 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);
|
||||||
|
@ -1058,8 +1008,8 @@ void HistoryWidget::applyInlineBotQuery(UserData *bot, const QString &query) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::orderWidgets() {
|
void HistoryWidget::orderWidgets() {
|
||||||
if (_reportSpamPanel) {
|
if (_contactStatus) {
|
||||||
_reportSpamPanel->raise();
|
_contactStatus->raise();
|
||||||
}
|
}
|
||||||
if (_pinnedBar) {
|
if (_pinnedBar) {
|
||||||
_pinnedBar->shadow->raise();
|
_pinnedBar->shadow->raise();
|
||||||
|
@ -1082,26 +1032,6 @@ void HistoryWidget::orderWidgets() {
|
||||||
_attachDragPhoto->raise();
|
_attachDragPhoto->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::setReportSpamStatus(DBIPeerReportSpamStatus status) {
|
|
||||||
if (_reportSpamStatus == status) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_reportSpamStatus = status;
|
|
||||||
if (_reportSpamStatus == dbiprsShowButton || _reportSpamStatus == dbiprsReportSent) {
|
|
||||||
Assert(_peer != nullptr);
|
|
||||||
_reportSpamPanel.create(this);
|
|
||||||
connect(_reportSpamPanel, SIGNAL(reportClicked()), this, SLOT(onReportSpamClicked()));
|
|
||||||
connect(_reportSpamPanel, SIGNAL(hideClicked()), this, SLOT(onReportSpamHide()));
|
|
||||||
connect(_reportSpamPanel, SIGNAL(clearClicked()), this, SLOT(onReportSpamClear()));
|
|
||||||
_reportSpamPanel->setReported(_reportSpamStatus == dbiprsReportSent, _peer);
|
|
||||||
_reportSpamPanel->show();
|
|
||||||
orderWidgets();
|
|
||||||
updateControlsGeometry();
|
|
||||||
} else {
|
|
||||||
_reportSpamPanel.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HistoryWidget::updateStickersByEmoji() {
|
void HistoryWidget::updateStickersByEmoji() {
|
||||||
if (!_history) {
|
if (!_history) {
|
||||||
return;
|
return;
|
||||||
|
@ -1753,6 +1683,11 @@ void HistoryWidget::showHistory(
|
||||||
_channel = peerToChannel(_peer->id);
|
_channel = peerToChannel(_peer->id);
|
||||||
_canSendMessages = _peer->canWrite();
|
_canSendMessages = _peer->canWrite();
|
||||||
_tabbedSelector->setCurrentPeer(_peer);
|
_tabbedSelector->setCurrentPeer(_peer);
|
||||||
|
_contactStatus = std::make_unique<HistoryView::ContactStatus>(
|
||||||
|
this,
|
||||||
|
_peer);
|
||||||
|
} else {
|
||||||
|
_contactStatus = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_peer) {
|
if (_peer) {
|
||||||
|
@ -1769,12 +1704,6 @@ void HistoryWidget::showHistory(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_reportSpamRequest = 0;
|
|
||||||
if (_reportSpamSettingRequestId > 0) {
|
|
||||||
MTP::cancel(_reportSpamSettingRequestId);
|
|
||||||
}
|
|
||||||
_reportSpamSettingRequestId = ReportSpamRequestNeeded;
|
|
||||||
|
|
||||||
noSelectingScroll();
|
noSelectingScroll();
|
||||||
_nonEmptySelection = false;
|
_nonEmptySelection = false;
|
||||||
|
|
||||||
|
@ -1941,117 +1870,6 @@ bool HistoryWidget::contentOverlapped(const QRect &globalRect) {
|
||||||
|| (_inlineResults && _inlineResults->overlaps(globalRect)));
|
|| (_inlineResults && _inlineResults->overlaps(globalRect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::updateReportSpamStatus() {
|
|
||||||
if (!_peer
|
|
||||||
|| (_peer->id == session().userPeerId())
|
|
||||||
|| _peer->isServiceUser()
|
|
||||||
|| (_peer->isUser() && _peer->asUser()->isBot())) {
|
|
||||||
setReportSpamStatus(dbiprsHidden);
|
|
||||||
return;
|
|
||||||
} else if (!_firstLoadRequest && _history->isEmpty()) {
|
|
||||||
setReportSpamStatus(dbiprsNoButton);
|
|
||||||
if (cReportSpamStatuses().contains(_peer->id)) {
|
|
||||||
cRefReportSpamStatuses().remove(_peer->id);
|
|
||||||
Local::writeReportSpamStatuses();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
auto i = cReportSpamStatuses().constFind(_peer->id);
|
|
||||||
if (i != cReportSpamStatuses().cend()) {
|
|
||||||
if (i.value() == dbiprsNoButton) {
|
|
||||||
setReportSpamStatus(dbiprsHidden);
|
|
||||||
if (!_peer->isUser() || !_peer->asUser()->isContact()) {
|
|
||||||
MTP::send(MTPmessages_HidePeerSettingsBar(_peer->input));
|
|
||||||
}
|
|
||||||
|
|
||||||
cRefReportSpamStatuses().insert(_peer->id, _reportSpamStatus);
|
|
||||||
Local::writeReportSpamStatuses();
|
|
||||||
} else {
|
|
||||||
setReportSpamStatus(i.value());
|
|
||||||
if (_reportSpamStatus == dbiprsShowButton) {
|
|
||||||
requestReportSpamSetting();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else if (_peer->migrateFrom()) { // migrate report status
|
|
||||||
i = cReportSpamStatuses().constFind(_peer->migrateFrom()->id);
|
|
||||||
if (i != cReportSpamStatuses().cend()) {
|
|
||||||
if (i.value() == dbiprsNoButton) {
|
|
||||||
setReportSpamStatus(dbiprsHidden);
|
|
||||||
if (!_peer->isUser() || !_peer->asUser()->isContact()) {
|
|
||||||
MTP::send(MTPmessages_HidePeerSettingsBar(_peer->input));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setReportSpamStatus(i.value());
|
|
||||||
if (_reportSpamStatus == dbiprsShowButton) {
|
|
||||||
requestReportSpamSetting();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cRefReportSpamStatuses().insert(_peer->id, _reportSpamStatus);
|
|
||||||
Local::writeReportSpamStatuses();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
auto status = dbiprsRequesting;
|
|
||||||
if (!session().data().contactsLoaded().current() || _firstLoadRequest) {
|
|
||||||
status = dbiprsUnknown;
|
|
||||||
} else if (_peer->isUser() && _peer->asUser()->isContact()) {
|
|
||||||
status = dbiprsHidden;
|
|
||||||
} else {
|
|
||||||
requestReportSpamSetting();
|
|
||||||
}
|
|
||||||
setReportSpamStatus(status);
|
|
||||||
if (_reportSpamStatus == dbiprsHidden) {
|
|
||||||
cRefReportSpamStatuses().insert(_peer->id, _reportSpamStatus);
|
|
||||||
Local::writeReportSpamStatuses();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HistoryWidget::requestReportSpamSetting() {
|
|
||||||
if (_reportSpamSettingRequestId >= 0 || !_peer) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_reportSpamSettingRequestId = MTP::send(
|
|
||||||
MTPmessages_GetPeerSettings(_peer->input),
|
|
||||||
rpcDone(&HistoryWidget::reportSpamSettingDone),
|
|
||||||
rpcFail(&HistoryWidget::reportSpamSettingFail));
|
|
||||||
}
|
|
||||||
|
|
||||||
void HistoryWidget::reportSpamSettingDone(const MTPPeerSettings &result, mtpRequestId req) {
|
|
||||||
if (req != _reportSpamSettingRequestId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_reportSpamSettingRequestId = 0;
|
|
||||||
result.match([&](const MTPDpeerSettings &data) {
|
|
||||||
const auto status = data.is_report_spam()
|
|
||||||
? dbiprsShowButton
|
|
||||||
: dbiprsHidden;
|
|
||||||
if (status != _reportSpamStatus) {
|
|
||||||
setReportSpamStatus(status);
|
|
||||||
if (_reportSpamPanel) {
|
|
||||||
_reportSpamPanel->setReported(false, _peer);
|
|
||||||
}
|
|
||||||
|
|
||||||
cRefReportSpamStatuses().insert(_peer->id, _reportSpamStatus);
|
|
||||||
Local::writeReportSpamStatuses();
|
|
||||||
|
|
||||||
updateControlsVisibility();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HistoryWidget::reportSpamSettingFail(const RPCError &error, mtpRequestId req) {
|
|
||||||
if (MTP::isDefaultHandledError(error)) return false;
|
|
||||||
|
|
||||||
if (req == _reportSpamSettingRequestId) {
|
|
||||||
req = 0;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HistoryWidget::canWriteMessage() const {
|
bool HistoryWidget::canWriteMessage() const {
|
||||||
if (!_history || !_canSendMessages) return false;
|
if (!_history || !_canSendMessages) return false;
|
||||||
if (isBlocked() || isJoinChannel() || isMuteUnmute() || isBotStart()) return false;
|
if (isBlocked() || isJoinChannel() || isMuteUnmute() || isBotStart()) return false;
|
||||||
|
@ -2085,8 +1903,8 @@ void HistoryWidget::updateControlsVisibility() {
|
||||||
} else if (!_firstLoadRequest && _scroll->isHidden()) {
|
} else if (!_firstLoadRequest && _scroll->isHidden()) {
|
||||||
_scroll->show();
|
_scroll->show();
|
||||||
}
|
}
|
||||||
if (_reportSpamPanel) {
|
if (_contactStatus) {
|
||||||
_reportSpamPanel->show();
|
_contactStatus->show();
|
||||||
}
|
}
|
||||||
refreshAboutProxyPromotion();
|
refreshAboutProxyPromotion();
|
||||||
if (!editingMessage() && (isBlocked() || isJoinChannel() || isMuteUnmute() || isBotStart())) {
|
if (!editingMessage() && (isBlocked() || isJoinChannel() || isMuteUnmute() || isBotStart())) {
|
||||||
|
@ -2445,10 +2263,6 @@ void HistoryWidget::messagesReceived(PeerData *peer, const MTPmessages_Messages
|
||||||
addMessagesToFront(peer, *histList);
|
addMessagesToFront(peer, *histList);
|
||||||
_preloadRequest = 0;
|
_preloadRequest = 0;
|
||||||
preloadHistoryIfNeeded();
|
preloadHistoryIfNeeded();
|
||||||
if (_reportSpamStatus == dbiprsUnknown) {
|
|
||||||
updateReportSpamStatus();
|
|
||||||
if (_reportSpamStatus != dbiprsUnknown) updateControlsVisibility();
|
|
||||||
}
|
|
||||||
} else if (_preloadDownRequest == requestId) {
|
} else if (_preloadDownRequest == requestId) {
|
||||||
auto to = toMigrated ? _migrated : _history;
|
auto to = toMigrated ? _migrated : _history;
|
||||||
addMessagesToBack(peer, *histList);
|
addMessagesToBack(peer, *histList);
|
||||||
|
@ -3138,7 +2952,6 @@ void HistoryWidget::animationCallback() {
|
||||||
|
|
||||||
void HistoryWidget::doneShow() {
|
void HistoryWidget::doneShow() {
|
||||||
_topBar->setAnimatingMode(false);
|
_topBar->setAnimatingMode(false);
|
||||||
updateReportSpamStatus();
|
|
||||||
updateBotKeyboard();
|
updateBotKeyboard();
|
||||||
updateControlsVisibility();
|
updateControlsVisibility();
|
||||||
if (!_historyInited) {
|
if (!_historyInited) {
|
||||||
|
@ -4663,73 +4476,6 @@ void HistoryWidget::documentFailed(const FullMsgId &newId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::onReportSpamClicked() {
|
|
||||||
auto text = lang(_peer->isUser() ? lng_report_spam_sure : ((_peer->isChat() || _peer->isMegagroup()) ? lng_report_spam_sure_group : lng_report_spam_sure_channel));
|
|
||||||
Ui::show(Box<ConfirmBox>(text, lang(lng_report_spam_ok), st::attentionBoxButton, crl::guard(this, [this, peer = _peer] {
|
|
||||||
if (_reportSpamRequest) return;
|
|
||||||
|
|
||||||
Ui::hideLayer();
|
|
||||||
_reportSpamRequest = MTP::send(
|
|
||||||
MTPmessages_ReportSpam(peer->input),
|
|
||||||
rpcDone(&HistoryWidget::reportSpamDone, peer),
|
|
||||||
rpcFail(&HistoryWidget::reportSpamFail), 0, 5);
|
|
||||||
if (const auto user = peer->asUser()) {
|
|
||||||
session().api().blockUser(user);
|
|
||||||
}
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
|
|
||||||
void HistoryWidget::reportSpamDone(PeerData *peer, const MTPBool &result, mtpRequestId req) {
|
|
||||||
Expects(peer != nullptr);
|
|
||||||
|
|
||||||
if (req == _reportSpamRequest) {
|
|
||||||
_reportSpamRequest = 0;
|
|
||||||
}
|
|
||||||
cRefReportSpamStatuses().insert(peer->id, dbiprsReportSent);
|
|
||||||
Local::writeReportSpamStatuses();
|
|
||||||
if (_peer == peer) {
|
|
||||||
setReportSpamStatus(dbiprsReportSent);
|
|
||||||
if (_reportSpamPanel) {
|
|
||||||
_reportSpamPanel->setReported(_reportSpamStatus == dbiprsReportSent, peer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HistoryWidget::reportSpamFail(const RPCError &error, mtpRequestId req) {
|
|
||||||
if (MTP::isDefaultHandledError(error)) return false;
|
|
||||||
|
|
||||||
if (req == _reportSpamRequest) {
|
|
||||||
_reportSpamRequest = 0;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HistoryWidget::onReportSpamHide() {
|
|
||||||
if (_peer) {
|
|
||||||
cRefReportSpamStatuses().insert(_peer->id, dbiprsHidden);
|
|
||||||
Local::writeReportSpamStatuses();
|
|
||||||
|
|
||||||
MTP::send(MTPmessages_HidePeerSettingsBar(_peer->input));
|
|
||||||
}
|
|
||||||
setReportSpamStatus(dbiprsHidden);
|
|
||||||
updateControlsVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HistoryWidget::onReportSpamClear() {
|
|
||||||
Expects(_peer != nullptr);
|
|
||||||
|
|
||||||
InvokeQueued(App::main(), [peer = _peer] {
|
|
||||||
Ui::showChatsList();
|
|
||||||
if (const auto from = peer->migrateFrom()) {
|
|
||||||
peer->session().api().deleteConversation(from, false);
|
|
||||||
}
|
|
||||||
peer->session().api().deleteConversation(peer, false);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Invalidates _peer.
|
|
||||||
controller()->showBackFromStack();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HistoryWidget::handleHistoryChange(not_null<const History*> history) {
|
void HistoryWidget::handleHistoryChange(not_null<const History*> history) {
|
||||||
if (_list && (_history == history || _migrated == history)) {
|
if (_list && (_history == history || _migrated == history)) {
|
||||||
handlePendingHistoryUpdate();
|
handlePendingHistoryUpdate();
|
||||||
|
@ -4824,11 +4570,11 @@ void HistoryWidget::updateControlsGeometry() {
|
||||||
_pinnedBar->cancel->moveToLeft(width() - _pinnedBar->cancel->width(), pinnedBarTop);
|
_pinnedBar->cancel->moveToLeft(width() - _pinnedBar->cancel->width(), pinnedBarTop);
|
||||||
_pinnedBar->shadow->setGeometryToLeft(0, pinnedBarTop + st::historyReplyHeight, width(), st::lineWidth);
|
_pinnedBar->shadow->setGeometryToLeft(0, pinnedBarTop + st::historyReplyHeight, width(), st::lineWidth);
|
||||||
}
|
}
|
||||||
const auto reportSpamTop = pinnedBarTop + (_pinnedBar ? st::historyReplyHeight : 0);
|
const auto contactStatusTop = pinnedBarTop + (_pinnedBar ? st::historyReplyHeight : 0);
|
||||||
if (_reportSpamPanel) {
|
if (_contactStatus) {
|
||||||
_reportSpamPanel->setGeometryToLeft(0, reportSpamTop, width(), _reportSpamPanel->height());
|
_contactStatus->move(0, contactStatusTop);
|
||||||
}
|
}
|
||||||
const auto scrollAreaTop = reportSpamTop + (_reportSpamPanel ? (_reportSpamPanel->height() - st::lineWidth) : 0);
|
const auto scrollAreaTop = contactStatusTop + (_contactStatus ? _contactStatus->height() : 0);
|
||||||
if (_scroll->y() != scrollAreaTop) {
|
if (_scroll->y() != scrollAreaTop) {
|
||||||
_scroll->moveToLeft(0, scrollAreaTop);
|
_scroll->moveToLeft(0, scrollAreaTop);
|
||||||
_fieldAutocomplete->setBoundings(_scroll->geometry());
|
_fieldAutocomplete->setBoundings(_scroll->geometry());
|
||||||
|
@ -4983,8 +4729,8 @@ void HistoryWidget::updateHistoryGeometry(bool initial, bool loadedDown, const S
|
||||||
if (_pinnedBar) {
|
if (_pinnedBar) {
|
||||||
newScrollHeight -= st::historyReplyHeight;
|
newScrollHeight -= st::historyReplyHeight;
|
||||||
}
|
}
|
||||||
if (_reportSpamPanel) {
|
if (_contactStatus) {
|
||||||
newScrollHeight -= _reportSpamPanel->height() - st::lineWidth;
|
newScrollHeight -= _contactStatus->height() - st::lineWidth;
|
||||||
}
|
}
|
||||||
if (!editingMessage() && (isBlocked() || isBotStart() || isJoinChannel() || isMuteUnmute())) {
|
if (!editingMessage() && (isBlocked() || isBotStart() || isJoinChannel() || isMuteUnmute())) {
|
||||||
newScrollHeight -= _unblock->height();
|
newScrollHeight -= _unblock->height();
|
||||||
|
@ -5255,7 +5001,7 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
|
||||||
int HistoryWidget::computeMaxFieldHeight() const {
|
int HistoryWidget::computeMaxFieldHeight() const {
|
||||||
const auto available = height()
|
const auto available = height()
|
||||||
- _topBar->height()
|
- _topBar->height()
|
||||||
- (_reportSpamPanel ? _reportSpamPanel->height() - st::lineWidth : 0)
|
- (_contactStatus ? _contactStatus->height() : 0)
|
||||||
- (_pinnedBar ? st::historyReplyHeight : 0)
|
- (_pinnedBar ? st::historyReplyHeight : 0)
|
||||||
- ((_editMsgId
|
- ((_editMsgId
|
||||||
|| replyToId()
|
|| replyToId()
|
||||||
|
@ -6266,7 +6012,6 @@ void HistoryWidget::fullPeerUpdated(PeerData *peer) {
|
||||||
refresh = true;
|
refresh = true;
|
||||||
}
|
}
|
||||||
onCheckFieldAutocomplete();
|
onCheckFieldAutocomplete();
|
||||||
updateReportSpamStatus();
|
|
||||||
_list->updateBotInfo();
|
_list->updateBotInfo();
|
||||||
|
|
||||||
handlePeerUpdate();
|
handlePeerUpdate();
|
||||||
|
@ -6285,7 +6030,6 @@ void HistoryWidget::fullPeerUpdated(PeerData *peer) {
|
||||||
void HistoryWidget::handlePeerUpdate() {
|
void HistoryWidget::handlePeerUpdate() {
|
||||||
bool resize = false;
|
bool resize = false;
|
||||||
updateHistoryGeometry();
|
updateHistoryGeometry();
|
||||||
if (_peer->isChannel()) updateReportSpamStatus();
|
|
||||||
if (_peer->isChat() && _peer->asChat()->noParticipantInfo()) {
|
if (_peer->isChat() && _peer->asChat()->noParticipantInfo()) {
|
||||||
session().api().requestFullPeer(_peer);
|
session().api().requestFullPeer(_peer);
|
||||||
} else if (_peer->isUser() && (_peer->asUser()->blockStatus() == UserData::BlockStatus::Unknown || _peer->asUser()->callsStatus() == UserData::CallsStatus::Unknown)) {
|
} else if (_peer->isUser() && (_peer->asUser()->blockStatus() == UserData::BlockStatus::Unknown || _peer->asUser()->callsStatus() == UserData::CallsStatus::Unknown)) {
|
||||||
|
|
|
@ -78,6 +78,7 @@ struct UploadedThumbDocument;
|
||||||
|
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
class TopBarWidget;
|
class TopBarWidget;
|
||||||
|
class ContactStatus;
|
||||||
} // namespace HistoryView
|
} // namespace HistoryView
|
||||||
|
|
||||||
class DragArea;
|
class DragArea;
|
||||||
|
@ -87,30 +88,6 @@ class MessageField;
|
||||||
class HistoryInner;
|
class HistoryInner;
|
||||||
struct HistoryMessageMarkupButton;
|
struct HistoryMessageMarkupButton;
|
||||||
|
|
||||||
class ReportSpamPanel : public TWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ReportSpamPanel(QWidget *parent);
|
|
||||||
|
|
||||||
void setReported(bool reported, PeerData *onPeer);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void hideClicked();
|
|
||||||
void reportClicked();
|
|
||||||
void clearClicked();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
|
||||||
void paintEvent(QPaintEvent *e) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
object_ptr<Ui::FlatButton> _report;
|
|
||||||
object_ptr<Ui::FlatButton> _hide;
|
|
||||||
object_ptr<Ui::LinkButton> _clear;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class HistoryWidget final : public Window::AbstractSectionWidget, public RPCSender {
|
class HistoryWidget final : public Window::AbstractSectionWidget, public RPCSender {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -302,10 +279,6 @@ signals:
|
||||||
void cancelled();
|
void cancelled();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onReportSpamClicked();
|
|
||||||
void onReportSpamHide();
|
|
||||||
void onReportSpamClear();
|
|
||||||
|
|
||||||
void onScroll();
|
void onScroll();
|
||||||
|
|
||||||
void onBroadcastSilentChange();
|
void onBroadcastSilentChange();
|
||||||
|
@ -358,7 +331,6 @@ private:
|
||||||
void toggleTabbedSelectorMode();
|
void toggleTabbedSelectorMode();
|
||||||
void returnTabbedSelector(object_ptr<TabbedSelector> selector);
|
void returnTabbedSelector(object_ptr<TabbedSelector> selector);
|
||||||
void recountChatWidth();
|
void recountChatWidth();
|
||||||
void setReportSpamStatus(DBIPeerReportSpamStatus status);
|
|
||||||
void historyDownClicked();
|
void historyDownClicked();
|
||||||
void showNextUnreadMention();
|
void showNextUnreadMention();
|
||||||
void handlePeerUpdate();
|
void handlePeerUpdate();
|
||||||
|
@ -572,19 +544,10 @@ private:
|
||||||
void saveEditMsgDone(History *history, const MTPUpdates &updates, mtpRequestId req);
|
void saveEditMsgDone(History *history, const MTPUpdates &updates, mtpRequestId req);
|
||||||
bool saveEditMsgFail(History *history, const RPCError &error, mtpRequestId req);
|
bool saveEditMsgFail(History *history, const RPCError &error, mtpRequestId req);
|
||||||
|
|
||||||
void updateReportSpamStatus();
|
|
||||||
void requestReportSpamSetting();
|
|
||||||
void reportSpamSettingDone(const MTPPeerSettings &result, mtpRequestId req);
|
|
||||||
bool reportSpamSettingFail(const RPCError &error, mtpRequestId req);
|
|
||||||
|
|
||||||
void checkPreview();
|
void checkPreview();
|
||||||
void requestPreview();
|
void requestPreview();
|
||||||
void gotPreview(QString links, const MTPMessageMedia &media, mtpRequestId req);
|
void gotPreview(QString links, const MTPMessageMedia &media, mtpRequestId req);
|
||||||
|
|
||||||
static const mtpRequestId ReportSpamRequestNeeded = -1;
|
|
||||||
DBIPeerReportSpamStatus _reportSpamStatus = dbiprsUnknown;
|
|
||||||
mtpRequestId _reportSpamSettingRequestId = ReportSpamRequestNeeded;
|
|
||||||
|
|
||||||
QStringList _parsedLinks;
|
QStringList _parsedLinks;
|
||||||
QString _previewLinks;
|
QString _previewLinks;
|
||||||
WebPageData *_previewData = nullptr;
|
WebPageData *_previewData = nullptr;
|
||||||
|
@ -645,9 +608,6 @@ private:
|
||||||
// This one is syntetic.
|
// This one is syntetic.
|
||||||
void synteticScrollToY(int y);
|
void synteticScrollToY(int y);
|
||||||
|
|
||||||
void reportSpamDone(PeerData *peer, const MTPBool &result, mtpRequestId request);
|
|
||||||
bool reportSpamFail(const RPCError &error, mtpRequestId request);
|
|
||||||
|
|
||||||
void countHistoryShowFrom();
|
void countHistoryShowFrom();
|
||||||
|
|
||||||
enum class TextUpdateEvent {
|
enum class TextUpdateEvent {
|
||||||
|
@ -749,7 +709,7 @@ private:
|
||||||
bool showInlineBotCancel() const;
|
bool showInlineBotCancel() const;
|
||||||
void refreshSilentToggle();
|
void refreshSilentToggle();
|
||||||
|
|
||||||
object_ptr<ReportSpamPanel> _reportSpamPanel = { nullptr };
|
std::unique_ptr<HistoryView::ContactStatus> _contactStatus;
|
||||||
|
|
||||||
object_ptr<Ui::SendButton> _send;
|
object_ptr<Ui::SendButton> _send;
|
||||||
object_ptr<Ui::FlatButton> _unblock;
|
object_ptr<Ui::FlatButton> _unblock;
|
||||||
|
@ -758,7 +718,6 @@ private:
|
||||||
object_ptr<Ui::FlatButton> _muteUnmute;
|
object_ptr<Ui::FlatButton> _muteUnmute;
|
||||||
object_ptr<Ui::FlatButton> _discuss;
|
object_ptr<Ui::FlatButton> _discuss;
|
||||||
object_ptr<Ui::RpWidget> _aboutProxyPromotion = { nullptr };
|
object_ptr<Ui::RpWidget> _aboutProxyPromotion = { nullptr };
|
||||||
mtpRequestId _reportSpamRequest = 0;
|
|
||||||
object_ptr<Ui::IconButton> _attachToggle;
|
object_ptr<Ui::IconButton> _attachToggle;
|
||||||
object_ptr<Ui::EmojiButton> _tabbedSelectorToggle;
|
object_ptr<Ui::EmojiButton> _tabbedSelectorToggle;
|
||||||
object_ptr<Ui::ImportantTooltip> _tabbedSelectorToggleTooltip = { nullptr };
|
object_ptr<Ui::ImportantTooltip> _tabbedSelectorToggleTooltip = { nullptr };
|
||||||
|
|
|
@ -0,0 +1,251 @@
|
||||||
|
/*
|
||||||
|
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 "history/view/history_view_contact_status.h"
|
||||||
|
|
||||||
|
#include "lang/lang_keys.h"
|
||||||
|
#include "ui/widgets/buttons.h"
|
||||||
|
#include "data/data_peer.h"
|
||||||
|
#include "data/data_user.h"
|
||||||
|
#include "data/data_chat.h"
|
||||||
|
#include "data/data_channel.h"
|
||||||
|
#include "apiwrap.h"
|
||||||
|
#include "auth_session.h"
|
||||||
|
#include "styles/style_history.h"
|
||||||
|
#include "styles/style_info.h"
|
||||||
|
|
||||||
|
namespace HistoryView {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
bool BarCurrentlyHidden(not_null<PeerData*> peer) {
|
||||||
|
const auto settings = peer->settings();
|
||||||
|
if (!settings) {
|
||||||
|
return false;
|
||||||
|
} else if (!(*settings)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
using Setting = MTPDpeerSettings::Flag;
|
||||||
|
if (const auto user = peer->asUser()) {
|
||||||
|
if (user->isContact()
|
||||||
|
&& !((*settings) & Setting::f_share_contact)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (!((*settings) & Setting::f_report_spam)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
//
|
||||||
|
//void HistoryWidget::onReportSpamClicked() {
|
||||||
|
// auto text = lang(_peer->isUser() ? lng_report_spam_sure : ((_peer->isChat() || _peer->isMegagroup()) ? lng_report_spam_sure_group : lng_report_spam_sure_channel));
|
||||||
|
// Ui::show(Box<ConfirmBox>(text, lang(lng_report_spam_ok), st::attentionBoxButton, crl::guard(this, [this, peer = _peer] {
|
||||||
|
// if (_reportSpamRequest) return;
|
||||||
|
//
|
||||||
|
// Ui::hideLayer();
|
||||||
|
// _reportSpamRequest = MTP::send(
|
||||||
|
// MTPmessages_ReportSpam(peer->input),
|
||||||
|
// rpcDone(&HistoryWidget::reportSpamDone, peer),
|
||||||
|
// rpcFail(&HistoryWidget::reportSpamFail), 0, 5);
|
||||||
|
// if (const auto user = peer->asUser()) {
|
||||||
|
// session().api().blockUser(user);
|
||||||
|
// }
|
||||||
|
// })));
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void HistoryWidget::reportSpamDone(PeerData *peer, const MTPBool &result, mtpRequestId req) {
|
||||||
|
// Expects(peer != nullptr);
|
||||||
|
//
|
||||||
|
// if (req == _reportSpamRequest) {
|
||||||
|
// _reportSpamRequest = 0;
|
||||||
|
// }
|
||||||
|
// cRefReportSpamStatuses().insert(peer->id, dbiprsReportSent);
|
||||||
|
// Local::writeReportSpamStatuses();
|
||||||
|
// if (_peer == peer) {
|
||||||
|
// setReportSpamStatus(dbiprsReportSent);
|
||||||
|
// if (_reportSpamPanel) {
|
||||||
|
// _reportSpamPanel->setReported(_reportSpamStatus == dbiprsReportSent, peer);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//bool HistoryWidget::reportSpamFail(const RPCError &error, mtpRequestId req) {
|
||||||
|
// if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
//
|
||||||
|
// if (req == _reportSpamRequest) {
|
||||||
|
// _reportSpamRequest = 0;
|
||||||
|
// }
|
||||||
|
// return false;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void HistoryWidget::onReportSpamHide() {
|
||||||
|
// if (_peer) {
|
||||||
|
// cRefReportSpamStatuses().insert(_peer->id, dbiprsHidden);
|
||||||
|
// Local::writeReportSpamStatuses();
|
||||||
|
//
|
||||||
|
// MTP::send(MTPmessages_HidePeerSettingsBar(_peer->input));
|
||||||
|
// }
|
||||||
|
// setReportSpamStatus(dbiprsHidden);
|
||||||
|
// updateControlsVisibility();
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void HistoryWidget::onReportSpamClear() {
|
||||||
|
// Expects(_peer != nullptr);
|
||||||
|
//
|
||||||
|
// InvokeQueued(App::main(), [peer = _peer] {
|
||||||
|
// Ui::showChatsList();
|
||||||
|
// if (const auto from = peer->migrateFrom()) {
|
||||||
|
// peer->session().api().deleteConversation(from, false);
|
||||||
|
// }
|
||||||
|
// peer->session().api().deleteConversation(peer, false);
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// // Invalidates _peer.
|
||||||
|
// controller()->showBackFromStack();
|
||||||
|
//}
|
||||||
|
|
||||||
|
ContactStatus::Bar::Bar(QWidget *parent)
|
||||||
|
: RpWidget(parent)
|
||||||
|
, _block(this, lang(lng_new_contact_block), st::historyUnblock)
|
||||||
|
, _add(this, lang(lng_new_contact_add), st::historyComposeButton)
|
||||||
|
, _share(this, lang(lng_new_contact_share), st::historyComposeButton)
|
||||||
|
, _report(this, lang(lng_report_spam), st::historyUnblock)
|
||||||
|
, _close(this, st::infoTopBarClose) {
|
||||||
|
resize(_close->size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContactStatus::Bar::showState(State state) {
|
||||||
|
_add->setVisible(state == State::BlockOrAdd);
|
||||||
|
_block->setVisible(state == State::BlockOrAdd);
|
||||||
|
_share->setVisible(state == State::SharePhoneNumber);
|
||||||
|
_report->setVisible(state == State::ReportSpam);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContactStatus::Bar::resizeEvent(QResizeEvent *e) {
|
||||||
|
_close->moveToRight(0, 0);
|
||||||
|
_add->setGeometry(0, 0, width() / 2, height());
|
||||||
|
_block->setGeometry(width() / 2, 0, width() - (width() / 2), height());
|
||||||
|
_share->setGeometry(rect());
|
||||||
|
_report->setGeometry(rect());
|
||||||
|
}
|
||||||
|
|
||||||
|
ContactStatus::ContactStatus(not_null<Ui::RpWidget*> parent, not_null<PeerData*> peer)
|
||||||
|
: _bar(parent, object_ptr<Bar>(parent))
|
||||||
|
, _shadow(parent) {
|
||||||
|
setupWidgets(parent);
|
||||||
|
setupState(peer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContactStatus::setupWidgets(not_null<Ui::RpWidget*> parent) {
|
||||||
|
parent->widthValue(
|
||||||
|
) | rpl::start_with_next([=](int width) {
|
||||||
|
_bar.resizeToWidth(width);
|
||||||
|
}, _bar.lifetime());
|
||||||
|
|
||||||
|
_bar.geometryValue(
|
||||||
|
) | rpl::start_with_next([=](QRect geometry) {
|
||||||
|
_shadow.setGeometry(
|
||||||
|
geometry.x(),
|
||||||
|
geometry.y() + geometry.height(),
|
||||||
|
geometry.width(),
|
||||||
|
st::lineWidth);
|
||||||
|
}, _shadow.lifetime());
|
||||||
|
|
||||||
|
_bar.shownValue(
|
||||||
|
) | rpl::start_with_next([=](bool shown) {
|
||||||
|
_shadow.setVisible(shown);
|
||||||
|
}, _shadow.lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto ContactStatus::PeerState(not_null<PeerData*> peer)
|
||||||
|
-> rpl::producer<State> {
|
||||||
|
using SettingsChange = PeerData::Settings::Change;
|
||||||
|
using Settings = MTPDpeerSettings::Flags;
|
||||||
|
using Setting = MTPDpeerSettings::Flag;
|
||||||
|
if (const auto user = peer->asUser()) {
|
||||||
|
using FlagsChange = UserData::Flags::Change;
|
||||||
|
using Flags = MTPDuser::Flags;
|
||||||
|
using Flag = MTPDuser::Flag;
|
||||||
|
|
||||||
|
auto isContactChanges = user->flagsValue(
|
||||||
|
) | rpl::filter([](FlagsChange flags) {
|
||||||
|
return flags.diff
|
||||||
|
& (Flag::f_contact | Flag::f_mutual_contact);
|
||||||
|
});
|
||||||
|
return rpl::combine(
|
||||||
|
std::move(isContactChanges),
|
||||||
|
user->settingsValue()
|
||||||
|
) | rpl::map([=](FlagsChange flags, SettingsChange settings) {
|
||||||
|
if (!settings.value) {
|
||||||
|
return State::None;
|
||||||
|
} else if (user->isContact()) {
|
||||||
|
if (settings.value & Setting::f_share_contact) {
|
||||||
|
return State::SharePhoneNumber;
|
||||||
|
} else {
|
||||||
|
return State::None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return State::BlockOrAdd;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return peer->settingsValue(
|
||||||
|
) | rpl::map([=](SettingsChange settings) {
|
||||||
|
return (settings.value & Setting::f_report_spam)
|
||||||
|
? State::ReportSpam
|
||||||
|
: State::None;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContactStatus::setupState(not_null<PeerData*> peer) {
|
||||||
|
if (!BarCurrentlyHidden(peer)) {
|
||||||
|
peer->session().api().requestPeerSettings(peer);
|
||||||
|
}
|
||||||
|
PeerState(
|
||||||
|
peer
|
||||||
|
) | rpl::start_with_next([=](State state) {
|
||||||
|
if (state == State::None) {
|
||||||
|
_bar.hide(anim::type::normal);
|
||||||
|
} else {
|
||||||
|
_bar.entity()->showState(state);
|
||||||
|
_bar.show(anim::type::normal);
|
||||||
|
}
|
||||||
|
}, _bar.lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContactStatus::show() {
|
||||||
|
if (_shown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_shown = true;
|
||||||
|
const auto visible = (_state != State::None);
|
||||||
|
if (visible) {
|
||||||
|
_bar.entity()->showState(_state);
|
||||||
|
}
|
||||||
|
_bar.toggle(visible, anim::type::instant);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContactStatus::raise() {
|
||||||
|
_bar.raise();
|
||||||
|
_shadow.raise();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContactStatus::move(int x, int y) {
|
||||||
|
_bar.move(x, y);
|
||||||
|
_shadow.move(x, y + _bar.height());
|
||||||
|
}
|
||||||
|
|
||||||
|
int ContactStatus::height() const {
|
||||||
|
return _bar.height();
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<int> ContactStatus::heightValue() const {
|
||||||
|
return _bar.heightValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace HistoryView
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
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 "ui/rp_widget.h"
|
||||||
|
#include "ui/wrap/slide_wrap.h"
|
||||||
|
#include "ui/widgets/shadow.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class FlatButton;
|
||||||
|
class IconButton;
|
||||||
|
} // namespace Ui
|
||||||
|
|
||||||
|
namespace HistoryView {
|
||||||
|
|
||||||
|
class ContactStatus final {
|
||||||
|
public:
|
||||||
|
ContactStatus(not_null<Ui::RpWidget*> parent, not_null<PeerData*> peer);
|
||||||
|
|
||||||
|
void show();
|
||||||
|
void raise();
|
||||||
|
|
||||||
|
void move(int x, int y);
|
||||||
|
int height() const;
|
||||||
|
rpl::producer<int> heightValue() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum class State {
|
||||||
|
None,
|
||||||
|
ReportSpam,
|
||||||
|
BlockOrAdd,
|
||||||
|
SharePhoneNumber,
|
||||||
|
};
|
||||||
|
|
||||||
|
class Bar : public Ui::RpWidget {
|
||||||
|
public:
|
||||||
|
explicit Bar(QWidget *parent);
|
||||||
|
|
||||||
|
void showState(State state);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
object_ptr<Ui::FlatButton> _block;
|
||||||
|
object_ptr<Ui::FlatButton> _add;
|
||||||
|
object_ptr<Ui::FlatButton> _share;
|
||||||
|
object_ptr<Ui::FlatButton> _report;
|
||||||
|
object_ptr<Ui::IconButton> _close;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void setupWidgets(not_null<Ui::RpWidget*> parent);
|
||||||
|
void setupState(not_null<PeerData*> peer);
|
||||||
|
|
||||||
|
static rpl::producer<State> PeerState(not_null<PeerData*> peer);
|
||||||
|
|
||||||
|
State _state = State::None;
|
||||||
|
Ui::SlideWrap<Bar> _bar;
|
||||||
|
Ui::PlainShadow _shadow;
|
||||||
|
bool _shown = false;
|
||||||
|
|
||||||
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace HistoryView
|
|
@ -4215,8 +4215,11 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updatePeerSettings: {
|
case mtpc_updatePeerSettings: {
|
||||||
//const auto &d = update.c_updateContactLink();
|
const auto &d = update.c_updatePeerSettings();
|
||||||
//App::feedUserLink(d.vuser_id, d.vmy_link, d.vforeign_link);
|
const auto peerId = peerFromMTP(d.vpeer);
|
||||||
|
if (const auto peer = session().data().peerLoaded(peerId)) {
|
||||||
|
//peer->updateSettings(d.vsettings);
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateNotifySettings: {
|
case mtpc_updateNotifySettings: {
|
||||||
|
@ -4278,9 +4281,9 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateUserBlocked: {
|
case mtpc_updateUserBlocked: {
|
||||||
auto &d = update.c_updateUserBlocked();
|
const auto &d = update.c_updateUserBlocked();
|
||||||
if (auto user = session().data().userLoaded(d.vuser_id.v)) {
|
if (const auto user = session().data().userLoaded(d.vuser_id.v)) {
|
||||||
user->setBlockStatus(mtpIsTrue(d.vblocked) ? UserData::BlockStatus::Blocked : UserData::BlockStatus::NotBlocked);
|
user->setIsBlocked(mtpIsTrue(d.vblocked));
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
|
|
@ -69,8 +69,6 @@ int32 gIntRetinaFactor = 1;
|
||||||
|
|
||||||
int gOtherOnline = 0;
|
int gOtherOnline = 0;
|
||||||
|
|
||||||
ReportSpamStatuses gReportSpamStatuses;
|
|
||||||
|
|
||||||
int32 gAutoDownloadPhoto = 0; // all auto download
|
int32 gAutoDownloadPhoto = 0; // all auto download
|
||||||
int32 gAutoDownloadAudio = 0;
|
int32 gAutoDownloadAudio = 0;
|
||||||
int32 gAutoDownloadGif = 0;
|
int32 gAutoDownloadGif = 0;
|
||||||
|
|
|
@ -158,10 +158,6 @@ DeclareSetting(float64, RetinaFactor);
|
||||||
DeclareSetting(int32, IntRetinaFactor);
|
DeclareSetting(int32, IntRetinaFactor);
|
||||||
|
|
||||||
DeclareSetting(int, OtherOnline);
|
DeclareSetting(int, OtherOnline);
|
||||||
|
|
||||||
typedef QMap<uint64, DBIPeerReportSpamStatus> ReportSpamStatuses;
|
|
||||||
DeclareRefSetting(ReportSpamStatuses, ReportSpamStatuses);
|
|
||||||
|
|
||||||
DeclareSetting(bool, AutoPlayGif);
|
DeclareSetting(bool, AutoPlayGif);
|
||||||
|
|
||||||
constexpr auto kInterfaceScaleAuto = 0;
|
constexpr auto kInterfaceScaleAuto = 0;
|
||||||
|
|
|
@ -234,7 +234,7 @@ void BlockedBoxController::receivedUsers(const QVector<MTPContactBlocked> &resul
|
||||||
item.match([&](const MTPDcontactBlocked &data) {
|
item.match([&](const MTPDcontactBlocked &data) {
|
||||||
if (const auto user = Auth().data().userLoaded(data.vuser_id.v)) {
|
if (const auto user = Auth().data().userLoaded(data.vuser_id.v)) {
|
||||||
appendRow(user);
|
appendRow(user);
|
||||||
user->setBlockStatus(UserData::BlockStatus::Blocked);
|
user->setIsBlocked(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -518,7 +518,7 @@ enum { // Local Storage Keys
|
||||||
lskRecentHashtagsAndBots = 0x0a, // no data
|
lskRecentHashtagsAndBots = 0x0a, // no data
|
||||||
lskStickersOld = 0x0b, // no data
|
lskStickersOld = 0x0b, // no data
|
||||||
lskSavedPeersOld = 0x0c, // no data
|
lskSavedPeersOld = 0x0c, // no data
|
||||||
lskReportSpamStatuses = 0x0d, // no data
|
lskReportSpamStatusesOld = 0x0d, // no data
|
||||||
lskSavedGifsOld = 0x0e, // no data
|
lskSavedGifsOld = 0x0e, // no data
|
||||||
lskSavedGifs = 0x0f, // no data
|
lskSavedGifs = 0x0f, // no data
|
||||||
lskStickersKeys = 0x10, // no data
|
lskStickersKeys = 0x10, // no data
|
||||||
|
@ -645,7 +645,7 @@ typedef QMap<QString, FileLocationPair> FileLocationPairs;
|
||||||
FileLocationPairs _fileLocationPairs;
|
FileLocationPairs _fileLocationPairs;
|
||||||
typedef QMap<MediaKey, MediaKey> FileLocationAliases;
|
typedef QMap<MediaKey, MediaKey> FileLocationAliases;
|
||||||
FileLocationAliases _fileLocationAliases;
|
FileLocationAliases _fileLocationAliases;
|
||||||
FileKey _locationsKey = 0, _reportSpamStatusesKey = 0, _trustedBotsKey = 0;
|
FileKey _locationsKey = 0, _trustedBotsKey = 0;
|
||||||
|
|
||||||
using TrustedBots = OrderedSet<uint64>;
|
using TrustedBots = OrderedSet<uint64>;
|
||||||
TrustedBots _trustedBots;
|
TrustedBots _trustedBots;
|
||||||
|
@ -838,63 +838,6 @@ void _readLocations() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _writeReportSpamStatuses() {
|
|
||||||
if (!_working()) return;
|
|
||||||
|
|
||||||
if (cReportSpamStatuses().isEmpty()) {
|
|
||||||
if (_reportSpamStatusesKey) {
|
|
||||||
clearKey(_reportSpamStatusesKey);
|
|
||||||
_reportSpamStatusesKey = 0;
|
|
||||||
_mapChanged = true;
|
|
||||||
_writeMap();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!_reportSpamStatusesKey) {
|
|
||||||
_reportSpamStatusesKey = genKey();
|
|
||||||
_mapChanged = true;
|
|
||||||
_writeMap(WriteMapWhen::Fast);
|
|
||||||
}
|
|
||||||
const ReportSpamStatuses &statuses(cReportSpamStatuses());
|
|
||||||
|
|
||||||
quint32 size = sizeof(qint32);
|
|
||||||
for (ReportSpamStatuses::const_iterator i = statuses.cbegin(), e = statuses.cend(); i != e; ++i) {
|
|
||||||
// peer + status
|
|
||||||
size += sizeof(quint64) + sizeof(qint32);
|
|
||||||
}
|
|
||||||
|
|
||||||
EncryptedDescriptor data(size);
|
|
||||||
data.stream << qint32(statuses.size());
|
|
||||||
for (ReportSpamStatuses::const_iterator i = statuses.cbegin(), e = statuses.cend(); i != e; ++i) {
|
|
||||||
data.stream << quint64(i.key()) << qint32(i.value());
|
|
||||||
}
|
|
||||||
|
|
||||||
FileWriteDescriptor file(_reportSpamStatusesKey);
|
|
||||||
file.writeEncrypted(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _readReportSpamStatuses() {
|
|
||||||
FileReadDescriptor statuses;
|
|
||||||
if (!readEncryptedFile(statuses, _reportSpamStatusesKey)) {
|
|
||||||
clearKey(_reportSpamStatusesKey);
|
|
||||||
_reportSpamStatusesKey = 0;
|
|
||||||
_writeMap();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReportSpamStatuses &map(cRefReportSpamStatuses());
|
|
||||||
map.clear();
|
|
||||||
|
|
||||||
qint32 size = 0;
|
|
||||||
statuses.stream >> size;
|
|
||||||
for (int32 i = 0; i < size; ++i) {
|
|
||||||
quint64 peer = 0;
|
|
||||||
qint32 status = 0;
|
|
||||||
statuses.stream >> peer >> status;
|
|
||||||
map.insert(peer, DBIPeerReportSpamStatus(status));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ReadSettingsContext {
|
struct ReadSettingsContext {
|
||||||
int legacyLanguageId = Lang::kLegacyLanguageNone;
|
int legacyLanguageId = Lang::kLegacyLanguageNone;
|
||||||
QString legacyLanguageFile;
|
QString legacyLanguageFile;
|
||||||
|
@ -2352,8 +2295,9 @@ ReadMapState _readMap(const QByteArray &pass) {
|
||||||
case lskLocations: {
|
case lskLocations: {
|
||||||
map.stream >> locationsKey;
|
map.stream >> locationsKey;
|
||||||
} break;
|
} break;
|
||||||
case lskReportSpamStatuses: {
|
case lskReportSpamStatusesOld: {
|
||||||
map.stream >> reportSpamStatusesKey;
|
map.stream >> reportSpamStatusesKey;
|
||||||
|
clearKey(reportSpamStatusesKey);
|
||||||
} break;
|
} break;
|
||||||
case lskTrustedBots: {
|
case lskTrustedBots: {
|
||||||
map.stream >> trustedBotsKey;
|
map.stream >> trustedBotsKey;
|
||||||
|
@ -2412,7 +2356,6 @@ ReadMapState _readMap(const QByteArray &pass) {
|
||||||
_draftsNotReadMap = draftsNotReadMap;
|
_draftsNotReadMap = draftsNotReadMap;
|
||||||
|
|
||||||
_locationsKey = locationsKey;
|
_locationsKey = locationsKey;
|
||||||
_reportSpamStatusesKey = reportSpamStatusesKey;
|
|
||||||
_trustedBotsKey = trustedBotsKey;
|
_trustedBotsKey = trustedBotsKey;
|
||||||
_recentStickersKeyOld = recentStickersKeyOld;
|
_recentStickersKeyOld = recentStickersKeyOld;
|
||||||
_installedStickersKey = installedStickersKey;
|
_installedStickersKey = installedStickersKey;
|
||||||
|
@ -2437,9 +2380,6 @@ ReadMapState _readMap(const QByteArray &pass) {
|
||||||
if (_locationsKey) {
|
if (_locationsKey) {
|
||||||
_readLocations();
|
_readLocations();
|
||||||
}
|
}
|
||||||
if (_reportSpamStatusesKey) {
|
|
||||||
_readReportSpamStatuses();
|
|
||||||
}
|
|
||||||
|
|
||||||
_readUserSettings();
|
_readUserSettings();
|
||||||
_readMtpData();
|
_readMtpData();
|
||||||
|
@ -2516,7 +2456,6 @@ void _writeMap(WriteMapWhen when) {
|
||||||
if (!_draftsMap.isEmpty()) mapSize += sizeof(quint32) * 2 + _draftsMap.size() * sizeof(quint64) * 2;
|
if (!_draftsMap.isEmpty()) mapSize += sizeof(quint32) * 2 + _draftsMap.size() * sizeof(quint64) * 2;
|
||||||
if (!_draftCursorsMap.isEmpty()) mapSize += sizeof(quint32) * 2 + _draftCursorsMap.size() * sizeof(quint64) * 2;
|
if (!_draftCursorsMap.isEmpty()) mapSize += sizeof(quint32) * 2 + _draftCursorsMap.size() * sizeof(quint64) * 2;
|
||||||
if (_locationsKey) mapSize += sizeof(quint32) + sizeof(quint64);
|
if (_locationsKey) mapSize += sizeof(quint32) + sizeof(quint64);
|
||||||
if (_reportSpamStatusesKey) mapSize += sizeof(quint32) + sizeof(quint64);
|
|
||||||
if (_trustedBotsKey) mapSize += sizeof(quint32) + sizeof(quint64);
|
if (_trustedBotsKey) mapSize += sizeof(quint32) + sizeof(quint64);
|
||||||
if (_recentStickersKeyOld) mapSize += sizeof(quint32) + sizeof(quint64);
|
if (_recentStickersKeyOld) mapSize += sizeof(quint32) + sizeof(quint64);
|
||||||
if (_installedStickersKey || _featuredStickersKey || _recentStickersKey || _archivedStickersKey) {
|
if (_installedStickersKey || _featuredStickersKey || _recentStickersKey || _archivedStickersKey) {
|
||||||
|
@ -2548,9 +2487,6 @@ void _writeMap(WriteMapWhen when) {
|
||||||
if (_locationsKey) {
|
if (_locationsKey) {
|
||||||
mapData.stream << quint32(lskLocations) << quint64(_locationsKey);
|
mapData.stream << quint32(lskLocations) << quint64(_locationsKey);
|
||||||
}
|
}
|
||||||
if (_reportSpamStatusesKey) {
|
|
||||||
mapData.stream << quint32(lskReportSpamStatuses) << quint64(_reportSpamStatusesKey);
|
|
||||||
}
|
|
||||||
if (_trustedBotsKey) {
|
if (_trustedBotsKey) {
|
||||||
mapData.stream << quint32(lskTrustedBots) << quint64(_trustedBotsKey);
|
mapData.stream << quint32(lskTrustedBots) << quint64(_trustedBotsKey);
|
||||||
}
|
}
|
||||||
|
@ -2837,7 +2773,7 @@ void reset() {
|
||||||
_fileLocationPairs.clear();
|
_fileLocationPairs.clear();
|
||||||
_fileLocationAliases.clear();
|
_fileLocationAliases.clear();
|
||||||
_draftsNotReadMap.clear();
|
_draftsNotReadMap.clear();
|
||||||
_locationsKey = _reportSpamStatusesKey = _trustedBotsKey = 0;
|
_locationsKey = _trustedBotsKey = 0;
|
||||||
_recentStickersKeyOld = 0;
|
_recentStickersKeyOld = 0;
|
||||||
_installedStickersKey = _featuredStickersKey = _recentStickersKey = _favedStickersKey = _archivedStickersKey = 0;
|
_installedStickersKey = _featuredStickersKey = _recentStickersKey = _favedStickersKey = _archivedStickersKey = 0;
|
||||||
_savedGifsKey = 0;
|
_savedGifsKey = 0;
|
||||||
|
@ -2879,7 +2815,6 @@ void setPasscode(const QByteArray &passcode) {
|
||||||
base::flat_set<QString> CollectGoodNames() {
|
base::flat_set<QString> CollectGoodNames() {
|
||||||
const auto keys = {
|
const auto keys = {
|
||||||
_locationsKey,
|
_locationsKey,
|
||||||
_reportSpamStatusesKey,
|
|
||||||
_userSettingsKey,
|
_userSettingsKey,
|
||||||
_installedStickersKey,
|
_installedStickersKey,
|
||||||
_featuredStickersKey,
|
_featuredStickersKey,
|
||||||
|
@ -4838,10 +4773,6 @@ Export::Settings ReadExportSettings() {
|
||||||
: Export::Settings();
|
: Export::Settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeReportSpamStatuses() {
|
|
||||||
_writeReportSpamStatuses();
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeSelf() {
|
void writeSelf() {
|
||||||
_mapChanged = true;
|
_mapChanged = true;
|
||||||
_writeMap();
|
_writeMap();
|
||||||
|
@ -4976,10 +4907,6 @@ bool ClearManager::addTask(int task) {
|
||||||
_locationsKey = 0;
|
_locationsKey = 0;
|
||||||
_mapChanged = true;
|
_mapChanged = true;
|
||||||
}
|
}
|
||||||
if (_reportSpamStatusesKey) {
|
|
||||||
_reportSpamStatusesKey = 0;
|
|
||||||
_mapChanged = true;
|
|
||||||
}
|
|
||||||
if (_trustedBotsKey) {
|
if (_trustedBotsKey) {
|
||||||
_trustedBotsKey = 0;
|
_trustedBotsKey = 0;
|
||||||
_mapChanged = true;
|
_mapChanged = true;
|
||||||
|
|
|
@ -169,8 +169,6 @@ void saveRecentSearchHashtags(const QString &text);
|
||||||
void WriteExportSettings(const Export::Settings &settings);
|
void WriteExportSettings(const Export::Settings &settings);
|
||||||
Export::Settings ReadExportSettings();
|
Export::Settings ReadExportSettings();
|
||||||
|
|
||||||
void writeReportSpamStatuses();
|
|
||||||
|
|
||||||
void writeSelf();
|
void writeSelf();
|
||||||
void readSelf(const QByteArray &serialized, int32 streamVersion);
|
void readSelf(const QByteArray &serialized, int32 streamVersion);
|
||||||
|
|
||||||
|
|
|
@ -296,6 +296,8 @@
|
||||||
<(src_loc)/history/media/history_media_wall_paper.cpp
|
<(src_loc)/history/media/history_media_wall_paper.cpp
|
||||||
<(src_loc)/history/media/history_media_web_page.h
|
<(src_loc)/history/media/history_media_web_page.h
|
||||||
<(src_loc)/history/media/history_media_web_page.cpp
|
<(src_loc)/history/media/history_media_web_page.cpp
|
||||||
|
<(src_loc)/history/view/history_view_contact_status.cpp
|
||||||
|
<(src_loc)/history/view/history_view_contact_status.h
|
||||||
<(src_loc)/history/view/history_view_context_menu.cpp
|
<(src_loc)/history/view/history_view_context_menu.cpp
|
||||||
<(src_loc)/history/view/history_view_context_menu.h
|
<(src_loc)/history/view/history_view_context_menu.h
|
||||||
<(src_loc)/history/view/history_view_cursor_state.cpp
|
<(src_loc)/history/view/history_view_cursor_state.cpp
|
||||||
|
|
Loading…
Reference in New Issue