Add group/channel info limit in EditPeerInfoBox.

This commit is contained in:
John Preston 2018-03-11 23:22:43 +03:00
parent 1e0fe70dc3
commit b1cc7b25ba
2 changed files with 5 additions and 5 deletions

View File

@ -33,7 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace { namespace {
constexpr auto kMaxGroupChannelTitle = 255; constexpr auto kMaxGroupChannelTitle = 255;
constexpr auto kMaxChannelDescription = 255; constexpr auto kMaxChannelDescription = 255; // See also edit_peer_info_box.
constexpr auto kMaxBioLength = 70; constexpr auto kMaxBioLength = 70;
constexpr auto kMinUsernameLength = 5; constexpr auto kMinUsernameLength = 5;

View File

@ -38,6 +38,7 @@ namespace {
constexpr auto kUsernameCheckTimeout = TimeMs(200); constexpr auto kUsernameCheckTimeout = TimeMs(200);
constexpr auto kMinUsernameLength = 5; constexpr auto kMinUsernameLength = 5;
constexpr auto kMaxChannelDescription = 255; // See also add_contact_box.
class Controller class Controller
: private MTP::Sender : private MTP::Sender
@ -324,6 +325,7 @@ object_ptr<Ui::RpWidget> Controller::createDescriptionEdit() {
langFactory(lng_create_group_description), langFactory(lng_create_group_description),
channel->about()), channel->about()),
st::editPeerDescriptionMargins); st::editPeerDescriptionMargins);
result->entity()->setMaxLength(kMaxChannelDescription);
QObject::connect( QObject::connect(
result->entity(), result->entity(),
@ -1252,11 +1254,9 @@ void Controller::saveTitle() {
continueSave(); continueSave();
return; return;
} }
if (type == qstr("NO_CHAT_TITLE")) {
_controls.title->showError(); _controls.title->showError();
if (type == qstr("NO_CHAT_TITLE")) {
_box->scrollToWidget(_controls.title); _box->scrollToWidget(_controls.title);
} else {
_controls.title->setFocus();
} }
cancelSave(); cancelSave();
}; };
@ -1302,7 +1302,7 @@ void Controller::saveDescription() {
successCallback(); successCallback();
return; return;
} }
_controls.description->setFocus(); _controls.description->showError();
cancelSave(); cancelSave();
}).send(); }).send();
} }