From 959348f8cdc048e9571eebfc39e6a1954da70f5b Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 5 Apr 2023 15:36:28 +0400 Subject: [PATCH] Improve error messages for shareable folders. --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/api/api_chat_filters.cpp | 7 +++++-- Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp | 10 ++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index d2638a2ef..1d0fa7374 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -3592,6 +3592,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_filters_link_name_it" = "Name Link"; "lng_filters_link_delete_sure" = "Are you sure you want to delete this link?"; "lng_filters_link_qr_about" = "Everyone on Telegram can scan this code to add this folder and join the chats included in this invite link."; +"lng_filters_link_group_admin_error" = "One of the groups in this folder can’t be added because one of its admins has too many groups and channels."; "lng_filters_by_link_title" = "Add Folder"; "lng_filters_by_link_sure" = "Do you want to add a new chat folder {folder} and join its groups and channels?"; "lng_filters_by_link_join#one" = "{count} chat to join"; diff --git a/Telegram/SourceFiles/api/api_chat_filters.cpp b/Telegram/SourceFiles/api/api_chat_filters.cpp index 5729d38b6..2a8e3eaf3 100644 --- a/Telegram/SourceFiles/api/api_chat_filters.cpp +++ b/Telegram/SourceFiles/api/api_chat_filters.cpp @@ -488,16 +488,19 @@ void ShowImportError( const auto i = ranges::find(list, id, &Data::ChatFilter::id); const auto count = added + ((i != end(list)) ? int(i->always().size()) : 0); - if (error == u"USER_CHANNELS_TOO_MUCH"_q) { + if (error == u"CHANNELS_TOO_MUCH"_q) { window->show(Box(ChannelsLimitBox, session)); } else if (error == u"FILTER_INCLUDE_TOO_MUCH"_q) { window->show(Box(FilterChatsLimitBox, session, count)); } else if (error == u"CHATLISTS_TOO_MUCH"_q) { window->show(Box(ShareableFiltersLimitBox, session)); } else { + const auto text = (error == u"INVITE_SLUG_EXPIRED"_q) + ? tr::lng_group_invite_bad_link(tr::now) + : error; Ui::ShowMultilineToast({ .parentOverride = Window::Show(window).toastParent(), - .text = { error }, + .text = { text }, }); } } diff --git a/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp b/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp index 5a63062c1..7d43dc9b6 100644 --- a/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp +++ b/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp @@ -14,7 +14,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/layers/generic_box.h" #include "ui/text/text_utilities.h" #include "ui/text/text_options.h" -#include "ui/toasts/common_toasts.h" #include "ui/widgets/buttons.h" #include "ui/widgets/input_fields.h" #include "ui/wrap/slide_wrap.h" @@ -784,19 +783,22 @@ void EditFilterBox( *data = data->current().withChatlist(true, true); window->show(ShowLinkBox(window, updated, link)); }, [=](QString error) { + const auto session = &window->session(); if (error == u"CHATLISTS_TOO_MUCH"_q) { - const auto session = &window->session(); window->show(Box(ShareableFiltersLimitBox, session)); } else if (error == u"INVITES_TOO_MUCH"_q) { - const auto session = &window->session(); window->show(Box(FilterLinksLimitBox, session)); + } else if (error == u"CHANNELS_TOO_MUCH"_q) { + window->show(Box(ChannelsLimitBox, session)); + } else if (error == u"USER_CHANNELS_TOO_MUCH"_q) { + window->showToast( + { tr::lng_filters_link_group_admin_error(tr::now) }); } else { window->show(ShowLinkBox(window, updated, { .id = id })); } }); })); }, createLink->lifetime()); - AddSkip(content); AddDividerText( content,