diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 32172fa6e..bb4562f79 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1342,6 +1342,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_group_request_sent_channel" = "You will be added to the channel once its admins approve your request."; "lng_group_requests_pending#one" = "{count} user requested to join"; "lng_group_requests_pending#other" = "{count} users requested to join"; +"lng_group_requests_pending_user" = "{user} requested to join"; "lng_group_requests_status" = "requested to join {date}"; "lng_group_requests_add" = "Add to Group"; "lng_group_requests_add_channel" = "Add to Channel"; diff --git a/Telegram/SourceFiles/history/view/history_view_requests_bar.cpp b/Telegram/SourceFiles/history/view/history_view_requests_bar.cpp index b5fc4fff9..8f70c5287 100644 --- a/Telegram/SourceFiles/history/view/history_view_requests_bar.cpp +++ b/Telegram/SourceFiles/history/view/history_view_requests_bar.cpp @@ -137,9 +137,9 @@ rpl::producer RequestsBarContentByPeer( result.match([&]( const MTPDmessages_chatInviteImporters &data) { const auto count = data.vcount().v; - const auto changed = (state->current.count != count); const auto &importers = data.vimporters().v; auto &owner = state->peer->owner(); + const auto old = base::take(state->users); state->users = std::vector>(); const auto use = std::min( importers.size(), @@ -152,8 +152,22 @@ rpl::producer RequestsBarContentByPeer( owner.user(data.vuser_id())); }); } + const auto changed = (state->current.count != count) + || (count == 1 + && ((state->users.size() != old.size()) + || (old.size() == 1 + && state->users.front() != old.front()))); if (changed) { state->current.count = count; + if (count == 1 && !state->users.empty()) { + const auto user = state->users.front(); + state->current.nameShort = user->shortName(); + state->current.nameFull = user->name; + } else { + state->current.nameShort + = state->current.nameFull + = QString(); + } } if (RegenerateUserpics(state, userpicSize) || changed) { push(); diff --git a/Telegram/SourceFiles/ui/chat/requests_bar.cpp b/Telegram/SourceFiles/ui/chat/requests_bar.cpp index da512977d..620754af9 100644 --- a/Telegram/SourceFiles/ui/chat/requests_bar.cpp +++ b/Telegram/SourceFiles/ui/chat/requests_bar.cpp @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/chat/group_call_userpics.h" #include "ui/widgets/shadow.h" +#include "ui/text/text_options.h" #include "lang/lang_keys.h" #include "styles/style_chat.h" #include "styles/style_calls.h" @@ -47,10 +48,31 @@ RequestsBar::RequestsBar( ) | rpl::start_with_next([=](RequestsBarContent &&content) { _content = content; if (_content.count > 0) { - _text = tr::lng_group_requests_pending( - tr::now, - lt_count_decimal, - _content.count); + if (_content.count == 1 && !_content.nameFull.isEmpty()) { + _textFull.setText( + st::defaultMessageBar.title, + tr::lng_group_requests_pending_user( + tr::now, + lt_user, + _content.nameFull), + Ui::NameTextOptions()); + _textShort.setText( + st::defaultMessageBar.title, + tr::lng_group_requests_pending_user( + tr::now, + lt_user, + _content.nameShort), + Ui::NameTextOptions()); + } else { + _textShort.setText( + st::defaultMessageBar.title, + tr::lng_group_requests_pending( + tr::now, + lt_count_decimal, + _content.count), + Ui::NameTextOptions()); + _textFull.clear(); + } } _userpics->update(_content.users, !_wrap.isHidden()); _inner->update(); @@ -131,7 +153,11 @@ void RequestsBar::paint(Painter &p) { const auto textLeft = userpicsLeft + _userpicsWidth + userpicsLeft; const auto available = width - textLeft - userpicsLeft; - p.drawTextLeft(textLeft, textTop, width, _text); + if (_textFull.isEmpty() || available < _textFull.maxWidth()) { + _textShort.drawElided(p, textLeft, textTop, available); + } else { + _textFull.drawElided(p, textLeft, textTop, available); + } // Skip shadow of the bar above. _userpics->paint(p, userpicsLeft, userpicsTop, userpicsSize); diff --git a/Telegram/SourceFiles/ui/chat/requests_bar.h b/Telegram/SourceFiles/ui/chat/requests_bar.h index 28d5df2d8..047d64a6d 100644 --- a/Telegram/SourceFiles/ui/chat/requests_bar.h +++ b/Telegram/SourceFiles/ui/chat/requests_bar.h @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/wrap/slide_wrap.h" #include "ui/effects/animations.h" +#include "ui/text/text.h" #include "base/object_ptr.h" #include "base/timer.h" @@ -22,6 +23,8 @@ class GroupCallUserpics; struct RequestsBarContent { std::vector users; + QString nameFull; + QString nameShort; int count = 0; bool isGroup = false; }; @@ -70,7 +73,8 @@ private: RequestsBarContent _content; std::unique_ptr _userpics; int _userpicsWidth = 0; - QString _text; + Ui::Text::String _textShort; + Ui::Text::String _textFull; };