Improve error messages for shareable folders.

This commit is contained in:
John Preston 2023-04-05 15:36:28 +04:00
parent 1a1fa5db3e
commit 959348f8cd
3 changed files with 12 additions and 6 deletions

View File

@ -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 cant 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";

View File

@ -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 },
});
}
}

View File

@ -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,