mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Restricted removing of poll answer by time from app config.
This commit is contained in:
@@ -81,6 +81,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/qt/qt_key_modifiers.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "base/call_delayed.h"
|
||||
#include "main/main_app_config.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_session_settings.h"
|
||||
#include "mainwidget.h"
|
||||
@@ -3003,7 +3004,24 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||
TextUtilities::SetClipboardText(text);
|
||||
},
|
||||
&st::menuIconCopy);
|
||||
if (poll->creator() && a->addedDate) {
|
||||
const auto canDelete = [&] {
|
||||
if (!a->addedDate) {
|
||||
return false;
|
||||
}
|
||||
if (poll->creator()) {
|
||||
return true;
|
||||
}
|
||||
if (a->addedBy
|
||||
&& a->addedBy->isSelf()) {
|
||||
const auto period = poll->session()
|
||||
.appConfig()
|
||||
.pollAnswerDeletePeriod();
|
||||
return (base::unixtime::now() - a->addedDate)
|
||||
< period;
|
||||
}
|
||||
return false;
|
||||
}();
|
||||
if (canDelete) {
|
||||
const auto itemId = item->fullId();
|
||||
const auto option = pollOptionLink;
|
||||
_menu->addAction(
|
||||
|
||||
@@ -87,6 +87,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "window/window_session_controller.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "core/application.h"
|
||||
#include "main/main_app_config.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_session_settings.h"
|
||||
#include "spellcheck/spellcheck_types.h"
|
||||
@@ -1323,7 +1324,24 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
||||
TextUtilities::SetClipboardText(text);
|
||||
},
|
||||
&st::menuIconCopy);
|
||||
if (poll->creator() && a->addedDate) {
|
||||
const auto canDelete = [&] {
|
||||
if (!a->addedDate) {
|
||||
return false;
|
||||
}
|
||||
if (poll->creator()) {
|
||||
return true;
|
||||
}
|
||||
if (a->addedBy
|
||||
&& a->addedBy->isSelf()) {
|
||||
const auto period = poll->session()
|
||||
.appConfig()
|
||||
.pollAnswerDeletePeriod();
|
||||
return (base::unixtime::now() - a->addedDate)
|
||||
< period;
|
||||
}
|
||||
return false;
|
||||
}();
|
||||
if (canDelete) {
|
||||
const auto itemId = item->fullId();
|
||||
result->addAction(
|
||||
tr::lng_context_delete_poll_option(tr::now),
|
||||
|
||||
@@ -208,6 +208,10 @@ int AppConfig::pollOptionsLimit() const {
|
||||
return get<int>(u"poll_answers_max"_q, 12);
|
||||
}
|
||||
|
||||
int AppConfig::pollAnswerDeletePeriod() const {
|
||||
return get<int>(u"poll_answer_delete_period"_q, 300);
|
||||
}
|
||||
|
||||
int AppConfig::todoListItemsLimit() const {
|
||||
return get<int>(
|
||||
u"todo_items_max"_q,
|
||||
|
||||
@@ -105,6 +105,7 @@ public:
|
||||
[[nodiscard]] int giftResaleNanoTonThousandths() const;
|
||||
|
||||
[[nodiscard]] int pollOptionsLimit() const;
|
||||
[[nodiscard]] int pollAnswerDeletePeriod() const;
|
||||
[[nodiscard]] int todoListItemsLimit() const;
|
||||
[[nodiscard]] int todoListTitleLimit() const;
|
||||
[[nodiscard]] int todoListItemTextLimit() const;
|
||||
|
||||
Reference in New Issue
Block a user