Added counter label of characters limit to edit mode without media.

This commit is contained in:
23rd 2024-02-27 05:05:00 +03:00 committed by John Preston
parent a77c547a62
commit 08717dcd78
2 changed files with 14 additions and 6 deletions

View file

@ -7316,12 +7316,16 @@ void HistoryWidget::checkCharsLimitation() {
return; return;
} }
const auto item = session().data().message(_history->peer, _editMsgId); const auto item = session().data().message(_history->peer, _editMsgId);
if (!item || !item->media() || !item->media()->allowsEditCaption()) { if (!item) {
_charsLimitation = nullptr; _charsLimitation = nullptr;
return; return;
} }
const auto remove = Ui::FieldCharacterCount(_field) const auto hasMediaWithCaption = item->media()
- Data::PremiumLimits(&session()).captionLengthCurrent(); && item->media()->allowsEditCaption();
const auto maxCaptionSize = !hasMediaWithCaption
? MaxMessageSize
: Data::PremiumLimits(&session()).captionLengthCurrent();
const auto remove = Ui::FieldCharacterCount(_field) - maxCaptionSize;
if (remove > 0) { if (remove > 0) {
if (!_charsLimitation) { if (!_charsLimitation) {
_charsLimitation = base::make_unique_q<CharactersLimitLabel>( _charsLimitation = base::make_unique_q<CharactersLimitLabel>(

View file

@ -3323,12 +3323,16 @@ void ComposeControls::checkCharsLimitation() {
return; return;
} }
const auto item = _history->owner().message(_header->editMsgId()); const auto item = _history->owner().message(_header->editMsgId());
if (!item || !item->media() || !item->media()->allowsEditCaption()) { if (!item) {
_charsLimitation = nullptr; _charsLimitation = nullptr;
return; return;
} }
const auto remove = Ui::FieldCharacterCount(_field) const auto hasMediaWithCaption = item->media()
- Data::PremiumLimits(&session()).captionLengthCurrent(); && item->media()->allowsEditCaption();
const auto maxCaptionSize = !hasMediaWithCaption
? MaxMessageSize
: Data::PremiumLimits(&session()).captionLengthCurrent();
const auto remove = Ui::FieldCharacterCount(_field) - maxCaptionSize;
if (remove > 0) { if (remove > 0) {
if (!_charsLimitation) { if (!_charsLimitation) {
using namespace Controls; using namespace Controls;