From de230332b95a9cb786bc141fa4df32be0b756897 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 3 Oct 2019 19:49:59 +0300 Subject: [PATCH 1/6] Version 1.8.14: Fix crash in text processing on old OS X. --- Telegram/Resources/uwp/AppX/AppxManifest.xml | 2 +- Telegram/Resources/winrc/Telegram.rc | 8 ++++---- Telegram/Resources/winrc/Updater.rc | 8 ++++---- Telegram/SourceFiles/core/version.h | 4 ++-- Telegram/SourceFiles/ui/text/text.cpp | 16 ++++++++++------ Telegram/build/version | 6 +++--- changelog.txt | 4 ++++ 7 files changed, 28 insertions(+), 20 deletions(-) diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml index 530165669..5281fcb22 100644 --- a/Telegram/Resources/uwp/AppX/AppxManifest.xml +++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml @@ -9,7 +9,7 @@ + Version="1.8.14.0" /> Telegram Desktop Telegram FZ-LLC diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index a605dd0f9..2ea805229 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -33,8 +33,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,8,13,0 - PRODUCTVERSION 1,8,13,0 + FILEVERSION 1,8,14,0 + PRODUCTVERSION 1,8,14,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -51,10 +51,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop" - VALUE "FileVersion", "1.8.13.0" + VALUE "FileVersion", "1.8.14.0" VALUE "LegalCopyright", "Copyright (C) 2014-2019" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "1.8.13.0" + VALUE "ProductVersion", "1.8.14.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index bc05c7140..6e3a1c18a 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -24,8 +24,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,8,13,0 - PRODUCTVERSION 1,8,13,0 + FILEVERSION 1,8,14,0 + PRODUCTVERSION 1,8,14,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -42,10 +42,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop Updater" - VALUE "FileVersion", "1.8.13.0" + VALUE "FileVersion", "1.8.14.0" VALUE "LegalCopyright", "Copyright (C) 2014-2019" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "1.8.13.0" + VALUE "ProductVersion", "1.8.14.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index 32f5657dd..a37424e1a 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -15,7 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #define TDESKTOP_ALPHA_VERSION (0ULL) #endif // TDESKTOP_OFFICIAL_TARGET -constexpr auto AppVersion = 1008013; -constexpr auto AppVersionStr = "1.8.13"; +constexpr auto AppVersion = 1008014; +constexpr auto AppVersionStr = "1.8.14"; constexpr auto AppBetaVersion = false; constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION; diff --git a/Telegram/SourceFiles/ui/text/text.cpp b/Telegram/SourceFiles/ui/text/text.cpp index 7891995be..cc865eace 100644 --- a/Telegram/SourceFiles/ui/text/text.cpp +++ b/Telegram/SourceFiles/ui/text/text.cpp @@ -118,14 +118,18 @@ bool ComputeCheckTilde(const style::TextStyle &st) { bool chIsBad(QChar ch) { return (ch == 0) - || (ch >= 8232 && ch < 8237) - || (ch >= 65024 && ch < 65040 && ch != 65039) - || (ch >= 127 && ch < 160 && ch != 156) + || (ch >= 8232 && ch < 8237) + || (ch >= 65024 && ch < 65040 && ch != 65039) + || (ch >= 127 && ch < 160 && ch != 156) - // qt harfbuzz crash see https://github.com/telegramdesktop/tdesktop/issues/4551 - || (Platform::IsMac() && ch == 6158) + // qt harfbuzz crash see https://github.com/telegramdesktop/tdesktop/issues/4551 + || (Platform::IsMac() && ch == 6158) - // tmp hack see https://bugreports.qt.io/browse/QTBUG-48910 + || (Platform::IsMac() + && !Platform::IsMac10_7OrGreater() + && (ch == 8207 || ch == 8206 || ch == 8288)) + + // tmp hack see https://bugreports.qt.io/browse/QTBUG-48910 || (Platform::IsMac10_11OrGreater() && !Platform::IsMac10_12OrGreater() && ch >= 0x0B00 diff --git a/Telegram/build/version b/Telegram/build/version index aec94f196..5572a2b64 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,6 +1,6 @@ -AppVersion 1008013 +AppVersion 1008014 AppVersionStrMajor 1.8 -AppVersionStrSmall 1.8.13 -AppVersionStr 1.8.13 +AppVersionStrSmall 1.8.14 +AppVersionStr 1.8.14 BetaChannel 0 AlphaVersion 0 diff --git a/changelog.txt b/changelog.txt index b7f97921a..1e82844b8 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +1.8.14 (03.10.19) + +- Bug fixes and other minor improvements. + 1.8.13 (03.10.19) - Bug fixes and other minor improvements. From 60b39c8f7e1a3b7c6cd46f4c591a27ad4da7c5e4 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 7 Oct 2019 12:19:04 +0300 Subject: [PATCH 2/6] Fix inline result previews. --- .../inline_bot_layout_internal.cpp | 4 +-- .../inline_bots/inline_bot_layout_item.cpp | 7 +++- .../inline_bots/inline_bot_layout_item.h | 2 +- .../inline_bots/inline_bot_result.cpp | 4 +-- .../media/view/media_view_overlay_widget.cpp | 32 ++++++++----------- 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp index cacf33239..24a485763 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp @@ -625,7 +625,7 @@ void Photo::prepareThumbnail(QSize size, QSize frame) const { } Video::Video(not_null context, Result *result) : FileBase(context, result) -, _link(getResultContentUrlHandler()) +, _link(getResultPreviewHandler()) , _title(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) , _description(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) { if (int duration = content_duration()) { @@ -1057,7 +1057,7 @@ void Contact::prepareThumbnail(int width, int height) const { Article::Article(not_null context, Result *result, bool withThumb) : ItemBase(context, result) , _url(getResultUrlHandler()) -, _link(getResultContentUrlHandler()) +, _link(getResultPreviewHandler()) , _withThumb(withThumb) , _title(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) , _description(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) { diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp index 32601d549..4823a58f1 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp @@ -187,11 +187,16 @@ ClickHandlerPtr ItemBase::getResultUrlHandler() const { return ClickHandlerPtr(); } -ClickHandlerPtr ItemBase::getResultContentUrlHandler() const { +ClickHandlerPtr ItemBase::getResultPreviewHandler() const { if (!_result->_content_url.isEmpty()) { return std::make_shared( _result->_content_url, false); + } else if (_result->_document && _result->_document->canBePlayed()) { + return std::make_shared( + _result->_document); + } else if (_result->_photo) { + return std::make_shared(_result->_photo); } return ClickHandlerPtr(); } diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.h b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.h index 106cfb507..b506d6cae 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.h +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.h @@ -103,7 +103,7 @@ protected: int getResultDuration() const; QString getResultUrl() const; ClickHandlerPtr getResultUrlHandler() const; - ClickHandlerPtr getResultContentUrlHandler() const; + ClickHandlerPtr getResultPreviewHandler() const; QString getResultThumbLetter() const; not_null context() const { diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_result.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_result.cpp index 495ee9ed1..0cacca7fa 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_result.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_result.cpp @@ -272,9 +272,9 @@ bool Result::onChoose(Layout::ItemBase *layout) { } else if (_document->loading()) { _document->cancel(); } else { - _document->save( + DocumentSaveClickHandler::Save( Data::FileOriginSavedGifs(), - QString()); + _document); } return false; } diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index 99d773f64..9aa9e6cc9 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -2358,25 +2358,19 @@ void OverlayWidget::playbackPauseResume() { Expects(_streamed != nullptr); _streamed->resumeOnCallEnd = false; - if (const auto item = Auth().data().message(_msgid)) { - if (_streamed->player.failed()) { - clearStreaming(); - initStreaming(); - } else if (_streamed->player.finished()) { - _streamingStartPaused = false; - restartAtSeekPosition(0); - } else if (_streamed->player.paused()) { - _streamed->player.resume(); - updatePlaybackState(); - playbackPauseMusic(); - } else { - _streamed->player.pause(); - updatePlaybackState(); - } - } else { + if (_streamed->player.failed()) { clearStreaming(); - updateControls(); - update(); + initStreaming(); + } else if (_streamed->player.finished()) { + _streamingStartPaused = false; + restartAtSeekPosition(0); + } else if (_streamed->player.paused()) { + _streamed->player.resume(); + updatePlaybackState(); + playbackPauseMusic(); + } else { + _streamed->player.pause(); + updatePlaybackState(); } } @@ -3324,7 +3318,7 @@ void OverlayWidget::mousePressEvent(QMouseEvent *e) { void OverlayWidget::mouseDoubleClickEvent(QMouseEvent *e) { updateOver(e->pos()); - if (_over == OverVideo) { + if (_over == OverVideo && _streamed) { playbackToggleFullScreen(); playbackPauseResume(); } else { From 55d5f6e03d0b5ec197ca0296e5d381ec748bb61c Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 7 Oct 2019 12:35:49 +0300 Subject: [PATCH 3/6] Fix possible crash in emoji suggestions. Fixes #6652, fixes #6654. --- .../chat_helpers/emoji_keywords.cpp | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/emoji_keywords.cpp b/Telegram/SourceFiles/chat_helpers/emoji_keywords.cpp index a1d6bc3a0..eb8f4f150 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_keywords.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_keywords.cpp @@ -170,7 +170,7 @@ void AppendFoundEmoji( const std::vector &list) { // It is important that the 'result' won't relocate while inserting. result.reserve(result.size() + list.size()); - const auto alreadyBegin = result.data(); + const auto alreadyBegin = begin(result); const auto alreadyEnd = alreadyBegin + result.size(); auto &&add = ranges::view::all( @@ -204,6 +204,12 @@ void AppendLegacySuggestions( } const auto suggestions = GetSuggestions(QStringToUTF16(query)); + + // It is important that the 'result' won't relocate while inserting. + result.reserve(result.size() + suggestions.size()); + const auto alreadyBegin = begin(result); + const auto alreadyEnd = alreadyBegin + result.size(); + auto &&add = ranges::view::all( suggestions ) | ranges::view::transform([](const Suggestion &suggestion) { @@ -214,10 +220,14 @@ void AppendLegacySuggestions( }; }) | ranges::view::filter([&](const Result &entry) { const auto i = entry.emoji - ? ranges::find(result, entry.emoji, &Result::emoji) - : end(result); + ? ranges::find( + alreadyBegin, + alreadyEnd, + entry.emoji, + &Result::emoji) + : alreadyEnd; return (entry.emoji != nullptr) - && (i == end(result)); + && (i == alreadyEnd); }); result.insert(end(result), add.begin(), add.end()); } @@ -593,21 +603,24 @@ std::vector EmojiKeywords::query( } auto result = std::vector(); for (const auto &[language, item] : _data) { - const auto oldcount = result.size(); const auto list = item->query(normalized, exact); + + // It is important that the 'result' won't relocate while inserting. + result.reserve(result.size() + list.size()); + const auto alreadyBegin = begin(result); + const auto alreadyEnd = alreadyBegin + result.size(); + auto &&add = ranges::view::all( list ) | ranges::view::filter([&](Result entry) { // In each item->query() result the list has no duplicates. // So we need to check only for duplicates between queries. - const auto oldbegin = begin(result); - const auto oldend = oldbegin + oldcount; const auto i = ranges::find( - oldbegin, - oldend, + alreadyBegin, + alreadyEnd, entry.emoji, &Result::emoji); - return (i == oldend); + return (i == alreadyEnd); }); result.insert(end(result), add.begin(), add.end()); } From 2835aa446f8598fca1b8e724a76524f74a1c8c90 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 7 Oct 2019 17:28:36 +0300 Subject: [PATCH 4/6] Fix possible HistoryHider bug on old OS X. --- Telegram/SourceFiles/mainwidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 8853f7b29..423acba13 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -809,6 +809,7 @@ void MainWidget::hiderLayer(base::unique_qptr hider) { _hider->hidden( ) | rpl::start_with_next([=, instance = _hider.get()] { clearHider(instance); + instance->hide(); instance->deleteLater(); }, _hider->lifetime()); From 5f06279b9aae620f52c5b029a21b58653469fccb Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 7 Oct 2019 17:33:41 +0300 Subject: [PATCH 5/6] Version 1.8.15. - Bug fixes and other minor improvements. --- Telegram/Resources/uwp/AppX/AppxManifest.xml | 2 +- Telegram/Resources/winrc/Telegram.rc | 8 ++++---- Telegram/Resources/winrc/Updater.rc | 8 ++++---- Telegram/SourceFiles/core/version.h | 4 ++-- Telegram/build/version | 6 +++--- changelog.txt | 4 ++++ 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml index 5281fcb22..7904b4d0e 100644 --- a/Telegram/Resources/uwp/AppX/AppxManifest.xml +++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml @@ -9,7 +9,7 @@ + Version="1.8.15.0" /> Telegram Desktop Telegram FZ-LLC diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index 2ea805229..90f7cd204 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -33,8 +33,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,8,14,0 - PRODUCTVERSION 1,8,14,0 + FILEVERSION 1,8,15,0 + PRODUCTVERSION 1,8,15,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -51,10 +51,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop" - VALUE "FileVersion", "1.8.14.0" + VALUE "FileVersion", "1.8.15.0" VALUE "LegalCopyright", "Copyright (C) 2014-2019" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "1.8.14.0" + VALUE "ProductVersion", "1.8.15.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index 6e3a1c18a..b2f182d8e 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -24,8 +24,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,8,14,0 - PRODUCTVERSION 1,8,14,0 + FILEVERSION 1,8,15,0 + PRODUCTVERSION 1,8,15,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -42,10 +42,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop Updater" - VALUE "FileVersion", "1.8.14.0" + VALUE "FileVersion", "1.8.15.0" VALUE "LegalCopyright", "Copyright (C) 2014-2019" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "1.8.14.0" + VALUE "ProductVersion", "1.8.15.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index a37424e1a..51ac20105 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -15,7 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #define TDESKTOP_ALPHA_VERSION (0ULL) #endif // TDESKTOP_OFFICIAL_TARGET -constexpr auto AppVersion = 1008014; -constexpr auto AppVersionStr = "1.8.14"; +constexpr auto AppVersion = 1008015; +constexpr auto AppVersionStr = "1.8.15"; constexpr auto AppBetaVersion = false; constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION; diff --git a/Telegram/build/version b/Telegram/build/version index 5572a2b64..8afc73acc 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,6 +1,6 @@ -AppVersion 1008014 +AppVersion 1008015 AppVersionStrMajor 1.8 -AppVersionStrSmall 1.8.14 -AppVersionStr 1.8.14 +AppVersionStrSmall 1.8.15 +AppVersionStr 1.8.15 BetaChannel 0 AlphaVersion 0 diff --git a/changelog.txt b/changelog.txt index 1e82844b8..b67b9206a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +1.8.15 (07.10.19) + +- Bug fixes and other minor improvements. + 1.8.14 (03.10.19) - Bug fixes and other minor improvements. From 261a83eda352786c083824d29b2a77e8af3f881e Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Mon, 7 Oct 2019 17:35:22 +0300 Subject: [PATCH 6/6] Show restricted date to user (#6642) * Show restricted date to user * Fixed attach button toast * Fixed attach button toast in scheduled messages --- Telegram/Resources/langs/lang.strings | 7 ++++ Telegram/SourceFiles/data/data_peer.cpp | 32 +++++++++++++++++++ .../SourceFiles/history/history_widget.cpp | 2 +- .../view/history_view_scheduled_section.cpp | 2 +- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 7afb4b7bc..5b6d8f672 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1768,6 +1768,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_restricted_send_inline" = "The admins of this group restricted you from posting inline content here."; "lng_restricted_send_polls" = "The admins of this group restricted you from posting polls here."; +"lng_restricted_send_message_until" = "The admins of this group restricted you from writing here until {date}, {time}."; +"lng_restricted_send_media_until" = "The admins of this group restricted you from posting media content here until {date}, {time}."; +"lng_restricted_send_stickers_until" = "The admins of this group restricted you from posting stickers here until {date}, {time}."; +"lng_restricted_send_gifs_until" = "The admins of this group restricted you from posting GIFs here until {date}, {time}."; +"lng_restricted_send_inline_until" = "The admins of this group restricted you from posting inline content here until {date}, {time}."; +"lng_restricted_send_polls_until" = "The admins of this group restricted you from posting polls here until {date}, {time}."; + "lng_restricted_send_message_all" = "Writing messages isn't allowed in this group."; "lng_restricted_send_media_all" = "Posting media content isn't allowed in this group."; "lng_restricted_send_stickers_all" = "Posting stickers isn't allowed in this group."; diff --git a/Telegram/SourceFiles/data/data_peer.cpp b/Telegram/SourceFiles/data/data_peer.cpp index de36eab49..cfb91084e 100644 --- a/Telegram/SourceFiles/data/data_peer.cpp +++ b/Telegram/SourceFiles/data/data_peer.cpp @@ -754,6 +754,38 @@ std::optional RestrictionError( using Flag = ChatRestriction; if (const auto restricted = peer->amRestricted(restriction)) { const auto all = restricted.isWithEveryone(); + const auto channel = peer->asChannel(); + if (!all && channel) { + auto restrictedUntil = channel->restrictedUntil(); + if (restrictedUntil > 0 && !ChannelData::IsRestrictedForever(restrictedUntil)) { + auto restrictedUntilDateTime = base::unixtime::parse(channel->restrictedUntil()); + auto date = restrictedUntilDateTime.toString(qsl("dd.MM.yy")); + auto time = restrictedUntilDateTime.toString(cTimeFormat()); + + switch (restriction) { + case Flag::f_send_polls: + return tr::lng_restricted_send_polls_until( + tr::now, lt_date, date, lt_time, time); + case Flag::f_send_messages: + return tr::lng_restricted_send_message_until( + tr::now, lt_date, date, lt_time, time); + case Flag::f_send_media: + return tr::lng_restricted_send_media_until( + tr::now, lt_date, date, lt_time, time); + case Flag::f_send_stickers: + return tr::lng_restricted_send_stickers_until( + tr::now, lt_date, date, lt_time, time); + case Flag::f_send_gifs: + return tr::lng_restricted_send_gifs_until( + tr::now, lt_date, date, lt_time, time); + case Flag::f_send_inline: + case Flag::f_send_games: + return tr::lng_restricted_send_inline_until( + tr::now, lt_date, date, lt_time, time); + } + Unexpected("Restriction in Data::RestrictionErrorKey."); + } + } switch (restriction) { case Flag::f_send_polls: return all diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 320d11a64..fd549bf9a 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -3219,7 +3219,7 @@ void HistoryWidget::chooseAttach() { } else if (const auto error = Data::RestrictionError( _peer, ChatRestriction::f_send_media)) { - Ui::Toast::Show(*error); + ShowErrorToast(*error); return; } else if (showSlowmodeError()) { return; diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index 9e51ada7e..f2813348f 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -170,7 +170,7 @@ void ScheduledWidget::chooseAttach() { if (const auto error = Data::RestrictionError( _history->peer, ChatRestriction::f_send_media)) { - Ui::Toast::Show(*error); + ShowErrorToast(*error); return; }