mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-01 06:55:58 +00:00
Fix t.me/share links.
Regression was introduced in ffc20e4492
.
Fixes #4099.
This commit is contained in:
@@ -662,19 +662,28 @@ bool MainWidget::setForwardDraft(PeerId peerId, const SelectedItemSet &items) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainWidget::onShareUrl(const PeerId &peer, const QString &url, const QString &text) {
|
||||
PeerData *p = App::peer(peer);
|
||||
if (!peer || p->canWrite()) {
|
||||
bool MainWidget::shareUrl(
|
||||
not_null<PeerData*> peer,
|
||||
const QString &url,
|
||||
const QString &text) {
|
||||
if (!peer->canWrite()) {
|
||||
Ui::show(Box<InformBox>(lang(lng_share_cant)));
|
||||
return false;
|
||||
}
|
||||
History *h = App::history(peer);
|
||||
TextWithTags textWithTags = { url + '\n' + text, TextWithTags::Tags() };
|
||||
MessageCursor cursor = { url.size() + 1, url.size() + 1 + text.size(), QFIXED_MAX };
|
||||
h->setLocalDraft(std::make_unique<Data::Draft>(textWithTags, 0, cursor, false));
|
||||
h->clearEditDraft();
|
||||
bool opened = _history->peer() && (_history->peer()->id == peer);
|
||||
if (opened) {
|
||||
TextWithTags textWithTags = {
|
||||
url + '\n' + text,
|
||||
TextWithTags::Tags()
|
||||
};
|
||||
MessageCursor cursor = {
|
||||
url.size() + 1,
|
||||
url.size() + 1 + text.size(),
|
||||
QFIXED_MAX
|
||||
};
|
||||
auto history = App::history(peer->id);
|
||||
history->setLocalDraft(
|
||||
std::make_unique<Data::Draft>(textWithTags, 0, cursor, false));
|
||||
history->clearEditDraft();
|
||||
if (_history->peer() == peer) {
|
||||
_history->applyDraft();
|
||||
} else {
|
||||
Ui::showPeerHistory(peer, ShowAtUnreadMsgId);
|
||||
|
Reference in New Issue
Block a user