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