From daa24de1715196bee87666d147ac20fdec2c95fb Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 25 Sep 2025 22:26:23 +0300 Subject: [PATCH] Added toast when limit for note length is reached. --- Telegram/Resources/langs/lang.strings | 2 ++ .../SourceFiles/boxes/peers/edit_contact_box.cpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 1f1c2049eb..4ed5c63075 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -4802,6 +4802,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_contact_phone_will_be_shared" = "You can make your phone visible to {user}."; "lng_contact_add_notes" = "Note"; "lng_contact_add_notes_about" = "Notes are only visible to you."; +"lng_contact_notes_limit_reached#one" = "You've reached the contact note limit. Please make the note shorter by {count} character."; +"lng_contact_notes_limit_reached#other" = "You've reached the contact note limit. Please make the note shorter by {count} characters."; "lng_suggest_photo_for" = "Suggest Photo for {user}"; "lng_suggest_birthday" = "Suggest Date of Birth"; "lng_suggest_birthday_box_title" = "{user}'s Date of Birth"; diff --git a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp index 3cc7cdc930..2a7ed69029 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp @@ -258,6 +258,22 @@ void Controller::initNameFields( (inverted ? last : first)->showError(); return; } + + if (_notesField) { + const auto limit = Data::PremiumLimits( + &_user->session()).contactNoteLengthCurrent(); + const auto remove = Ui::ComputeFieldCharacterCount(_notesField) + - limit; + if (remove > 0) { + _box->showToast(tr::lng_contact_notes_limit_reached( + tr::now, + lt_count, + remove)); + _notesField->setFocus(); + return; + } + } + const auto user = _user; const auto personal = _updatedPersonalPhoto ? _updatedPersonalPhoto()