diff --git a/Telegram/SourceFiles/boxes/premium_limits_box.cpp b/Telegram/SourceFiles/boxes/premium_limits_box.cpp index 0998d44223..27d11c236d 100644 --- a/Telegram/SourceFiles/boxes/premium_limits_box.cpp +++ b/Telegram/SourceFiles/boxes/premium_limits_box.cpp @@ -837,7 +837,8 @@ void CaptionLimitReachedBox( void FileSizeLimitBox( not_null box, - not_null session) { + not_null session, + uint64 fileSizeBytes) { const auto premium = session->premium(); const auto defaultLimit = Limit( @@ -851,6 +852,12 @@ void FileSizeLimitBox( const auto defaultGb = (defaultLimit + 999) / 2000; const auto premiumGb = (premiumLimit + 999) / 2000; + const auto current = fileSizeBytes + ? std::clamp( + float64(((fileSizeBytes / uint64(1024 * 1024)) + 999) / 1000), + defaultGb, + premiumGb) + : defaultGb; const auto gb = [](int count) { return tr::lng_file_size_limit(tr::now, lt_count, count); }; @@ -876,7 +883,7 @@ void FileSizeLimitBox( "upload_max_fileparts", { defaultGb, - defaultGb, + current, premiumGb, &st::premiumIconFiles, tr::lng_file_size_limit diff --git a/Telegram/SourceFiles/boxes/premium_limits_box.h b/Telegram/SourceFiles/boxes/premium_limits_box.h index d050f772cd..ae3e74cbf4 100644 --- a/Telegram/SourceFiles/boxes/premium_limits_box.h +++ b/Telegram/SourceFiles/boxes/premium_limits_box.h @@ -48,7 +48,8 @@ void CaptionLimitReachedBox( int remove); void FileSizeLimitBox( not_null box, - not_null session); + not_null session, + uint64 fileSizeBytes); void AccountsLimitBox( not_null box, not_null session); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 65dc82c9a1..a41c3ad1dc 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -4913,7 +4913,8 @@ bool HistoryWidget::showSendingFilesError( if (text.isEmpty()) { return false; } else if (text == u"(premium)"_q) { - controller()->show(Box(FileSizeLimitBox, &session())); + const auto fileSize = list.files.back().size; + controller()->show(Box(FileSizeLimitBox, &session(), fileSize)); return true; } diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index 7bf458a964..3c04316f19 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -948,7 +948,8 @@ bool RepliesWidget::showSendingFilesError( if (text.isEmpty()) { return false; } else if (text == u"(premium)"_q) { - controller()->show(Box(FileSizeLimitBox, &session())); + const auto fileSize = list.files.back().size; + controller()->show(Box(FileSizeLimitBox, &session(), fileSize)); return true; } diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index deb047f58d..c97f223ebf 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -568,7 +568,8 @@ bool ScheduledWidget::showSendingFilesError( if (text.isEmpty()) { return false; } else if (text == u"(premium)"_q) { - controller()->show(Box(FileSizeLimitBox, &session())); + const auto fileSize = list.files.back().size; + controller()->show(Box(FileSizeLimitBox, &session(), fileSize)); return true; } diff --git a/Telegram/SourceFiles/storage/storage_media_prepare.cpp b/Telegram/SourceFiles/storage/storage_media_prepare.cpp index 853b252cf6..6ab1c044b5 100644 --- a/Telegram/SourceFiles/storage/storage_media_prepare.cpp +++ b/Telegram/SourceFiles/storage/storage_media_prepare.cpp @@ -223,10 +223,12 @@ PreparedList PrepareMediaList( file }; } else if (filesize > kFileSizeLimit && !premium) { - return { + auto errorResult = PreparedList( PreparedList::Error::PremiumRequired, - file - }; + QString()); + errorResult.files.emplace_back(file); + errorResult.files.back().size = filesize; + return errorResult; } if (result.files.size() < Ui::MaxAlbumItems()) { result.files.emplace_back(file);