mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Fixed edit of long text message without media.
This commit is contained in:
parent
5bf6a93086
commit
dd6cbd2c36
4 changed files with 35 additions and 25 deletions
|
@ -3875,13 +3875,17 @@ void HistoryWidget::saveEditMsg() {
|
|||
const auto media = item->media();
|
||||
|
||||
const auto originalLeftSize = left.text.size();
|
||||
const auto maxCaptionSize = Data::PremiumLimits(
|
||||
&session()).captionLengthCurrent();
|
||||
const auto hasMediaWithCaption = item
|
||||
&& item->media()
|
||||
&& item->media()->allowsEditCaption();
|
||||
const auto maxCaptionSize = !hasMediaWithCaption
|
||||
? MaxMessageSize
|
||||
: Data::PremiumLimits(&session()).captionLengthCurrent();
|
||||
if (!TextUtilities::CutPart(sending, left, maxCaptionSize)
|
||||
&& (webPageDraft.removed
|
||||
|| webPageDraft.url.isEmpty()
|
||||
|| !webPageDraft.manual)
|
||||
&& (!media || !media->allowsEditCaption())) {
|
||||
&& !hasMediaWithCaption) {
|
||||
const auto suggestModerateActions = false;
|
||||
controller()->show(
|
||||
Box<DeleteMessagesBox>(item, suggestModerateActions));
|
||||
|
@ -7309,9 +7313,12 @@ void HistoryWidget::showPremiumToast(not_null<DocumentData*> document) {
|
|||
|
||||
void HistoryWidget::checkCharsLimitation() {
|
||||
if (!_history || !_editMsgId) {
|
||||
if (_charsLimitation) {
|
||||
_charsLimitation = nullptr;
|
||||
}
|
||||
_charsLimitation = nullptr;
|
||||
return;
|
||||
}
|
||||
const auto item = session().data().message(_history->peer, _editMsgId);
|
||||
if (!item || !item->media() || !item->media()->allowsEditCaption()) {
|
||||
_charsLimitation = nullptr;
|
||||
return;
|
||||
}
|
||||
const auto limits = Data::PremiumLimits(&session());
|
||||
|
@ -7332,9 +7339,7 @@ void HistoryWidget::checkCharsLimitation() {
|
|||
}
|
||||
_charsLimitation->setLeft(remove);
|
||||
} else {
|
||||
if (_charsLimitation) {
|
||||
_charsLimitation = nullptr;
|
||||
}
|
||||
_charsLimitation = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3315,9 +3315,12 @@ TextWithEntities ComposeControls::prepareTextForEditMsg() const {
|
|||
|
||||
void ComposeControls::checkCharsLimitation() {
|
||||
if (!_history || !isEditingMessage()) {
|
||||
if (_charsLimitation) {
|
||||
_charsLimitation = nullptr;
|
||||
}
|
||||
_charsLimitation = nullptr;
|
||||
return;
|
||||
}
|
||||
const auto item = _history->owner().message(_header->editMsgId());
|
||||
if (!item || !item->media() || !item->media()->allowsEditCaption()) {
|
||||
_charsLimitation = nullptr;
|
||||
return;
|
||||
}
|
||||
const auto limits = Data::PremiumLimits(&session());
|
||||
|
@ -3339,9 +3342,7 @@ void ComposeControls::checkCharsLimitation() {
|
|||
}
|
||||
_charsLimitation->setLeft(remove);
|
||||
} else {
|
||||
if (_charsLimitation) {
|
||||
_charsLimitation = nullptr;
|
||||
}
|
||||
_charsLimitation = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1174,12 +1174,14 @@ void RepliesWidget::edit(
|
|||
auto left = _composeControls->prepareTextForEditMsg();
|
||||
|
||||
const auto originalLeftSize = left.text.size();
|
||||
const auto maxCaptionSize = Data::PremiumLimits(
|
||||
&session()).captionLengthCurrent();
|
||||
const auto hasMediaWithCaption = item
|
||||
&& item->media()
|
||||
&& item->media()->allowsEditCaption();
|
||||
const auto maxCaptionSize = !hasMediaWithCaption
|
||||
? MaxMessageSize
|
||||
: Data::PremiumLimits(&session()).captionLengthCurrent();
|
||||
if (!TextUtilities::CutPart(sending, left, maxCaptionSize)
|
||||
&& (!item
|
||||
|| !item->media()
|
||||
|| !item->media()->allowsEditCaption())) {
|
||||
&& !hasMediaWithCaption) {
|
||||
if (item) {
|
||||
controller()->show(Box<DeleteMessagesBox>(item, false));
|
||||
} else {
|
||||
|
|
|
@ -638,12 +638,14 @@ void ScheduledWidget::edit(
|
|||
auto left = _composeControls->prepareTextForEditMsg();
|
||||
|
||||
const auto originalLeftSize = left.text.size();
|
||||
const auto maxCaptionSize = Data::PremiumLimits(
|
||||
&session()).captionLengthCurrent();
|
||||
const auto hasMediaWithCaption = item
|
||||
&& item->media()
|
||||
&& item->media()->allowsEditCaption();
|
||||
const auto maxCaptionSize = !hasMediaWithCaption
|
||||
? MaxMessageSize
|
||||
: Data::PremiumLimits(&session()).captionLengthCurrent();
|
||||
if (!TextUtilities::CutPart(sending, left, maxCaptionSize)
|
||||
&& (!item
|
||||
|| !item->media()
|
||||
|| !item->media()->allowsEditCaption())) {
|
||||
&& !hasMediaWithCaption) {
|
||||
if (item) {
|
||||
controller()->show(Box<DeleteMessagesBox>(item, false));
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue