mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-09 21:23:43 +00:00
Open the editor in edit mode from Expand
This commit is contained in:
@@ -1404,6 +1404,19 @@ void HistoryWidget::initExpandButton() {
|
||||
return;
|
||||
}
|
||||
const auto window = controller();
|
||||
if (editingMessage()) {
|
||||
const auto item = session().data().message(
|
||||
_history->peer,
|
||||
_editMsgId);
|
||||
if (item && Iv::Editor::CheckRichMessagesPremium(window)) {
|
||||
Iv::Editor::ShowEditFromFieldBox(
|
||||
window,
|
||||
item,
|
||||
prepareSendAction({}),
|
||||
[=] { return sendMenuDetails(); });
|
||||
}
|
||||
return;
|
||||
}
|
||||
Iv::Editor::ShowComposeBox(
|
||||
window,
|
||||
_history->peer,
|
||||
|
||||
@@ -3730,6 +3730,18 @@ void ComposeControls::initExpandButton() {
|
||||
if (!_regularWindow || !_history || !_sendActionFactory) {
|
||||
return;
|
||||
}
|
||||
if (isEditingMessage()) {
|
||||
const auto item = _history->owner().message(
|
||||
_header->editMsgId());
|
||||
if (item && Iv::Editor::CheckRichMessagesPremium(_regularWindow)) {
|
||||
Iv::Editor::ShowEditFromFieldBox(
|
||||
_regularWindow,
|
||||
item,
|
||||
_sendActionFactory(),
|
||||
[=] { return sendMenuDetails(); });
|
||||
}
|
||||
return;
|
||||
}
|
||||
Iv::Editor::ShowComposeBox(
|
||||
_regularWindow,
|
||||
_history->peer,
|
||||
|
||||
@@ -643,6 +643,52 @@ public:
|
||||
articleSession->showWindow();
|
||||
}
|
||||
|
||||
static void ShowEditFromField(
|
||||
not_null<HistoryItem*> item,
|
||||
Api::SendAction action,
|
||||
Fn<SendMenu::Details()> sendMenuDetails) {
|
||||
const auto session = &item->history()->session();
|
||||
const auto topicRootId = action.replyTo.topicRootId;
|
||||
const auto monoforumPeerId = action.replyTo.monoforumPeerId;
|
||||
const auto composeKey = ComposeKey(
|
||||
session,
|
||||
item->history()->peer->id,
|
||||
topicRootId,
|
||||
monoforumPeerId);
|
||||
auto page = std::make_shared<RichPage>();
|
||||
if (const auto entry = LookupComposeThreadEntry(composeKey)) {
|
||||
if (entry->readDraft) {
|
||||
if (const auto draft = entry->readDraft()) {
|
||||
const auto &withTags = draft->textWithTags;
|
||||
*page = SplitTextIntoRichPage({
|
||||
withTags.text,
|
||||
TextUtilities::ConvertTextTagsToEntities(
|
||||
withTags.tags),
|
||||
});
|
||||
}
|
||||
}
|
||||
if (entry->migratedAway) {
|
||||
entry->migratedAway();
|
||||
}
|
||||
}
|
||||
auto articleSession = std::shared_ptr<ArticleSession>(new ArticleSession(
|
||||
session,
|
||||
item->history()->peer,
|
||||
Mode::Edit,
|
||||
item->fullId(),
|
||||
std::move(page),
|
||||
std::move(action),
|
||||
std::move(sendMenuDetails),
|
||||
EditedItemSnapshot{
|
||||
.item = item,
|
||||
.inlinePage = item->richPage(),
|
||||
.summary = item->originalText(),
|
||||
.fullPage = item->fullRichPage(),
|
||||
},
|
||||
std::nullopt));
|
||||
articleSession->showWindow();
|
||||
}
|
||||
|
||||
~ArticleSession() {
|
||||
_submitDeferred = false;
|
||||
for (const auto &attachment : _attachments) {
|
||||
@@ -4112,6 +4158,17 @@ void ShowEditBox(
|
||||
});
|
||||
}
|
||||
|
||||
void ShowEditFromFieldBox(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<HistoryItem*> item,
|
||||
Api::SendAction action,
|
||||
Fn<SendMenu::Details()> sendMenuDetails) {
|
||||
ArticleSession::ShowEditFromField(
|
||||
item,
|
||||
std::move(action),
|
||||
std::move(sendMenuDetails));
|
||||
}
|
||||
|
||||
bool IsComposeBoxOpen(
|
||||
not_null<Main::Session*> session,
|
||||
PeerId peerId,
|
||||
|
||||
@@ -59,6 +59,11 @@ void ShowComposeBox(
|
||||
void ShowEditBox(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<HistoryItem*> item);
|
||||
void ShowEditFromFieldBox(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<HistoryItem*> item,
|
||||
Api::SendAction action,
|
||||
Fn<SendMenu::Details()> sendMenuDetails);
|
||||
[[nodiscard]] bool IsComposeBoxOpen(
|
||||
not_null<Main::Session*> session,
|
||||
PeerId peerId,
|
||||
|
||||
Reference in New Issue
Block a user