From b2e829904fb7976784618dea18700dbb5568b42f Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 30 Jul 2021 14:43:48 +0300 Subject: [PATCH] Add support for 1 month self-destruct messages. --- .../icons/chat/input_autodelete_30d.png | Bin 0 -> 1010 bytes .../icons/chat/input_autodelete_30d@2x.png | Bin 0 -> 2072 bytes .../icons/chat/input_autodelete_30d@3x.png | Bin 0 -> 3036 bytes Telegram/Resources/langs/lang.strings | 10 ++++++---- Telegram/SourceFiles/boxes/about_box.cpp | 2 -- Telegram/SourceFiles/core/crash_reports.cpp | 2 -- Telegram/SourceFiles/data/data_session.cpp | 7 +++++-- .../history/admin_log/history_admin_log_item.cpp | 6 ++++-- Telegram/SourceFiles/history/history_service.cpp | 6 ++++-- .../view/controls/history_view_ttl_button.cpp | 14 ++++++++++---- .../ui/boxes/auto_delete_settings.cpp | 11 ++++++++--- Telegram/SourceFiles/ui/chat/chat.style | 2 ++ 12 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 Telegram/Resources/icons/chat/input_autodelete_30d.png create mode 100644 Telegram/Resources/icons/chat/input_autodelete_30d@2x.png create mode 100644 Telegram/Resources/icons/chat/input_autodelete_30d@3x.png diff --git a/Telegram/Resources/icons/chat/input_autodelete_30d.png b/Telegram/Resources/icons/chat/input_autodelete_30d.png new file mode 100644 index 0000000000000000000000000000000000000000..dc06d9a4d757d69ce204e055ea12e8db822fda1f GIT binary patch literal 1010 zcmVPx#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91B%lKT1ONa40RR91Bme*a04fgS`~Uz0TuDShR9Fe^mQ5&pQ53+>3?d)J zj+BJ*QL>n|GRw(AN*3%SO}9GY8Ds^3t14^QnFyi=9&#Puikt2-t+aFbI+W2Z2*Ac{xz5V*O2@Ni33^fNIXM-E<=e{#4>qCMh0|r zbU+{wfT^h|czb)3sVc8iA5y+2CMHn34i68ps;Wxaha|2#3_0@q{mgT7bE9#g$P}ie zq{IsLGoZ)EM+V8x&c?yPL40|6;rYtS3Z|x}#sZ}dL|LHg_4QQ`Tv}R+TDI2K)-WwC zO_xcwMkbFAC?_WelarI#NkKsY1D&0neQ`?bmzS3;o1C2dB2$2}2I}ta#*dE=yuQB1 z{QP{Zsj1dc8a!8X7VT*xTF7 z@|~R>L%9J&xSl!C*w`35UtCv=ofoD9@ZTm9yZl8u$2QfHa4=;@LCxd7{K-Qb*!wcG!5i* zI@xw(W5ZNW321h9mYue?wyHYC+}vEYy}P?pwUuY+=;(-@mX(#MIz_wPj#pP#cye;0 zYAXkNetu>k@gY@p%KB7;nVFeNwx$O(K_j*pKy+Pxn>~t(ia^v0%+Js3YIG6^27~%M z+JW>JEH5u}hU)6-q&gx9f9ao|o>+HtbJJ9p^et|=LR(uK2ie=(Lz~TJ=!k0N;NSr1 zQ*nHJj2aMibn5JVeSJu^NZUU$GJ^g6{rK?kfYdartE-KC%7K!Sl90YvboKP~7#Z`L zRwt*Yr#et!VIkYmsi3{Ro!4n$YikQzT3Q&8+J`~58D?f?K%ArbFRdETiimQi_7ki;#wd?ELovpQ+B^pF07*qoM6N<$g7B}@9RL6T literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/chat/input_autodelete_30d@2x.png b/Telegram/Resources/icons/chat/input_autodelete_30d@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..b9f03cbbb5825dd1226f4497a12bed74ae35ce7e GIT binary patch literal 2072 zcmZ8ic|6o>7ypf6Oqfhf8I0{_9U^5bB-^C9VGyISjg++v*-g?!*+w@)jeW|_H8s`{ z)th^ZEJM*)rbICq+{&Ki{`%*AKcDxH^PKaX^Zny_p7VXqH`T%31|cRZ1^@s8f5zGg z^k;q<90sl~3-vajgM>TTSOTm*xmj>y?Ry^YXJ-d!f-xL`BnJY*zaXH=f(8IkCIoMYzrB$y1 z(U&^H1_`h>Nll+?juyp-H4a6Ih+u}j9pEqvB>RF@r%sfhy;d)|d2u{C`X}#t^nfiLNFye4QZN$xva3h56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ed<65TZn%Js#>NvTM))PfFzPDDSTY{o@nesPxS2D z+gEIhb=DkAyA}wR>mE`>Sq8l&K6ch+RsR5#PcD5<_8!bhMP6gVsLa)u*e^L;!Z3rV zE{l%9wX}3z*V?G3QgMN_=C3WDZ_f#9WCl{BGmG^jKWLvS^cqi)cZo_=pxPP>SN!m` zC=FZDcT$m~KJtVh$G>u6~w6r1|L0%oUYbcW>XQAC#9WD$>XQl z0Stu4-|{(}VEOBt6P1jg%x^QrVmy*19SBlOoui;VSlAgjRz`g4izB;e6=gHQ7rf zN8RDA!o>g^TTl8Rh1-WESup&gc(z-U<74l(wjhxMVoN(`^^Phtb`k4}p;L`+_jJFr z9!<0-h8FQG@xSPo(`y`tT^dEv?93_W&zgjuqu(7smp4nfUD{%YM(|lx-5#=|5pTRi z8YDe8q4Xeiu8gehFZ|ApQ4ic|;3Uh#I%&NM{;<;%8%N$w3WzNX%mSfY*kSHtUv-yR8vrPHt0rUa@@ZGx*UG# literal 0 HcmV?d00001 diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index cf50921c95..5ce90423ed 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1017,8 +1017,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_manage_messages_ttl_title" = "Auto-delete messages"; "lng_manage_messages_ttl_never" = "Off"; -"lng_manage_messages_ttl_after1" = "24 hours"; -"lng_manage_messages_ttl_after2" = "7 days"; +"lng_manage_messages_ttl_after1" = "1 day"; +"lng_manage_messages_ttl_after2" = "1 week"; +"lng_manage_messages_ttl_after3" = "1 month"; "lng_ttl_edit_about" = "Automatically delete new messages after a certain period of time for you and {user}."; "lng_ttl_edit_about_group" = "Automatically delete new messages sent in this chat after a certain period of time."; @@ -1027,8 +1028,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_ttl_about_tooltip" = "New messages in this chat will be automatically deleted in {duration}."; "lng_ttl_about_tooltip_channel" = "New messages in this chat will be automatically deleted in {duration}."; "lng_ttl_about_tooltip_off" = "Auto-delete is now disabled."; -"lng_ttl_about_duration1" = "24 hours"; -"lng_ttl_about_duration2" = "7 days"; +"lng_ttl_about_duration1" = "1 day"; +"lng_ttl_about_duration2" = "1 week"; +"lng_ttl_about_duration3" = "1 month"; "lng_report_title" = "Report channel"; "lng_report_group_title" = "Report group"; diff --git a/Telegram/SourceFiles/boxes/about_box.cpp b/Telegram/SourceFiles/boxes/about_box.cpp index c43cb3afaf..f215088385 100644 --- a/Telegram/SourceFiles/boxes/about_box.cpp +++ b/Telegram/SourceFiles/boxes/about_box.cpp @@ -93,8 +93,6 @@ void AboutBox::showVersionHistory() { url += qsl("win/%1.zip"); } else if (Platform::IsWindows64Bit()) { url += qsl("win64/%1.zip"); - } else if (Platform::IsOSXBuild()) { - url += qsl("osx/%1.zip"); } else if (Platform::IsMac()) { url += qsl("mac/%1.zip"); } else if (Platform::IsLinux32Bit()) { diff --git a/Telegram/SourceFiles/core/crash_reports.cpp b/Telegram/SourceFiles/core/crash_reports.cpp index 022c6a14c9..47b6d69ccb 100644 --- a/Telegram/SourceFiles/core/crash_reports.cpp +++ b/Telegram/SourceFiles/core/crash_reports.cpp @@ -297,8 +297,6 @@ QString PlatformString() { return qsl("Windows64Bit"); } else if (Platform::IsMacStoreBuild()) { return qsl("MacAppStore"); - } else if (Platform::IsOSXBuild()) { - return qsl("OSX"); } else if (Platform::IsMac()) { return qsl("MacOS"); } else if (Platform::IsLinux32Bit()) { diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 421a2096b3..1068f1cb3d 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -2020,8 +2020,11 @@ void Session::scheduleNextTTLs() { } const auto nearest = _ttlMessages.begin()->first; const auto now = base::unixtime::now(); - const auto timeout = (std::max(now, nearest) - now) * crl::time(1000); - _ttlCheckTimer.callOnce(timeout); + + // Set timer not more than for 24 hours. + const auto maxTimeout = TimeId(86400); + const auto timeout = std::min(std::max(now, nearest) - now, maxTimeout); + _ttlCheckTimer.callOnce(timeout * crl::time(1000)); } void Session::unregisterMessageTTL( diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp index 429e85c7f8..15dd167b74 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp @@ -1047,9 +1047,11 @@ void GenerateItems( const auto wrap = [](int duration) { return (duration == 5) ? u"5 seconds"_q - : (duration < 3 * 86400) + : (duration < 2 * 86400) ? tr::lng_manage_messages_ttl_after1(tr::now) - : tr::lng_manage_messages_ttl_after2(tr::now); + : (duration < 8 * 86400) + ? tr::lng_manage_messages_ttl_after2(tr::now) + : tr::lng_manage_messages_ttl_after3(tr::now); }; auto text = !was ? tr::lng_admin_log_messages_ttl_set(tr::now, lt_from, fromLinkText, lt_duration, wrap(now)) diff --git a/Telegram/SourceFiles/history/history_service.cpp b/Telegram/SourceFiles/history/history_service.cpp index ecb8ed9781..10fd3111e3 100644 --- a/Telegram/SourceFiles/history/history_service.cpp +++ b/Telegram/SourceFiles/history/history_service.cpp @@ -399,9 +399,11 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { const auto period = action.vperiod().v; const auto duration = (period == 5) ? u"5 seconds"_q - : (period < 3 * 86400) + : (period < 2 * 86400) ? tr::lng_ttl_about_duration1(tr::now) - : tr::lng_ttl_about_duration2(tr::now); + : (period < 8 * 86400) + ? tr::lng_ttl_about_duration2(tr::now) + : tr::lng_ttl_about_duration3(tr::now); if (isPost()) { if (!period) { result.text = tr::lng_action_ttl_removed_channel(tr::now); diff --git a/Telegram/SourceFiles/history/view/controls/history_view_ttl_button.cpp b/Telegram/SourceFiles/history/view/controls/history_view_ttl_button.cpp index 1adcb2a42c..3e432e5e68 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_ttl_button.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_ttl_button.cpp @@ -37,9 +37,11 @@ void ShowAutoDeleteToast(not_null peer) { const auto duration = (period == 5) ? u"5 seconds"_q - : (period < 3 * 86400) + : (period < 2 * 86400) ? tr::lng_ttl_about_duration1(tr::now) - : tr::lng_ttl_about_duration2(tr::now); + : (period < 8 * 86400) + ? tr::lng_ttl_about_duration2(tr::now) + : tr::lng_ttl_about_duration3(tr::now); const auto text = peer->isBroadcast() ? tr::lng_ttl_about_tooltip_channel(tr::now, lt_duration, duration) : tr::lng_ttl_about_tooltip(tr::now, lt_duration, duration); @@ -113,12 +115,16 @@ TTLButton::TTLButton(not_null parent, not_null peer) Data::PeerUpdate::Flag::MessagesTTL ) | rpl::start_with_next([=] { const auto ttl = peer->messagesTTL(); - if (ttl < 3 * 86400) { + if (ttl < 2 * 86400) { _button.setIconOverride(nullptr, nullptr); - } else { + } else if (ttl < 8 * 86400) { _button.setIconOverride( &st::historyMessagesTTL2Icon, &st::historyMessagesTTL2IconOver); + } else { + _button.setIconOverride( + &st::historyMessagesTTL3Icon, + &st::historyMessagesTTL3IconOver); } }, _button.lifetime()); } diff --git a/Telegram/SourceFiles/ui/boxes/auto_delete_settings.cpp b/Telegram/SourceFiles/ui/boxes/auto_delete_settings.cpp index df18993e0c..9cd9975ef2 100644 --- a/Telegram/SourceFiles/ui/boxes/auto_delete_settings.cpp +++ b/Telegram/SourceFiles/ui/boxes/auto_delete_settings.cpp @@ -204,15 +204,18 @@ void AutoDeleteSettingsBox( //u"5 seconds"_q, AssertIsDebug() tr::lng_manage_messages_ttl_after1(tr::now), tr::lng_manage_messages_ttl_after2(tr::now), + tr::lng_manage_messages_ttl_after3(tr::now), }; const auto periodToIndex = [&](TimeId period) { return !period ? 0 //: (period == 5) AssertIsDebug() //? 1 AssertIsDebug() - : (period < 3 * 86400) + : (period < 2 * 86400) ? 1 - : 2; + : (period < 8 * 86400) + ? 2 + : 3; }; const auto indexToPeriod = [&](int index) { return !index @@ -221,7 +224,9 @@ void AutoDeleteSettingsBox( //? 5 AssertIsDebug() : (index == 1) ? 86400 - : 7 * 86400; + : (index == 2) + ? 7 * 86400 + : 31 * 86400; }; const auto sliderCallback = [=](int index) { state->period = indexToPeriod(index); diff --git a/Telegram/SourceFiles/ui/chat/chat.style b/Telegram/SourceFiles/ui/chat/chat.style index 0086dbd8ae..6dc263fa63 100644 --- a/Telegram/SourceFiles/ui/chat/chat.style +++ b/Telegram/SourceFiles/ui/chat/chat.style @@ -311,6 +311,8 @@ historyMessagesTTL: IconButton(historyAttach) { } historyMessagesTTL2Icon: icon {{ "chat/input_autodelete_7d", historyComposeIconFg }}; historyMessagesTTL2IconOver: icon {{ "chat/input_autodelete_7d", historyComposeIconFgOver }}; +historyMessagesTTL3Icon: icon {{ "chat/input_autodelete_30d", historyComposeIconFg }}; +historyMessagesTTL3IconOver: icon {{ "chat/input_autodelete_30d", historyComposeIconFgOver }}; historyAttachEmojiFgActive: windowActiveTextFg; historyAttachEmojiActive: icon {{ "chat/input_smile_face", historyAttachEmojiFgActive }}; historyAttachEmojiTooltipDelta: 4px;