mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Simple sending from replies section.
This commit is contained in:
parent
204645a715
commit
45419205c6
4 changed files with 50 additions and 46 deletions
|
@ -398,7 +398,7 @@ ComposeControls::ComposeControls(
|
||||||
Mode mode)
|
Mode mode)
|
||||||
: _parent(parent)
|
: _parent(parent)
|
||||||
, _window(window)
|
, _window(window)
|
||||||
//, _mode(mode)
|
, _mode(mode)
|
||||||
, _wrap(std::make_unique<Ui::RpWidget>(parent))
|
, _wrap(std::make_unique<Ui::RpWidget>(parent))
|
||||||
, _send(Ui::CreateChild<Ui::SendButton>(_wrap.get()))
|
, _send(Ui::CreateChild<Ui::SendButton>(_wrap.get()))
|
||||||
, _attachToggle(Ui::CreateChild<Ui::IconButton>(
|
, _attachToggle(Ui::CreateChild<Ui::IconButton>(
|
||||||
|
@ -473,7 +473,10 @@ rpl::producer<not_null<QKeyEvent*>> ComposeControls::keyEvents() const {
|
||||||
|
|
||||||
rpl::producer<> ComposeControls::sendRequests() const {
|
rpl::producer<> ComposeControls::sendRequests() const {
|
||||||
auto filter = rpl::filter([=] {
|
auto filter = rpl::filter([=] {
|
||||||
return _send->type() == Ui::SendButton::Type::Schedule;
|
const auto type = (_mode == Mode::Normal)
|
||||||
|
? Ui::SendButton::Type::Send
|
||||||
|
: Ui::SendButton::Type::Schedule;
|
||||||
|
return (_send->type() == type);
|
||||||
});
|
});
|
||||||
auto submits = base::qt_signal_producer(
|
auto submits = base::qt_signal_producer(
|
||||||
_field.get(),
|
_field.get(),
|
||||||
|
@ -708,7 +711,7 @@ void ComposeControls::updateSendButtonType() {
|
||||||
//} else if (showRecordButton()) {
|
//} else if (showRecordButton()) {
|
||||||
// return Type::Record;
|
// return Type::Record;
|
||||||
}
|
}
|
||||||
return Type::Schedule;
|
return (_mode == Mode::Normal) ? Type::Send : Type::Schedule;
|
||||||
}();
|
}();
|
||||||
_send->setType(type);
|
_send->setType(type);
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ private:
|
||||||
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;
|
||||||
//Mode _mode = Mode::Normal;
|
Mode _mode = Mode::Normal;
|
||||||
|
|
||||||
const std::unique_ptr<Ui::RpWidget> _wrap;
|
const std::unique_ptr<Ui::RpWidget> _wrap;
|
||||||
|
|
||||||
|
|
|
@ -1710,7 +1710,7 @@ void Message::updateMediaInBubbleState() {
|
||||||
auto getMediaHasSomethingAbove = [&] {
|
auto getMediaHasSomethingAbove = [&] {
|
||||||
return displayFromName()
|
return displayFromName()
|
||||||
|| displayForwardedFrom()
|
|| displayForwardedFrom()
|
||||||
|| item->Has<HistoryMessageReply>()
|
|| displayedReply()
|
||||||
|| item->Has<HistoryMessageVia>();
|
|| item->Has<HistoryMessageVia>();
|
||||||
};
|
};
|
||||||
auto entry = logEntryOriginal();
|
auto entry = logEntryOriginal();
|
||||||
|
|
|
@ -374,10 +374,8 @@ bool RepliesWidget::confirmSendingFiles(
|
||||||
text,
|
text,
|
||||||
boxCompressConfirm,
|
boxCompressConfirm,
|
||||||
_history->peer->slowmodeApplied() ? SendLimit::One : SendLimit::Many,
|
_history->peer->slowmodeApplied() ? SendLimit::One : SendLimit::Many,
|
||||||
CanScheduleUntilOnline(_history->peer)
|
Api::SendType::Normal,
|
||||||
? Api::SendType::ScheduledToUser
|
SendMenu::Type::Disabled); // #TODO replies schedule
|
||||||
: Api::SendType::Scheduled,
|
|
||||||
SendMenu::Type::Disabled);
|
|
||||||
//_field->setTextWithTags({});
|
//_field->setTextWithTags({});
|
||||||
|
|
||||||
box->setConfirmedCallback(crl::guard(this, [=](
|
box->setConfirmedCallback(crl::guard(this, [=](
|
||||||
|
@ -399,7 +397,7 @@ bool RepliesWidget::confirmSendingFiles(
|
||||||
std::move(list),
|
std::move(list),
|
||||||
type,
|
type,
|
||||||
std::move(caption),
|
std::move(caption),
|
||||||
MsgId(0),//replyToId(),
|
MsgId(_rootId),//replyToId(), // #TODO replies reply
|
||||||
options,
|
options,
|
||||||
album);
|
album);
|
||||||
}));
|
}));
|
||||||
|
@ -460,7 +458,7 @@ void RepliesWidget::uploadFilesAfterConfirmation(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto action = Api::SendAction(_history);
|
auto action = Api::SendAction(_history);
|
||||||
action.replyTo = replyTo;
|
action.replyTo = _rootId;// replyTo;// #TODO replies reply
|
||||||
action.options = options;
|
action.options = options;
|
||||||
session().api().sendFiles(
|
session().api().sendFiles(
|
||||||
std::move(list),
|
std::move(list),
|
||||||
|
@ -473,15 +471,10 @@ void RepliesWidget::uploadFilesAfterConfirmation(
|
||||||
void RepliesWidget::uploadFile(
|
void RepliesWidget::uploadFile(
|
||||||
const QByteArray &fileContent,
|
const QByteArray &fileContent,
|
||||||
SendMediaType type) {
|
SendMediaType type) {
|
||||||
const auto callback = [=](Api::SendOptions options) {
|
// #TODO replies schedule
|
||||||
auto action = Api::SendAction(_history);
|
auto action = Api::SendAction(_history);
|
||||||
//action.replyTo = replyToId();
|
action.replyTo = _rootId;// #TODO replies reply
|
||||||
action.options = options;
|
session().api().sendFile(fileContent, type, action);
|
||||||
session().api().sendFile(fileContent, type, action);
|
|
||||||
};
|
|
||||||
Ui::show(
|
|
||||||
PrepareScheduleBox(this, sendMenuType(), callback),
|
|
||||||
Ui::LayerOption::KeepOther);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RepliesWidget::showSendingFilesError(
|
bool RepliesWidget::showSendingFilesError(
|
||||||
|
@ -521,10 +514,12 @@ void RepliesWidget::send() {
|
||||||
if (_composeControls->getTextWithAppliedMarkdown().text.isEmpty()) {
|
if (_composeControls->getTextWithAppliedMarkdown().text.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto callback = [=](Api::SendOptions options) { send(options); };
|
send(Api::SendOptions());
|
||||||
Ui::show(
|
// #TODO replies schedule
|
||||||
PrepareScheduleBox(this, sendMenuType(), callback),
|
//const auto callback = [=](Api::SendOptions options) { send(options); };
|
||||||
Ui::LayerOption::KeepOther);
|
//Ui::show(
|
||||||
|
// PrepareScheduleBox(this, sendMenuType(), callback),
|
||||||
|
// Ui::LayerOption::KeepOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepliesWidget::send(Api::SendOptions options) {
|
void RepliesWidget::send(Api::SendOptions options) {
|
||||||
|
@ -537,7 +532,7 @@ void RepliesWidget::send(Api::SendOptions options) {
|
||||||
auto message = ApiWrap::MessageToSend(_history);
|
auto message = ApiWrap::MessageToSend(_history);
|
||||||
message.textWithTags = _composeControls->getTextWithAppliedMarkdown();
|
message.textWithTags = _composeControls->getTextWithAppliedMarkdown();
|
||||||
message.action.options = options;
|
message.action.options = options;
|
||||||
//message.action.replyTo = replyToId();
|
message.action.replyTo = _rootId;// replyToId();// #TODO replies reply
|
||||||
message.webPageId = webPageId;
|
message.webPageId = webPageId;
|
||||||
|
|
||||||
//const auto error = GetErrorTextForSending(
|
//const auto error = GetErrorTextForSending(
|
||||||
|
@ -637,12 +632,14 @@ void RepliesWidget::edit(
|
||||||
|
|
||||||
void RepliesWidget::sendExistingDocument(
|
void RepliesWidget::sendExistingDocument(
|
||||||
not_null<DocumentData*> document) {
|
not_null<DocumentData*> document) {
|
||||||
const auto callback = [=](Api::SendOptions options) {
|
sendExistingDocument(document, Api::SendOptions());
|
||||||
sendExistingDocument(document, options);
|
// #TODO replies schedule
|
||||||
};
|
//const auto callback = [=](Api::SendOptions options) {
|
||||||
Ui::show(
|
// sendExistingDocument(document, options);
|
||||||
PrepareScheduleBox(this, sendMenuType(), callback),
|
//};
|
||||||
Ui::LayerOption::KeepOther);
|
//Ui::show(
|
||||||
|
// PrepareScheduleBox(this, sendMenuType(), callback),
|
||||||
|
// Ui::LayerOption::KeepOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RepliesWidget::sendExistingDocument(
|
bool RepliesWidget::sendExistingDocument(
|
||||||
|
@ -657,7 +654,7 @@ bool RepliesWidget::sendExistingDocument(
|
||||||
}
|
}
|
||||||
|
|
||||||
auto message = Api::MessageToSend(_history);
|
auto message = Api::MessageToSend(_history);
|
||||||
//message.action.replyTo = replyToId();
|
message.action.replyTo = _rootId;// replyToId();// #TODO replies reply
|
||||||
message.action.options = options;
|
message.action.options = options;
|
||||||
Api::SendExistingDocument(std::move(message), document);
|
Api::SendExistingDocument(std::move(message), document);
|
||||||
|
|
||||||
|
@ -675,12 +672,14 @@ bool RepliesWidget::sendExistingDocument(
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepliesWidget::sendExistingPhoto(not_null<PhotoData*> photo) {
|
void RepliesWidget::sendExistingPhoto(not_null<PhotoData*> photo) {
|
||||||
const auto callback = [=](Api::SendOptions options) {
|
sendExistingPhoto(photo, Api::SendOptions());
|
||||||
sendExistingPhoto(photo, options);
|
// #TODO replies schedule
|
||||||
};
|
//const auto callback = [=](Api::SendOptions options) {
|
||||||
Ui::show(
|
// sendExistingPhoto(photo, options);
|
||||||
PrepareScheduleBox(this, sendMenuType(), callback),
|
//};
|
||||||
Ui::LayerOption::KeepOther);
|
//Ui::show(
|
||||||
|
// PrepareScheduleBox(this, sendMenuType(), callback),
|
||||||
|
// Ui::LayerOption::KeepOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RepliesWidget::sendExistingPhoto(
|
bool RepliesWidget::sendExistingPhoto(
|
||||||
|
@ -695,7 +694,7 @@ bool RepliesWidget::sendExistingPhoto(
|
||||||
}
|
}
|
||||||
|
|
||||||
auto message = Api::MessageToSend(_history);
|
auto message = Api::MessageToSend(_history);
|
||||||
//message.action.replyTo = replyToId();
|
message.action.replyTo = _rootId;// replyToId();// #TODO replies reply
|
||||||
message.action.options = options;
|
message.action.options = options;
|
||||||
Api::SendExistingPhoto(std::move(message), photo);
|
Api::SendExistingPhoto(std::move(message), photo);
|
||||||
|
|
||||||
|
@ -712,12 +711,13 @@ void RepliesWidget::sendInlineResult(
|
||||||
Ui::show(Box<InformBox>(errorText));
|
Ui::show(Box<InformBox>(errorText));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto callback = [=](Api::SendOptions options) {
|
sendInlineResult(result, bot, Api::SendOptions());
|
||||||
sendInlineResult(result, bot, options);
|
//const auto callback = [=](Api::SendOptions options) {
|
||||||
};
|
// sendInlineResult(result, bot, options);
|
||||||
Ui::show(
|
//};
|
||||||
PrepareScheduleBox(this, sendMenuType(), callback),
|
//Ui::show(
|
||||||
Ui::LayerOption::KeepOther);
|
// PrepareScheduleBox(this, sendMenuType(), callback),
|
||||||
|
// Ui::LayerOption::KeepOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepliesWidget::sendInlineResult(
|
void RepliesWidget::sendInlineResult(
|
||||||
|
@ -725,7 +725,7 @@ void RepliesWidget::sendInlineResult(
|
||||||
not_null<UserData*> bot,
|
not_null<UserData*> bot,
|
||||||
Api::SendOptions options) {
|
Api::SendOptions options) {
|
||||||
auto action = Api::SendAction(_history);
|
auto action = Api::SendAction(_history);
|
||||||
//action.replyTo = replyToId();
|
action.replyTo = _rootId;// replyToId();// #TODO replies reply
|
||||||
action.options = options;
|
action.options = options;
|
||||||
action.generateLocal = true;
|
action.generateLocal = true;
|
||||||
session().api().sendInlineResult(bot, result, action);
|
session().api().sendInlineResult(bot, result, action);
|
||||||
|
@ -752,6 +752,7 @@ void RepliesWidget::sendInlineResult(
|
||||||
}
|
}
|
||||||
|
|
||||||
SendMenu::Type RepliesWidget::sendMenuType() const {
|
SendMenu::Type RepliesWidget::sendMenuType() const {
|
||||||
|
// #TODO replies schedule
|
||||||
return _history->peer->isSelf()
|
return _history->peer->isSelf()
|
||||||
? SendMenu::Type::Reminder
|
? SendMenu::Type::Reminder
|
||||||
: HistoryView::CanScheduleUntilOnline(_history->peer)
|
: HistoryView::CanScheduleUntilOnline(_history->peer)
|
||||||
|
|
Loading…
Add table
Reference in a new issue