mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-08 08:04:08 +02:00
Added saving local text before editing scheduled message.
This commit is contained in:
parent
58281023bc
commit
8320feea10
2 changed files with 33 additions and 4 deletions
|
@ -79,6 +79,10 @@ FieldHeader::FieldHeader(QWidget *parent, not_null<Data::Session*> data)
|
||||||
Ui::DialogTextOptions());
|
Ui::DialogTextOptions());
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
_cancel->addClickHandler([=] {
|
||||||
|
_editMsgId = nullptr;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void FieldHeader::paintEvent(QPaintEvent *e) {
|
void FieldHeader::paintEvent(QPaintEvent *e) {
|
||||||
|
@ -303,11 +307,32 @@ void ComposeControls::init() {
|
||||||
}, _wrap->lifetime());
|
}, _wrap->lifetime());
|
||||||
|
|
||||||
_header->editMsgId(
|
_header->editMsgId(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=](auto item) {
|
||||||
updateHeight();
|
updateHeight();
|
||||||
|
updateSendButtonType();
|
||||||
|
|
||||||
|
if (_header->isEditingMessage()) {
|
||||||
|
setTextFromEditingMessage(item);
|
||||||
|
} else {
|
||||||
|
setText(_localSavedText);
|
||||||
|
_localSavedText = {};
|
||||||
|
}
|
||||||
}, _wrap->lifetime());
|
}, _wrap->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComposeControls::setTextFromEditingMessage(not_null<HistoryItem*> item) {
|
||||||
|
if (!_header->isEditingMessage()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_localSavedText = getTextWithAppliedMarkdown();
|
||||||
|
const auto t = item->originalText();
|
||||||
|
const auto text = TextWithTags{
|
||||||
|
t.text,
|
||||||
|
TextUtilities::ConvertEntitiesToTextTags(t.entities)
|
||||||
|
};
|
||||||
|
setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
void ComposeControls::initField() {
|
void ComposeControls::initField() {
|
||||||
_field->setMaxHeight(st::historyComposeFieldMaxHeight);
|
_field->setMaxHeight(st::historyComposeFieldMaxHeight);
|
||||||
_field->setSubmitSettings(Core::App().settings().sendSubmitWay());
|
_field->setSubmitSettings(Core::App().settings().sendSubmitWay());
|
||||||
|
@ -369,13 +394,13 @@ void ComposeControls::initSendButton() {
|
||||||
void ComposeControls::updateSendButtonType() {
|
void ComposeControls::updateSendButtonType() {
|
||||||
using Type = Ui::SendButton::Type;
|
using Type = Ui::SendButton::Type;
|
||||||
const auto type = [&] {
|
const auto type = [&] {
|
||||||
//if (_editMsgId) {
|
if (_header->isEditingMessage()) {
|
||||||
// return Type::Save;
|
return Type::Save;
|
||||||
//} else if (_isInlineBot) {
|
//} else if (_isInlineBot) {
|
||||||
// return Type::Cancel;
|
// return Type::Cancel;
|
||||||
//} else if (showRecordButton()) {
|
//} else if (showRecordButton()) {
|
||||||
// return Type::Record;
|
// return Type::Record;
|
||||||
//}
|
}
|
||||||
return Type::Schedule;
|
return Type::Schedule;
|
||||||
}();
|
}();
|
||||||
_send->setType(type);
|
_send->setType(type);
|
||||||
|
|
|
@ -115,6 +115,8 @@ private:
|
||||||
void setTabbedPanel(std::unique_ptr<ChatHelpers::TabbedPanel> panel);
|
void setTabbedPanel(std::unique_ptr<ChatHelpers::TabbedPanel> panel);
|
||||||
void setText(const TextWithTags &text);
|
void setText(const TextWithTags &text);
|
||||||
|
|
||||||
|
void setTextFromEditingMessage(not_null<HistoryItem*> item);
|
||||||
|
|
||||||
const not_null<QWidget*> _parent;
|
const not_null<QWidget*> _parent;
|
||||||
const not_null<Window::SessionController*> _window;
|
const not_null<Window::SessionController*> _window;
|
||||||
History *_history = nullptr;
|
History *_history = nullptr;
|
||||||
|
@ -137,6 +139,8 @@ private:
|
||||||
rpl::event_stream<not_null<PhotoData*>> _photoChosen;
|
rpl::event_stream<not_null<PhotoData*>> _photoChosen;
|
||||||
rpl::event_stream<ChatHelpers::TabbedSelector::InlineChosen> _inlineResultChosen;
|
rpl::event_stream<ChatHelpers::TabbedSelector::InlineChosen> _inlineResultChosen;
|
||||||
|
|
||||||
|
TextWithTags _localSavedText;
|
||||||
|
|
||||||
//bool _recording = false;
|
//bool _recording = false;
|
||||||
//bool _inField = false;
|
//bool _inField = false;
|
||||||
//bool _inReplyEditForward = false;
|
//bool _inReplyEditForward = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue