mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-04-01 00:08:02 +00:00
Removed "Export history" from context menu for empty chats.
This commit is contained in:
parent
5d04842a80
commit
2aecd1035e
@ -7,8 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "data/data_peer.h"
|
||||
|
||||
#include <rpl/filter.h>
|
||||
#include <rpl/map.h>
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_channel.h"
|
||||
@ -26,6 +24,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/empty_userpic.h"
|
||||
#include "ui/text_options.h"
|
||||
#include "history/history.h"
|
||||
#include "history/view/history_view_element.h"
|
||||
#include "history/history_item.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -376,6 +377,17 @@ void PeerData::setPinnedMessageId(MsgId messageId) {
|
||||
}
|
||||
}
|
||||
|
||||
bool PeerData::canExportChatHistory() const {
|
||||
for (const auto &block : _owner->history(id)->blocks) {
|
||||
for (const auto &message : block->messages) {
|
||||
if (!message->data()->serviceMsg()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PeerData::setAbout(const QString &newAbout) {
|
||||
if (_about == newAbout) {
|
||||
return false;
|
||||
|
@ -274,6 +274,8 @@ public:
|
||||
setPinnedMessageId(0);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool canExportChatHistory() const;
|
||||
|
||||
// Returns true if about text was changed.
|
||||
bool setAbout(const QString &newAbout);
|
||||
const QString &about() const {
|
||||
|
@ -336,10 +336,12 @@ void Filler::addUserActions(not_null<UserData*> user) {
|
||||
lang(lng_profile_invite_to_group),
|
||||
[user] { AddBotToGroupBoxController::Start(user); });
|
||||
}
|
||||
if (user->canExportChatHistory()) {
|
||||
_addAction(
|
||||
lang(lng_profile_export_chat),
|
||||
[=] { PeerMenuExportChat(user); });
|
||||
}
|
||||
}
|
||||
_addAction(
|
||||
lang(lng_profile_delete_conversation),
|
||||
DeleteAndLeaveHandler(user));
|
||||
@ -369,10 +371,12 @@ void Filler::addChatActions(not_null<ChatData*> chat) {
|
||||
lang(lng_polls_create),
|
||||
[=] { PeerMenuCreatePoll(chat); });
|
||||
}
|
||||
if (chat->canExportChatHistory()) {
|
||||
_addAction(
|
||||
lang(lng_profile_export_chat),
|
||||
[=] { PeerMenuExportChat(chat); });
|
||||
}
|
||||
}
|
||||
_addAction(
|
||||
lang(lng_profile_clear_and_exit),
|
||||
DeleteAndLeaveHandler(_peer));
|
||||
@ -411,12 +415,14 @@ void Filler::addChannelActions(not_null<ChannelData*> channel) {
|
||||
lang(lng_polls_create),
|
||||
[=] { PeerMenuCreatePoll(channel); });
|
||||
}
|
||||
if (channel->canExportChatHistory()) {
|
||||
_addAction(
|
||||
lang(isGroup
|
||||
? lng_profile_export_chat
|
||||
: lng_profile_export_channel),
|
||||
[=] { PeerMenuExportChat(channel); });
|
||||
}
|
||||
}
|
||||
if (channel->amIn()) {
|
||||
if (isGroup && !channel->isPublic()) {
|
||||
_addAction(
|
||||
|
Loading…
Reference in New Issue
Block a user