mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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 media = item->media();
|
||||||
|
|
||||||
const auto originalLeftSize = left.text.size();
|
const auto originalLeftSize = left.text.size();
|
||||||
const auto maxCaptionSize = Data::PremiumLimits(
|
const auto hasMediaWithCaption = item
|
||||||
&session()).captionLengthCurrent();
|
&& item->media()
|
||||||
|
&& item->media()->allowsEditCaption();
|
||||||
|
const auto maxCaptionSize = !hasMediaWithCaption
|
||||||
|
? MaxMessageSize
|
||||||
|
: Data::PremiumLimits(&session()).captionLengthCurrent();
|
||||||
if (!TextUtilities::CutPart(sending, left, maxCaptionSize)
|
if (!TextUtilities::CutPart(sending, left, maxCaptionSize)
|
||||||
&& (webPageDraft.removed
|
&& (webPageDraft.removed
|
||||||
|| webPageDraft.url.isEmpty()
|
|| webPageDraft.url.isEmpty()
|
||||||
|| !webPageDraft.manual)
|
|| !webPageDraft.manual)
|
||||||
&& (!media || !media->allowsEditCaption())) {
|
&& !hasMediaWithCaption) {
|
||||||
const auto suggestModerateActions = false;
|
const auto suggestModerateActions = false;
|
||||||
controller()->show(
|
controller()->show(
|
||||||
Box<DeleteMessagesBox>(item, suggestModerateActions));
|
Box<DeleteMessagesBox>(item, suggestModerateActions));
|
||||||
|
@ -7309,9 +7313,12 @@ void HistoryWidget::showPremiumToast(not_null<DocumentData*> document) {
|
||||||
|
|
||||||
void HistoryWidget::checkCharsLimitation() {
|
void HistoryWidget::checkCharsLimitation() {
|
||||||
if (!_history || !_editMsgId) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
const auto limits = Data::PremiumLimits(&session());
|
const auto limits = Data::PremiumLimits(&session());
|
||||||
|
@ -7332,9 +7339,7 @@ void HistoryWidget::checkCharsLimitation() {
|
||||||
}
|
}
|
||||||
_charsLimitation->setLeft(remove);
|
_charsLimitation->setLeft(remove);
|
||||||
} else {
|
} else {
|
||||||
if (_charsLimitation) {
|
_charsLimitation = nullptr;
|
||||||
_charsLimitation = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3315,9 +3315,12 @@ TextWithEntities ComposeControls::prepareTextForEditMsg() const {
|
||||||
|
|
||||||
void ComposeControls::checkCharsLimitation() {
|
void ComposeControls::checkCharsLimitation() {
|
||||||
if (!_history || !isEditingMessage()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
const auto limits = Data::PremiumLimits(&session());
|
const auto limits = Data::PremiumLimits(&session());
|
||||||
|
@ -3339,9 +3342,7 @@ void ComposeControls::checkCharsLimitation() {
|
||||||
}
|
}
|
||||||
_charsLimitation->setLeft(remove);
|
_charsLimitation->setLeft(remove);
|
||||||
} else {
|
} else {
|
||||||
if (_charsLimitation) {
|
_charsLimitation = nullptr;
|
||||||
_charsLimitation = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1174,12 +1174,14 @@ void RepliesWidget::edit(
|
||||||
auto left = _composeControls->prepareTextForEditMsg();
|
auto left = _composeControls->prepareTextForEditMsg();
|
||||||
|
|
||||||
const auto originalLeftSize = left.text.size();
|
const auto originalLeftSize = left.text.size();
|
||||||
const auto maxCaptionSize = Data::PremiumLimits(
|
const auto hasMediaWithCaption = item
|
||||||
&session()).captionLengthCurrent();
|
&& item->media()
|
||||||
|
&& item->media()->allowsEditCaption();
|
||||||
|
const auto maxCaptionSize = !hasMediaWithCaption
|
||||||
|
? MaxMessageSize
|
||||||
|
: Data::PremiumLimits(&session()).captionLengthCurrent();
|
||||||
if (!TextUtilities::CutPart(sending, left, maxCaptionSize)
|
if (!TextUtilities::CutPart(sending, left, maxCaptionSize)
|
||||||
&& (!item
|
&& !hasMediaWithCaption) {
|
||||||
|| !item->media()
|
|
||||||
|| !item->media()->allowsEditCaption())) {
|
|
||||||
if (item) {
|
if (item) {
|
||||||
controller()->show(Box<DeleteMessagesBox>(item, false));
|
controller()->show(Box<DeleteMessagesBox>(item, false));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -638,12 +638,14 @@ void ScheduledWidget::edit(
|
||||||
auto left = _composeControls->prepareTextForEditMsg();
|
auto left = _composeControls->prepareTextForEditMsg();
|
||||||
|
|
||||||
const auto originalLeftSize = left.text.size();
|
const auto originalLeftSize = left.text.size();
|
||||||
const auto maxCaptionSize = Data::PremiumLimits(
|
const auto hasMediaWithCaption = item
|
||||||
&session()).captionLengthCurrent();
|
&& item->media()
|
||||||
|
&& item->media()->allowsEditCaption();
|
||||||
|
const auto maxCaptionSize = !hasMediaWithCaption
|
||||||
|
? MaxMessageSize
|
||||||
|
: Data::PremiumLimits(&session()).captionLengthCurrent();
|
||||||
if (!TextUtilities::CutPart(sending, left, maxCaptionSize)
|
if (!TextUtilities::CutPart(sending, left, maxCaptionSize)
|
||||||
&& (!item
|
&& !hasMediaWithCaption) {
|
||||||
|| !item->media()
|
|
||||||
|| !item->media()->allowsEditCaption())) {
|
|
||||||
if (item) {
|
if (item) {
|
||||||
controller()->show(Box<DeleteMessagesBox>(item, false));
|
controller()->show(Box<DeleteMessagesBox>(item, false));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue