mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-26 15:33:02 +02:00
Implement suggestion of changes.
This commit is contained in:
parent
881aed50ea
commit
1ecd7aa7cf
15 changed files with 134 additions and 82 deletions
BIN
Telegram/Resources/animations/diamond.tgs
Normal file
BIN
Telegram/Resources/animations/diamond.tgs
Normal file
Binary file not shown.
|
@ -4423,9 +4423,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_suggest_options_title" = "Suggest a Message";
|
"lng_suggest_options_title" = "Suggest a Message";
|
||||||
"lng_suggest_options_change" = "Suggest Changes";
|
"lng_suggest_options_change" = "Suggest Changes";
|
||||||
"lng_suggest_options_stars_offer" = "Offer Stars";
|
"lng_suggest_options_stars_offer" = "Offer Stars";
|
||||||
|
"lng_suggest_options_stars_request" = "Request Stars";
|
||||||
"lng_suggest_options_stars_price" = "Enter Price in Stars";
|
"lng_suggest_options_stars_price" = "Enter Price in Stars";
|
||||||
"lng_suggest_options_stars_price_about" = "Choose how many Stars to pay to publish this message.";
|
"lng_suggest_options_stars_price_about" = "Choose how many Stars to pay to publish this message.";
|
||||||
"lng_suggest_options_ton_offer" = "Offer TON";
|
"lng_suggest_options_ton_offer" = "Offer TON";
|
||||||
|
"lng_suggest_options_ton_request" = "Request TON";
|
||||||
"lng_suggest_options_ton_price" = "Enter Price in TON";
|
"lng_suggest_options_ton_price" = "Enter Price in TON";
|
||||||
"lng_suggest_options_ton_price_about" = "Choose how many TON to pay to publish this message.";
|
"lng_suggest_options_ton_price_about" = "Choose how many TON to pay to publish this message.";
|
||||||
"lng_suggest_options_date" = "Time";
|
"lng_suggest_options_date" = "Time";
|
||||||
|
@ -4447,10 +4449,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_suggest_action_agree_date" = "The post will be automatically published on {channel} {date}.";
|
"lng_suggest_action_agree_date" = "The post will be automatically published on {channel} {date}.";
|
||||||
"lng_suggest_action_your_charged" = "You have been charged {amount}.";
|
"lng_suggest_action_your_charged" = "You have been charged {amount}.";
|
||||||
"lng_suggest_action_his_charged" = "{from} have been charged {amount}.";
|
"lng_suggest_action_his_charged" = "{from} have been charged {amount}.";
|
||||||
"lng_suggest_action_agree_receive" = "{channel} will receive the Stars once the post has been live for 24 hours.";
|
"lng_suggest_action_agree_receive_stars" = "{channel} will receive the Stars once the post has been live for 24 hours.";
|
||||||
"lng_suggest_action_agree_removed" = "If {channel} removes the post before it has been live for 24 hours, the Stars will be refunded.";
|
"lng_suggest_action_agree_receive_ton" = "{channel} will receive TON once the post has been live for 24 hours.";
|
||||||
"lng_suggest_action_your_not_enough" = "**Transaction failed** because you didn't have enough Stars.";
|
"lng_suggest_action_agree_removed_stars" = "If {channel} removes the post before it has been live for 24 hours, the Stars will be refunded.";
|
||||||
"lng_suggest_action_his_not_enough" = "**Transaction failed** because the user didn't have enough Stars.";
|
"lng_suggest_action_agree_removed_ton" = "If {channel} removes the post before it has been live for 24 hours, TON will be refunded.";
|
||||||
|
"lng_suggest_action_your_not_enough_stars" = "**Transaction failed** because you didn't have enough Stars.";
|
||||||
|
"lng_suggest_action_your_not_enough_ton" = "**Transaction failed** because you didn't have enough TON.";
|
||||||
|
"lng_suggest_action_his_not_enough_stars" = "**Transaction failed** because the user didn't have enough Stars.";
|
||||||
|
"lng_suggest_action_his_not_enough_ton" = "**Transaction failed** because the user didn't have enough TON.";
|
||||||
"lng_suggest_action_declined" = "{from} rejected the message.";
|
"lng_suggest_action_declined" = "{from} rejected the message.";
|
||||||
"lng_suggest_action_declined_reason" = "{from} rejected the message with the comment.";
|
"lng_suggest_action_declined_reason" = "{from} rejected the message with the comment.";
|
||||||
"lng_suggest_change_price" = "{from} suggests a new price for the message.";
|
"lng_suggest_change_price" = "{from} suggests a new price for the message.";
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
<file alias="hours.tgs">../../animations/hours.tgs</file>
|
<file alias="hours.tgs">../../animations/hours.tgs</file>
|
||||||
<file alias="phone.tgs">../../animations/phone.tgs</file>
|
<file alias="phone.tgs">../../animations/phone.tgs</file>
|
||||||
<file alias="chat_link.tgs">../../animations/chat_link.tgs</file>
|
<file alias="chat_link.tgs">../../animations/chat_link.tgs</file>
|
||||||
|
<file alias="diamond.tgs">../../animations/diamond.tgs</file>
|
||||||
<file alias="collectible_username.tgs">../../animations/collectible_username.tgs</file>
|
<file alias="collectible_username.tgs">../../animations/collectible_username.tgs</file>
|
||||||
<file alias="collectible_phone.tgs">../../animations/collectible_phone.tgs</file>
|
<file alias="collectible_phone.tgs">../../animations/collectible_phone.tgs</file>
|
||||||
<file alias="search.tgs">../../animations/search.tgs</file>
|
<file alias="search.tgs">../../animations/search.tgs</file>
|
||||||
|
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/components/scheduled_messages.h"
|
#include "data/components/scheduled_messages.h"
|
||||||
#include "data/data_file_origin.h"
|
#include "data/data_file_origin.h"
|
||||||
#include "data/data_histories.h"
|
#include "data/data_histories.h"
|
||||||
|
#include "data/data_saved_sublist.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_todo_list.h"
|
#include "data/data_todo_list.h"
|
||||||
#include "data/data_web_page.h"
|
#include "data/data_web_page.h"
|
||||||
|
@ -62,76 +63,39 @@ mtpRequestId SuggestMessage(
|
||||||
const auto session = &item->history()->session();
|
const auto session = &item->history()->session();
|
||||||
const auto api = &session->api();
|
const auto api = &session->api();
|
||||||
|
|
||||||
const auto text = textWithEntities.text;
|
const auto thread = item->history()->amMonoforumAdmin()
|
||||||
const auto sentEntities = EntitiesToMTP(
|
? item->savedSublist()
|
||||||
session,
|
: (Data::Thread*)item->history();
|
||||||
textWithEntities.entities,
|
auto action = SendAction(thread, options);
|
||||||
ConvertOption::SkipLocal);
|
action.replyTo = FullReplyTo{
|
||||||
|
|
||||||
const auto emptyFlag = MTPmessages_SendMessage::Flag(0);
|
|
||||||
auto replyTo = FullReplyTo{
|
|
||||||
.messageId = item->fullId(),
|
.messageId = item->fullId(),
|
||||||
.monoforumPeerId = (item->history()->amMonoforumAdmin()
|
.monoforumPeerId = (item->history()->amMonoforumAdmin()
|
||||||
? item->sublistPeerId()
|
? item->sublistPeerId()
|
||||||
: PeerId()),
|
: PeerId()),
|
||||||
};
|
};
|
||||||
const auto flags = emptyFlag
|
|
||||||
| MTPmessages_SendMessage::Flag::f_reply_to
|
|
||||||
| MTPmessages_SendMessage::Flag::f_suggested_post
|
|
||||||
| (webpage.removed
|
|
||||||
? MTPmessages_SendMessage::Flag::f_no_webpage
|
|
||||||
: emptyFlag)
|
|
||||||
| (((!webpage.removed && !webpage.url.isEmpty() && webpage.invert)
|
|
||||||
|| options.invertCaption)
|
|
||||||
? MTPmessages_SendMessage::Flag::f_invert_media
|
|
||||||
: emptyFlag)
|
|
||||||
| (!sentEntities.v.isEmpty()
|
|
||||||
? MTPmessages_SendMessage::Flag::f_entities
|
|
||||||
: emptyFlag)
|
|
||||||
| (options.starsApproved
|
|
||||||
? MTPmessages_SendMessage::Flag::f_allow_paid_stars
|
|
||||||
: emptyFlag);
|
|
||||||
const auto randomId = base::RandomValue<uint64>();
|
|
||||||
return api->request(MTPmessages_SendMessage(
|
|
||||||
MTP_flags(flags),
|
|
||||||
item->history()->peer->input,
|
|
||||||
ReplyToForMTP(item->history(), replyTo),
|
|
||||||
MTP_string(text),
|
|
||||||
MTP_long(randomId),
|
|
||||||
MTPReplyMarkup(),
|
|
||||||
sentEntities,
|
|
||||||
MTPint(), // schedule_date
|
|
||||||
MTPInputPeer(), // send_as
|
|
||||||
MTPInputQuickReplyShortcut(), // quick_reply_shortcut
|
|
||||||
MTPlong(), // effect
|
|
||||||
MTP_long(options.starsApproved),
|
|
||||||
Api::SuggestToMTP(options.suggest)
|
|
||||||
)).done([=](
|
|
||||||
const MTPUpdates &result,
|
|
||||||
[[maybe_unused]] mtpRequestId requestId) {
|
|
||||||
const auto apply = [=] { api->applyUpdates(result); };
|
|
||||||
|
|
||||||
if constexpr (WithId<DoneCallback>) {
|
auto message = MessageToSend(std::move(action));
|
||||||
done(apply, requestId);
|
message.textWithTags = TextWithTags{
|
||||||
} else if constexpr (WithoutId<DoneCallback>) {
|
textWithEntities.text,
|
||||||
done(apply);
|
TextUtilities::ConvertEntitiesToTextTags(textWithEntities.entities)
|
||||||
} else if constexpr (WithoutCallback<DoneCallback>) {
|
};
|
||||||
done();
|
message.webPage = webpage;
|
||||||
apply();
|
api->sendMessage(std::move(message));
|
||||||
} else {
|
|
||||||
t_bad_callback(done);
|
const auto requestId = -1;
|
||||||
}
|
crl::on_main(session, [=] {
|
||||||
}).fail([=](const MTP::Error &error, mtpRequestId requestId) {
|
const auto type = u"MESSAGE_NOT_MODIFIED"_q;
|
||||||
if constexpr (ErrorWithId<FailCallback>) {
|
if constexpr (ErrorWithId<FailCallback>) {
|
||||||
fail(error.type(), requestId);
|
fail(type, requestId);
|
||||||
} else if constexpr (ErrorWithoutId<FailCallback>) {
|
} else if constexpr (ErrorWithoutId<FailCallback>) {
|
||||||
fail(error.type());
|
fail(type);
|
||||||
} else if constexpr (WithoutCallback<FailCallback>) {
|
} else if constexpr (WithoutCallback<FailCallback>) {
|
||||||
fail();
|
fail();
|
||||||
} else {
|
} else {
|
||||||
t_bad_callback(fail);
|
t_bad_callback(fail);
|
||||||
}
|
}
|
||||||
}).send();
|
});
|
||||||
|
return requestId;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename DoneCallback, typename FailCallback>
|
template <typename DoneCallback, typename FailCallback>
|
||||||
|
@ -253,7 +217,7 @@ mtpRequestId SuggestMessageOrMedia(
|
||||||
MTPstring()); // query
|
MTPstring()); // query
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (inputMedia || (!webpage.removed && !webpage.url.isEmpty())) {
|
if (inputMedia) {
|
||||||
return SuggestMedia(
|
return SuggestMedia(
|
||||||
item,
|
item,
|
||||||
textWithEntities,
|
textWithEntities,
|
||||||
|
|
|
@ -268,11 +268,12 @@ void SuggestApprovalDate(
|
||||||
close);
|
close);
|
||||||
};
|
};
|
||||||
using namespace HistoryView;
|
using namespace HistoryView;
|
||||||
|
const auto admin = item->history()->amMonoforumAdmin();
|
||||||
auto dateBox = Box(ChooseSuggestTimeBox, SuggestTimeBoxArgs{
|
auto dateBox = Box(ChooseSuggestTimeBox, SuggestTimeBoxArgs{
|
||||||
.session = &controller->session(),
|
.session = &controller->session(),
|
||||||
.done = done,
|
.done = done,
|
||||||
.value = suggestion->date,
|
.value = suggestion->date,
|
||||||
.mode = SuggestMode::Change,
|
.mode = (admin ? SuggestMode::ChangeAdmin : SuggestMode::ChangeUser),
|
||||||
});
|
});
|
||||||
*weak = dateBox.data();
|
*weak = dateBox.data();
|
||||||
controller->uiShow()->show(std::move(dateBox));
|
controller->uiShow()->show(std::move(dateBox));
|
||||||
|
@ -306,6 +307,7 @@ void SuggestApprovalPrice(
|
||||||
close);
|
close);
|
||||||
};
|
};
|
||||||
using namespace HistoryView;
|
using namespace HistoryView;
|
||||||
|
const auto admin = item->history()->amMonoforumAdmin();
|
||||||
auto dateBox = Box(ChooseSuggestPriceBox, SuggestPriceBoxArgs{
|
auto dateBox = Box(ChooseSuggestPriceBox, SuggestPriceBoxArgs{
|
||||||
.session = &controller->session(),
|
.session = &controller->session(),
|
||||||
.done = done,
|
.done = done,
|
||||||
|
@ -316,7 +318,7 @@ void SuggestApprovalPrice(
|
||||||
.ton = uint32(suggestion->price.ton() ? 1 : 0),
|
.ton = uint32(suggestion->price.ton() ? 1 : 0),
|
||||||
.date = suggestion->date,
|
.date = suggestion->date,
|
||||||
},
|
},
|
||||||
.mode = SuggestMode::Change,
|
.mode = (admin ? SuggestMode::ChangeAdmin : SuggestMode::ChangeUser),
|
||||||
});
|
});
|
||||||
*weak = dateBox.data();
|
*weak = dateBox.data();
|
||||||
controller->uiShow()->show(std::move(dateBox));
|
controller->uiShow()->show(std::move(dateBox));
|
||||||
|
|
|
@ -3661,7 +3661,19 @@ void ApiWrap::editMedia(
|
||||||
if (list.files.empty()) return;
|
if (list.files.empty()) return;
|
||||||
|
|
||||||
auto &file = list.files.front();
|
auto &file = list.files.front();
|
||||||
const auto to = FileLoadTaskOptions(action);
|
auto to = FileLoadTaskOptions(action);
|
||||||
|
const auto existing = to.replaceMediaOf
|
||||||
|
? session().data().message(action.history->peer, to.replaceMediaOf)
|
||||||
|
: nullptr;
|
||||||
|
if (existing && existing->computeSuggestionActions()
|
||||||
|
== SuggestionActions::AcceptAndDecline) {
|
||||||
|
to.replyTo.messageId = {
|
||||||
|
action.history->peer->id,
|
||||||
|
to.replaceMediaOf
|
||||||
|
};
|
||||||
|
to.replyTo.monoforumPeerId = existing->sublistPeerId();
|
||||||
|
to.replaceMediaOf = MsgId();
|
||||||
|
}
|
||||||
_fileLoader->addTask(std::make_unique<FileLoadTask>(
|
_fileLoader->addTask(std::make_unique<FileLoadTask>(
|
||||||
&session(),
|
&session(),
|
||||||
file.path,
|
file.path,
|
||||||
|
|
|
@ -232,12 +232,14 @@ EditCaptionBox::EditCaptionBox(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<HistoryItem*> item,
|
not_null<HistoryItem*> item,
|
||||||
TextWithTags &&text,
|
TextWithTags &&text,
|
||||||
|
SuggestPostOptions suggest,
|
||||||
bool spoilered,
|
bool spoilered,
|
||||||
bool invertCaption,
|
bool invertCaption,
|
||||||
Ui::PreparedList &&list,
|
Ui::PreparedList &&list,
|
||||||
Fn<void()> saved)
|
Fn<void()> saved)
|
||||||
: _controller(controller)
|
: _controller(controller)
|
||||||
, _historyItem(item)
|
, _historyItem(item)
|
||||||
|
, _suggest(suggest)
|
||||||
, _isAllowedEditMedia(item->allowsEditMedia())
|
, _isAllowedEditMedia(item->allowsEditMedia())
|
||||||
, _albumType(ComputeAlbumType(item))
|
, _albumType(ComputeAlbumType(item))
|
||||||
, _controls(base::make_unique_q<Ui::VerticalLayout>(this))
|
, _controls(base::make_unique_q<Ui::VerticalLayout>(this))
|
||||||
|
@ -271,6 +273,7 @@ void EditCaptionBox::StartMediaReplace(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
FullMsgId itemId,
|
FullMsgId itemId,
|
||||||
TextWithTags text,
|
TextWithTags text,
|
||||||
|
SuggestPostOptions suggest,
|
||||||
bool spoilered,
|
bool spoilered,
|
||||||
bool invertCaption,
|
bool invertCaption,
|
||||||
Fn<void()> saved) {
|
Fn<void()> saved) {
|
||||||
|
@ -284,6 +287,7 @@ void EditCaptionBox::StartMediaReplace(
|
||||||
controller,
|
controller,
|
||||||
item,
|
item,
|
||||||
std::move(text),
|
std::move(text),
|
||||||
|
suggest,
|
||||||
spoilered,
|
spoilered,
|
||||||
invertCaption,
|
invertCaption,
|
||||||
std::move(list),
|
std::move(list),
|
||||||
|
@ -300,6 +304,7 @@ void EditCaptionBox::StartMediaReplace(
|
||||||
FullMsgId itemId,
|
FullMsgId itemId,
|
||||||
Ui::PreparedList &&list,
|
Ui::PreparedList &&list,
|
||||||
TextWithTags text,
|
TextWithTags text,
|
||||||
|
SuggestPostOptions suggest,
|
||||||
bool spoilered,
|
bool spoilered,
|
||||||
bool invertCaption,
|
bool invertCaption,
|
||||||
Fn<void()> saved) {
|
Fn<void()> saved) {
|
||||||
|
@ -335,6 +340,7 @@ void EditCaptionBox::StartMediaReplace(
|
||||||
controller,
|
controller,
|
||||||
item,
|
item,
|
||||||
std::move(text),
|
std::move(text),
|
||||||
|
suggest,
|
||||||
spoilered,
|
spoilered,
|
||||||
invertCaption,
|
invertCaption,
|
||||||
std::move(list),
|
std::move(list),
|
||||||
|
@ -347,6 +353,7 @@ void EditCaptionBox::StartPhotoEdit(
|
||||||
std::shared_ptr<Data::PhotoMedia> media,
|
std::shared_ptr<Data::PhotoMedia> media,
|
||||||
FullMsgId itemId,
|
FullMsgId itemId,
|
||||||
TextWithTags text,
|
TextWithTags text,
|
||||||
|
SuggestPostOptions suggest,
|
||||||
bool spoilered,
|
bool spoilered,
|
||||||
bool invertCaption,
|
bool invertCaption,
|
||||||
Fn<void()> saved) {
|
Fn<void()> saved) {
|
||||||
|
@ -365,6 +372,7 @@ void EditCaptionBox::StartPhotoEdit(
|
||||||
controller,
|
controller,
|
||||||
item,
|
item,
|
||||||
std::move(text),
|
std::move(text),
|
||||||
|
suggest,
|
||||||
spoilered,
|
spoilered,
|
||||||
invertCaption,
|
invertCaption,
|
||||||
std::move(list),
|
std::move(list),
|
||||||
|
@ -1001,6 +1009,7 @@ void EditCaptionBox::save() {
|
||||||
};
|
};
|
||||||
|
|
||||||
auto options = Api::SendOptions();
|
auto options = Api::SendOptions();
|
||||||
|
options.suggest = _suggest;
|
||||||
options.scheduled = item->isScheduled() ? item->date() : 0;
|
options.scheduled = item->isScheduled() ? item->date() : 0;
|
||||||
options.shortcutId = item->shortcutId();
|
options.shortcutId = item->shortcutId();
|
||||||
options.invertCaption = _mediaEditManager.invertCaption();
|
options.invertCaption = _mediaEditManager.invertCaption();
|
||||||
|
|
|
@ -39,6 +39,7 @@ public:
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<HistoryItem*> item,
|
not_null<HistoryItem*> item,
|
||||||
TextWithTags &&text,
|
TextWithTags &&text,
|
||||||
|
SuggestPostOptions suggest,
|
||||||
bool spoilered,
|
bool spoilered,
|
||||||
bool invertCaption,
|
bool invertCaption,
|
||||||
Ui::PreparedList &&list,
|
Ui::PreparedList &&list,
|
||||||
|
@ -49,6 +50,7 @@ public:
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
FullMsgId itemId,
|
FullMsgId itemId,
|
||||||
TextWithTags text,
|
TextWithTags text,
|
||||||
|
SuggestPostOptions suggest,
|
||||||
bool spoilered,
|
bool spoilered,
|
||||||
bool invertCaption,
|
bool invertCaption,
|
||||||
Fn<void()> saved);
|
Fn<void()> saved);
|
||||||
|
@ -57,6 +59,7 @@ public:
|
||||||
FullMsgId itemId,
|
FullMsgId itemId,
|
||||||
Ui::PreparedList &&list,
|
Ui::PreparedList &&list,
|
||||||
TextWithTags text,
|
TextWithTags text,
|
||||||
|
SuggestPostOptions suggest,
|
||||||
bool spoilered,
|
bool spoilered,
|
||||||
bool invertCaption,
|
bool invertCaption,
|
||||||
Fn<void()> saved);
|
Fn<void()> saved);
|
||||||
|
@ -65,6 +68,7 @@ public:
|
||||||
std::shared_ptr<Data::PhotoMedia> media,
|
std::shared_ptr<Data::PhotoMedia> media,
|
||||||
FullMsgId itemId,
|
FullMsgId itemId,
|
||||||
TextWithTags text,
|
TextWithTags text,
|
||||||
|
SuggestPostOptions suggest,
|
||||||
bool spoilered,
|
bool spoilered,
|
||||||
bool invertCaption,
|
bool invertCaption,
|
||||||
Fn<void()> saved);
|
Fn<void()> saved);
|
||||||
|
@ -111,6 +115,7 @@ private:
|
||||||
|
|
||||||
const not_null<Window::SessionController*> _controller;
|
const not_null<Window::SessionController*> _controller;
|
||||||
const not_null<HistoryItem*> _historyItem;
|
const not_null<HistoryItem*> _historyItem;
|
||||||
|
const SuggestPostOptions _suggest;
|
||||||
const bool _isAllowedEditMedia;
|
const bool _isAllowedEditMedia;
|
||||||
const Ui::AlbumType _albumType;
|
const Ui::AlbumType _albumType;
|
||||||
|
|
||||||
|
|
|
@ -6236,7 +6236,7 @@ void HistoryItem::applyAction(const MTPMessageAction &action) {
|
||||||
this,
|
this,
|
||||||
_from,
|
_from,
|
||||||
Data::GiftType::Ton,
|
Data::GiftType::Ton,
|
||||||
data.vamount().v);
|
data.vcrypto_amount().v);
|
||||||
}, [&](const MTPDmessageActionPrizeStars &data) {
|
}, [&](const MTPDmessageActionPrizeStars &data) {
|
||||||
_media = std::make_unique<Data::MediaGiftBox>(
|
_media = std::make_unique<Data::MediaGiftBox>(
|
||||||
this,
|
this,
|
||||||
|
|
|
@ -2271,7 +2271,11 @@ bool HistoryWidget::applyDraft(FieldHistoryAction fieldHistoryAction) {
|
||||||
}
|
}
|
||||||
if (editDraft && editDraft->suggest) {
|
if (editDraft && editDraft->suggest) {
|
||||||
using namespace HistoryView;
|
using namespace HistoryView;
|
||||||
applySuggestOptions(editDraft->suggest, SuggestMode::Change);
|
applySuggestOptions(
|
||||||
|
editDraft->suggest,
|
||||||
|
(_history->amMonoforumAdmin()
|
||||||
|
? SuggestMode::ChangeAdmin
|
||||||
|
: SuggestMode::ChangeUser));
|
||||||
} else {
|
} else {
|
||||||
cancelSuggestPost();
|
cancelSuggestPost();
|
||||||
}
|
}
|
||||||
|
@ -3030,6 +3034,7 @@ bool HistoryWidget::updateReplaceMediaButton() {
|
||||||
controller(),
|
controller(),
|
||||||
{ _history->peer->id, _editMsgId },
|
{ _history->peer->id, _editMsgId },
|
||||||
_field->getTextWithTags(),
|
_field->getTextWithTags(),
|
||||||
|
suggestOptions(),
|
||||||
_mediaEditManager.spoilered(),
|
_mediaEditManager.spoilered(),
|
||||||
_mediaEditManager.invertCaption(),
|
_mediaEditManager.invertCaption(),
|
||||||
crl::guard(_list, [=] { cancelEdit(); }));
|
crl::guard(_list, [=] { cancelEdit(); }));
|
||||||
|
@ -6276,6 +6281,7 @@ bool HistoryWidget::confirmSendingFiles(
|
||||||
{ _history->peer->id, _editMsgId },
|
{ _history->peer->id, _editMsgId },
|
||||||
std::move(list),
|
std::move(list),
|
||||||
_field->getTextWithTags(),
|
_field->getTextWithTags(),
|
||||||
|
suggestOptions(),
|
||||||
_mediaEditManager.spoilered(),
|
_mediaEditManager.spoilered(),
|
||||||
_mediaEditManager.invertCaption(),
|
_mediaEditManager.invertCaption(),
|
||||||
crl::guard(_list, [=] { cancelEdit(); }));
|
crl::guard(_list, [=] { cancelEdit(); }));
|
||||||
|
@ -7412,6 +7418,7 @@ void HistoryWidget::mousePressEvent(QMouseEvent *e) {
|
||||||
_photoEditMedia,
|
_photoEditMedia,
|
||||||
{ _history->peer->id, _editMsgId },
|
{ _history->peer->id, _editMsgId },
|
||||||
_field->getTextWithTags(),
|
_field->getTextWithTags(),
|
||||||
|
suggestOptions(),
|
||||||
_mediaEditManager.spoilered(),
|
_mediaEditManager.spoilered(),
|
||||||
_mediaEditManager.invertCaption(),
|
_mediaEditManager.invertCaption(),
|
||||||
crl::guard(_list, [=] { cancelEdit(); }));
|
crl::guard(_list, [=] { cancelEdit(); }));
|
||||||
|
|
|
@ -420,9 +420,13 @@ void FieldHeader::init() {
|
||||||
if (_preview.parsed) {
|
if (_preview.parsed) {
|
||||||
_editOptionsRequests.fire({});
|
_editOptionsRequests.fire({});
|
||||||
} else if (isEditingMessage()) {
|
} else if (isEditingMessage()) {
|
||||||
|
if (_suggestOptions) {
|
||||||
|
_suggestOptions->edit();
|
||||||
|
} else {
|
||||||
_jumpToItemRequests.fire(FullReplyTo{
|
_jumpToItemRequests.fire(FullReplyTo{
|
||||||
.messageId = _editMsgId.current()
|
.messageId = _editMsgId.current()
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} else if (reply && (e->modifiers() & Qt::ControlModifier)) {
|
} else if (reply && (e->modifiers() & Qt::ControlModifier)) {
|
||||||
_jumpToItemRequests.fire_copy(reply);
|
_jumpToItemRequests.fire_copy(reply);
|
||||||
} else if (reply || readyToForward()) {
|
} else if (reply || readyToForward()) {
|
||||||
|
@ -789,7 +793,7 @@ void FieldHeader::editMessage(
|
||||||
_inPhotoEditOver.stop();
|
_inPhotoEditOver.stop();
|
||||||
}
|
}
|
||||||
if (id && suggest) {
|
if (id && suggest) {
|
||||||
applySuggestOptions(suggest, SuggestMode::Change);
|
applySuggestOptions(suggest, SuggestMode::ChangeAdmin);
|
||||||
} else {
|
} else {
|
||||||
cancelSuggestPost();
|
cancelSuggestPost();
|
||||||
}
|
}
|
||||||
|
@ -1227,6 +1231,7 @@ bool ComposeControls::confirmMediaEdit(Ui::PreparedList &list) {
|
||||||
_editingId,
|
_editingId,
|
||||||
std::move(list),
|
std::move(list),
|
||||||
_field->getTextWithTags(),
|
_field->getTextWithTags(),
|
||||||
|
_header->suggestOptions(),
|
||||||
queryToEdit.spoilered,
|
queryToEdit.spoilered,
|
||||||
queryToEdit.options.invertCaption,
|
queryToEdit.options.invertCaption,
|
||||||
crl::guard(_wrap.get(), [=] { cancelEditMessage(); }));
|
crl::guard(_wrap.get(), [=] { cancelEditMessage(); }));
|
||||||
|
@ -1466,6 +1471,7 @@ void ComposeControls::init() {
|
||||||
_photoEditMedia,
|
_photoEditMedia,
|
||||||
_editingId,
|
_editingId,
|
||||||
_field->getTextWithTags(),
|
_field->getTextWithTags(),
|
||||||
|
_header->suggestOptions(),
|
||||||
queryToEdit.spoilered,
|
queryToEdit.spoilered,
|
||||||
queryToEdit.options.invertCaption,
|
queryToEdit.options.invertCaption,
|
||||||
crl::guard(_wrap.get(), [=] { cancelEditMessage(); }));
|
crl::guard(_wrap.get(), [=] { cancelEditMessage(); }));
|
||||||
|
@ -3093,6 +3099,7 @@ bool ComposeControls::updateReplaceMediaButton() {
|
||||||
_regularWindow,
|
_regularWindow,
|
||||||
_editingId,
|
_editingId,
|
||||||
_field->getTextWithTags(),
|
_field->getTextWithTags(),
|
||||||
|
_header->suggestOptions(),
|
||||||
queryToEdit.spoilered,
|
queryToEdit.spoilered,
|
||||||
queryToEdit.options.invertCaption,
|
queryToEdit.options.invertCaption,
|
||||||
crl::guard(_wrap.get(), [=] { cancelEditMessage(); }));
|
crl::guard(_wrap.get(), [=] { cancelEditMessage(); }));
|
||||||
|
|
|
@ -95,13 +95,17 @@ void ChooseSuggestPriceBox(
|
||||||
state->buttons.push_back({
|
state->buttons.push_back({
|
||||||
.text = Ui::Text::String(
|
.text = Ui::Text::String(
|
||||||
st::semiboldTextStyle,
|
st::semiboldTextStyle,
|
||||||
tr::lng_suggest_options_stars_offer(tr::now)),
|
(args.mode == SuggestMode::ChangeAdmin
|
||||||
|
? tr::lng_suggest_options_stars_request(tr::now)
|
||||||
|
: tr::lng_suggest_options_stars_offer(tr::now))),
|
||||||
.active = !state->ton.current(),
|
.active = !state->ton.current(),
|
||||||
});
|
});
|
||||||
state->buttons.push_back({
|
state->buttons.push_back({
|
||||||
.text = Ui::Text::String(
|
.text = Ui::Text::String(
|
||||||
st::semiboldTextStyle,
|
st::semiboldTextStyle,
|
||||||
tr::lng_suggest_options_ton_offer(tr::now)),
|
(args.mode == SuggestMode::ChangeAdmin
|
||||||
|
? tr::lng_suggest_options_ton_request(tr::now)
|
||||||
|
: tr::lng_suggest_options_ton_offer(tr::now))),
|
||||||
.active = state->ton.current(),
|
.active = state->ton.current(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,8 @@ namespace HistoryView {
|
||||||
|
|
||||||
enum class SuggestMode {
|
enum class SuggestMode {
|
||||||
New,
|
New,
|
||||||
Change,
|
ChangeUser,
|
||||||
|
ChangeAdmin,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SuggestTimeBoxArgs {
|
struct SuggestTimeBoxArgs {
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "boxes/gift_premium_box.h" // ResolveGiftCode
|
#include "boxes/gift_premium_box.h" // ResolveGiftCode
|
||||||
#include "chat_helpers/stickers_gift_box_pack.h"
|
#include "chat_helpers/stickers_gift_box_pack.h"
|
||||||
|
#include "chat_helpers/stickers_lottie.h"
|
||||||
#include "core/click_handler_types.h" // ClickHandlerContext
|
#include "core/click_handler_types.h" // ClickHandlerContext
|
||||||
#include "data/stickers/data_custom_emoji.h"
|
#include "data/stickers/data_custom_emoji.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
|
@ -47,7 +48,7 @@ PremiumGift::PremiumGift(
|
||||||
PremiumGift::~PremiumGift() = default;
|
PremiumGift::~PremiumGift() = default;
|
||||||
|
|
||||||
int PremiumGift::top() {
|
int PremiumGift::top() {
|
||||||
return starGift()
|
return (starGift() || tonGift())
|
||||||
? st::msgServiceStarGiftStickerTop
|
? st::msgServiceStarGiftStickerTop
|
||||||
: st::msgServiceGiftBoxStickerTop;
|
: st::msgServiceGiftBoxStickerTop;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +58,7 @@ int PremiumGift::width() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize PremiumGift::size() {
|
QSize PremiumGift::size() {
|
||||||
return starGift()
|
return (starGift() || tonGift())
|
||||||
? QSize(
|
? QSize(
|
||||||
st::msgServiceStarGiftStickerSize,
|
st::msgServiceStarGiftStickerSize,
|
||||||
st::msgServiceStarGiftStickerSize)
|
st::msgServiceStarGiftStickerSize)
|
||||||
|
@ -68,7 +69,10 @@ QSize PremiumGift::size() {
|
||||||
|
|
||||||
TextWithEntities PremiumGift::title() {
|
TextWithEntities PremiumGift::title() {
|
||||||
using namespace Ui::Text;
|
using namespace Ui::Text;
|
||||||
if (starGift()) {
|
if (tonGift()) {
|
||||||
|
AssertIsDebug();
|
||||||
|
return { QString::number(_data.count / 1'000'000'000LL) + u" TON"_q };
|
||||||
|
} else if (starGift()) {
|
||||||
const auto peer = _parent->history()->peer;
|
const auto peer = _parent->history()->peer;
|
||||||
return peer->isSelf()
|
return peer->isSelf()
|
||||||
? tr::lng_action_gift_self_subtitle(tr::now, WithEntities)
|
? tr::lng_action_gift_self_subtitle(tr::now, WithEntities)
|
||||||
|
@ -114,7 +118,10 @@ TextWithEntities PremiumGift::title() {
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities PremiumGift::subtitle() {
|
TextWithEntities PremiumGift::subtitle() {
|
||||||
if (starGift()) {
|
if (tonGift()) {
|
||||||
|
AssertIsDebug();
|
||||||
|
return { u"Use TON to suggest posts to channels."_q };
|
||||||
|
} else if (starGift()) {
|
||||||
const auto toChannel = _data.channel
|
const auto toChannel = _data.channel
|
||||||
&& _parent->history()->peer->isServiceUser();
|
&& _parent->history()->peer->isServiceUser();
|
||||||
return !_data.message.empty()
|
return !_data.message.empty()
|
||||||
|
@ -242,6 +249,14 @@ bool PremiumGift::buttonMinistars() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ClickHandlerPtr PremiumGift::createViewLink() {
|
ClickHandlerPtr PremiumGift::createViewLink() {
|
||||||
|
if (tonGift()) {
|
||||||
|
return std::make_shared<LambdaClickHandler>([=](ClickContext context) {
|
||||||
|
const auto my = context.other.value<ClickHandlerContext>();
|
||||||
|
if (const auto window = my.sessionWindow.get()) {
|
||||||
|
window->showSettings(Settings::CreditsId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
if (auto link = OpenStarGiftLink(_parent->data())) {
|
if (auto link = OpenStarGiftLink(_parent->data())) {
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
@ -401,6 +416,17 @@ int PremiumGift::credits() const {
|
||||||
void PremiumGift::ensureStickerCreated() const {
|
void PremiumGift::ensureStickerCreated() const {
|
||||||
if (_sticker) {
|
if (_sticker) {
|
||||||
return;
|
return;
|
||||||
|
} else if (tonGift()) {
|
||||||
|
const auto document = ChatHelpers::GenerateLocalTgsSticker(
|
||||||
|
&_parent->history()->session(),
|
||||||
|
"diamond");
|
||||||
|
const auto sticker = document->sticker();
|
||||||
|
Assert(sticker != nullptr);
|
||||||
|
_sticker.emplace(_parent, document, false, _parent);
|
||||||
|
_sticker->setPlayingOnce(true);
|
||||||
|
_sticker->initSize(st::msgServiceStarGiftStickerSize);
|
||||||
|
_parent->repaint();
|
||||||
|
return;
|
||||||
} else if (const auto document = _data.document) {
|
} else if (const auto document = _data.document) {
|
||||||
const auto sticker = document->sticker();
|
const auto sticker = document->sticker();
|
||||||
Assert(sticker != nullptr);
|
Assert(sticker != nullptr);
|
||||||
|
|
|
@ -143,8 +143,12 @@ auto GenerateSuggestDecisionMedia(
|
||||||
TextWithEntities(
|
TextWithEntities(
|
||||||
).append(Emoji(kWarning)).append(' ').append(
|
).append(Emoji(kWarning)).append(' ').append(
|
||||||
(sublistPeer->isSelf()
|
(sublistPeer->isSelf()
|
||||||
? tr::lng_suggest_action_your_not_enough
|
? (decision->price.ton()
|
||||||
: tr::lng_suggest_action_his_not_enough)(
|
? tr::lng_suggest_action_your_not_enough_ton
|
||||||
|
: tr::lng_suggest_action_your_not_enough_stars)
|
||||||
|
: (decision->price.ton()
|
||||||
|
? tr::lng_suggest_action_his_not_enough_ton
|
||||||
|
: tr::lng_suggest_action_his_not_enough_stars))(
|
||||||
tr::now,
|
tr::now,
|
||||||
Ui::Text::RichLangValue)),
|
Ui::Text::RichLangValue)),
|
||||||
st::chatSuggestInfoFullMargin,
|
st::chatSuggestInfoFullMargin,
|
||||||
|
@ -237,7 +241,9 @@ auto GenerateSuggestDecisionMedia(
|
||||||
pushText(
|
pushText(
|
||||||
TextWithEntities(
|
TextWithEntities(
|
||||||
).append(Emoji(kHourglass)).append(' ').append(
|
).append(Emoji(kHourglass)).append(' ').append(
|
||||||
tr::lng_suggest_action_agree_receive(
|
(price.ton()
|
||||||
|
? tr::lng_suggest_action_agree_receive_ton
|
||||||
|
: tr::lng_suggest_action_agree_receive_stars)(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_channel,
|
lt_channel,
|
||||||
Ui::Text::Bold(broadcast->name()),
|
Ui::Text::Bold(broadcast->name()),
|
||||||
|
@ -247,7 +253,9 @@ auto GenerateSuggestDecisionMedia(
|
||||||
pushText(
|
pushText(
|
||||||
TextWithEntities(
|
TextWithEntities(
|
||||||
).append(Emoji(kReload)).append(' ').append(
|
).append(Emoji(kReload)).append(' ').append(
|
||||||
tr::lng_suggest_action_agree_removed(
|
(price.ton()
|
||||||
|
? tr::lng_suggest_action_agree_removed_ton
|
||||||
|
: tr::lng_suggest_action_agree_removed_stars)(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_channel,
|
lt_channel,
|
||||||
Ui::Text::Bold(broadcast->name()),
|
Ui::Text::Bold(broadcast->name()),
|
||||||
|
|
Loading…
Add table
Reference in a new issue