diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 4cacf04bc..221425e2e 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -204,6 +204,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_filter_pin_limit2#one" = "Unpin some of the currently pinned ones or subscribe to **Telegram Premium** to double the limit to **{count}** chat."; "lng_filter_pin_limit2#other" = "Unpin some of the currently pinned ones or subscribe to **Telegram Premium** to double the limit to **{count}** chats."; +"lng_forum_pin_limit#one" = "Sorry, you can't pin more than **{count}** topic to the top."; +"lng_forum_pin_limit#other" = "Sorry, you can't pin more than **{count}** topics to the top."; + "lng_fave_sticker_limit_title#one" = "The Limit of {count} Stickers Reached"; "lng_fave_sticker_limit_title#other" = "The Limit of {count} Stickers Reached"; "lng_fave_sticker_limit_more#one" = "An older sticker was replaced with this one.\nYou can {link} to {count} sticker."; diff --git a/Telegram/SourceFiles/boxes/premium_limits_box.cpp b/Telegram/SourceFiles/boxes/premium_limits_box.cpp index 94f945cee..5e0fa9b09 100644 --- a/Telegram/SourceFiles/boxes/premium_limits_box.cpp +++ b/Telegram/SourceFiles/boxes/premium_limits_box.cpp @@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_chat_filters.h" #include "data/data_user.h" #include "data/data_channel.h" +#include "data/data_forum.h" #include "data/data_session.h" #include "data/data_folder.h" #include "data/data_premium_limits.h" @@ -800,6 +801,28 @@ void PinsLimitBox( PinsCount(session->data().chatsList())); } +void ForumPinsLimitBox( + not_null box, + not_null forum) { + const auto premium = false; + const auto premiumPossible = false; + + const auto current = forum->owner().pinnedChatsLimit(forum) * 1.; + + auto text = tr::lng_forum_pin_limit( + lt_count, + rpl::single(current), + Ui::Text::RichLangValue); + SimpleLimitBox( + box, + &forum->session(), + false, + tr::lng_filter_pin_limit_title(), + std::move(text), + QString(), + { current, current, current * 2, &st::premiumIconPins }); +} + void CaptionLimitBox( not_null box, not_null session, diff --git a/Telegram/SourceFiles/boxes/premium_limits_box.h b/Telegram/SourceFiles/boxes/premium_limits_box.h index de2a7db73..04a607de2 100644 --- a/Telegram/SourceFiles/boxes/premium_limits_box.h +++ b/Telegram/SourceFiles/boxes/premium_limits_box.h @@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/layers/generic_box.h" +namespace Data { +class Forum; +} // namespace Data + namespace Main { class Session; } // namespace Main @@ -41,6 +45,9 @@ void FolderPinsLimitBox( void PinsLimitBox( not_null box, not_null session); +void ForumPinsLimitBox( + not_null box, + not_null forum); void CaptionLimitBox( not_null box, not_null session, diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index cd87cf586..d9948f2ce 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -344,6 +344,7 @@ bool PinnedLimitReached( // Some old chat, that was converted, maybe is still pinned. const auto history = thread->asHistory(); if (!history) { + controller->show(Box(ForumPinsLimitBox, thread->asTopic()->forum())); return true; } const auto folder = history->folder(); @@ -380,11 +381,9 @@ void TogglePinnedThread( return; } const auto owner = &thread->owner(); - const auto isPinned = !thread->isPinnedDialog(0); - if (const auto history = thread->asHistory()) { - if (isPinned && PinnedLimitReached(controller, history, 0)) { - return; - } + const auto isPinned = !thread->isPinnedDialog(FilterId()); + if (isPinned && PinnedLimitReached(controller, thread)) { + return; } owner->setChatPinned(thread, FilterId(), isPinned);