1
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-03-30 07:18:28 +00:00

Delete button for large channels is hidden now

(server doesn't allow to delete large channels any more).

Error message added in a case when the current user
(not admin) tries to add to a supergroup a user who
was kicked by admin (and blacklisted by this action).
This commit is contained in:
John Preston 2016-03-23 19:50:40 +03:00
parent 4a5b63bbcd
commit 034adfab2b
5 changed files with 32 additions and 9 deletions

View File

@ -682,6 +682,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
"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_channel" = "Sorry, you can only add mutual contacts\nto channels at the moment.\n{more_info}";
"lng_cant_more_info" = "More info »";
"lng_cant_invite_banned" = "Sorry, only admin can add this user.";
"lng_cant_invite_privacy" = "Sorry, you cannot add this user to groups because of the privacy settings.";
"lng_cant_invite_privacy_channel" = "Sorry, you cannot add this user to channels because of the privacy settings.";

View File

@ -1147,7 +1147,9 @@ bool MainWidget::addParticipantFail(UserData *user, const RPCError &error) {
if (mtpIsFlood(error)) return false;
QString text = lang(lng_failed_add_participant);
if (error.type() == "USER_LEFT_CHAT") { // trying to return banned user to his group
if (error.type() == "USER_LEFT_CHAT") { // trying to return a user who has left
} else if (error.type() == "USER_KICKED") { // trying to return a user who was kicked by admin
text = lang(lng_cant_invite_banned);
} else if (error.type() == "USER_PRIVACY_RESTRICTED") {
text = lang(lng_cant_invite_privacy);
} else if (error.type() == "USER_NOT_MUTUAL_CONTACT") { // trying to return user who does not have me in contacts
@ -1166,8 +1168,10 @@ bool MainWidget::addParticipantsFail(ChannelData *channel, const RPCError &error
QString text = lang(lng_failed_add_participant);
if (error.type() == "USER_LEFT_CHAT") { // trying to return banned user to his group
} else if (error.type() == "USER_KICKED") { // trying to return a user who was kicked by admin
text = lang(lng_cant_invite_banned);
} else if (error.type() == "USER_PRIVACY_RESTRICTED") {
text = lang(lng_cant_invite_privacy_channel);
text = lang(channel->isMegagroup() ? lng_cant_invite_privacy : lng_cant_invite_privacy_channel);
} else if (error.type() == "USER_NOT_MUTUAL_CONTACT") { // trying to return user who does not have me in contacts
text = lang(channel->isMegagroup() ? lng_failed_add_not_mutual : lng_failed_add_not_mutual_channel);
} else if (error.type() == "PEER_FLOOD") {
@ -2595,6 +2599,16 @@ void MainWidget::sentUpdatesReceived(uint64 randomId, const MTPUpdates &result)
App::emitPeerUpdated();
}
bool MainWidget::deleteChannelFailed(const RPCError &error) {
if (mtpIsFlood(error)) return false;
//if (error.type() == qstr("CHANNEL_TOO_LARGE")) {
// Ui::showLayer(new InformBox(lang(lng_cant_delete_channel)));
//}
return true;
}
void MainWidget::inviteToChannelDone(ChannelData *channel, const MTPUpdates &updates) {
sentUpdatesReceived(updates);
QTimer::singleShot(ReloadChannelMembersTimeout, this, SLOT(onActiveChannelUpdateFull()));

View File

@ -251,6 +251,7 @@ public:
void sentUpdatesReceived(const MTPUpdates &updates) {
return sentUpdatesReceived(0, updates);
}
bool deleteChannelFailed(const RPCError &error);
void inviteToChannelDone(ChannelData *channel, const MTPUpdates &updates);
void historyToDown(History *hist);
void dialogsToUp();

View File

@ -364,7 +364,7 @@ void ProfileInner::onDeleteChannelSure() {
if (_peerChannel->migrateFrom()) {
App::main()->deleteConversation(_peerChannel->migrateFrom());
}
MTP::send(MTPchannels_DeleteChannel(_peerChannel->inputChannel), App::main()->rpcDone(&MainWidget::sentUpdatesReceived));
MTP::send(MTPchannels_DeleteChannel(_peerChannel->inputChannel), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::deleteChannelFailed));
}
}
void ProfileInner::onBlockUser() {
@ -978,7 +978,7 @@ void ProfileInner::paintEvent(QPaintEvent *e) {
}
if (_peerUser && peerToUser(_peerUser->id) != MTP::authedId()) {
top += st::setSectionSkip + _blockUser.height();
} else if (_peerChannel && _amCreator) {
} else if (canDeleteChannel()) {
top += (_peerChannel->isMegagroup() ? 0 : (st::setSectionSkip - st::setLittleSkip)) + _deleteChannel.height();
}
@ -1115,8 +1115,10 @@ void ProfileInner::updateSelected() {
}
int32 participantsTop = 0;
if (_peerChannel && _amCreator) {
if (canDeleteChannel()) {
participantsTop = _deleteChannel.y() + _deleteChannel.height();
} else if (_peerChannel && _amCreator) {
participantsTop = _searchInPeer.y() + _searchInPeer.height();
} else {
participantsTop = _deleteConversation.y() + _deleteConversation.height();
}
@ -1365,6 +1367,10 @@ bool ProfileInner::migrateFail(const RPCError &error) {
return true;
}
bool ProfileInner::canDeleteChannel() const {
return _peerChannel && _amCreator && (_peerChannel->count <= 1000);
}
void ProfileInner::resizeEvent(QResizeEvent *e) {
_width = qMin(width() - st::profilePadding.left() - st::profilePadding.right(), int(st::profileMaxWidth));
_left = (width() - _width) / 2;
@ -1482,7 +1488,7 @@ void ProfileInner::resizeEvent(QResizeEvent *e) {
if (_peerUser && peerToUser(_peerUser->id) != MTP::authedId()) {
top += st::setSectionSkip;
_blockUser.move(_left, top); top += _blockUser.height();
} else if (_peerChannel && _amCreator) {
} else if (canDeleteChannel()) {
top += (_peerChannel->isMegagroup() ? 0 : (st::setSectionSkip - st::setLittleSkip));
_deleteChannel.move(_left, top); top += _deleteChannel.height();
}
@ -1602,9 +1608,9 @@ int32 ProfileInner::countMinHeight() {
h += st::profileHeaderSkip;
}
} else if (_peerChannel) {
if (_amCreator) {
if (canDeleteChannel()) {
h = _deleteChannel.y() + _deleteChannel.height() + st::profileHeaderSkip;
} else if (_peerChannel->amIn()) {
} else if (_peerChannel->amIn() && !_amCreator) {
h = _deleteConversation.y() + _deleteConversation.height() + st::profileHeaderSkip;
} else {
h = _searchInPeer.y() + _searchInPeer.height() + st::profileHeaderSkip;
@ -1755,7 +1761,7 @@ void ProfileInner::showAll() {
_addParticipant.hide();
}
_blockUser.hide();
if (_amCreator) {
if (canDeleteChannel()) {
_deleteChannel.show();
} else {
_deleteChannel.hide();

View File

@ -191,6 +191,7 @@ private:
UserBlockedStatus _wasBlocked;
mtpRequestId _blockRequest;
LinkButton _blockUser, _deleteChannel;
bool canDeleteChannel() const;
// participants
int32 _pHeight;