-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Expand file tree
/
Copy pathshare_message_phrase_factory.cpp
More file actions
83 lines (75 loc) · 2.28 KB
/
Copy pathshare_message_phrase_factory.cpp
File metadata and controls
83 lines (75 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "chat_helpers/share_message_phrase_factory.h"
#include "chat_helpers/compose/compose_show.h"
#include "data/data_peer.h"
#include "data/data_user.h"
#include "lang/lang_keys.h"
#include "main/main_session.h"
#include "ui/text/text_utilities.h"
#include "window/window_session_controller.h"
namespace ChatHelpers {
rpl::producer<TextWithEntities> ForwardedMessagePhrase(
const ForwardedMessagePhraseArgs &args) {
if (args.toCount <= 1) {
Assert(args.to1);
if (args.to1->isSelf()) {
if (args.toSelfWithPremiumIsEmpty && args.to1->isPremium()) {
return {};
}
return (args.singleMessage
? tr::lng_share_message_to_saved
: tr::lng_share_messages_to_saved)(
lt_chat,
rpl::single(Ui::Text::Link(
tr::lng_saved_messages(tr::now))),
tr::rich);
} else {
return (args.singleMessage
? tr::lng_share_message_to_chat
: tr::lng_share_messages_to_chat)(
lt_chat,
rpl::single(TextWithEntities{ args.to1->name() }),
tr::rich);
}
} else if ((args.toCount == 2) && (args.to1 && args.to2)) {
return (args.singleMessage
? tr::lng_share_message_to_two_chats
: tr::lng_share_messages_to_two_chats)(
lt_user,
rpl::single(TextWithEntities{ args.to1->name() }),
lt_chat,
rpl::single(TextWithEntities{ args.to2->name() }),
tr::rich);
} else {
return (args.singleMessage
? tr::lng_share_message_to_many_chats
: tr::lng_share_messages_to_many_chats)(
lt_count,
rpl::single(args.toCount) | tr::to_count(),
tr::rich);
}
}
QString ForwardedMessagePhraseIcon(
const ForwardedMessagePhraseArgs &args) {
const auto toSelf = (args.toCount <= 1)
&& args.to1
&& args.to1->isSelf();
return toSelf
? u"toast/saved_messages"_q
: u"toast/forward"_q;
}
Ui::Toast::ClickHandlerFilter ForwardedToSavedMessagesFilter(
not_null<Main::Session*> session) {
return [=](const ClickHandlerPtr &, Qt::MouseButton) {
if (const auto window = ResolveWindowDefault()(session)) {
window->showPeerHistory(window->session().user());
}
return false;
};
}
} // namespace ChatHelpers