mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Confirm enable sharing request sending.
This commit is contained in:
@@ -1909,6 +1909,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_disable_sharing_button" = "Disable Sharing";
|
||||
"lng_disable_sharing_toast" = "Sharing disabled for this chat.";
|
||||
"lng_enable_sharing_toast" = "Sharing enabled for this chat.";
|
||||
"lng_enable_sharing_request_title" = "Enable Sharing";
|
||||
"lng_enable_sharing_request_text" = "You need **{name}'s** approval to enable sharing. Send a request?";
|
||||
"lng_enable_sharing_request_button" = "Send Request";
|
||||
|
||||
"lng_action_no_forwards_you_disabled" = "You disabled sharing in this chat.";
|
||||
"lng_action_no_forwards_you_enabled" = "You enabled sharing in this chat.";
|
||||
|
||||
@@ -1309,6 +1309,21 @@ void Session::maybeStopWatchForOffline(not_null<UserData*> user) {
|
||||
}
|
||||
}
|
||||
|
||||
void Session::recordSharingDisabledTime(not_null<UserData*> user) {
|
||||
_sharingDisabledTimes[user] = base::unixtime::now();
|
||||
}
|
||||
|
||||
bool Session::sharingRecentlyDisabledByMe(
|
||||
not_null<UserData*> user) const {
|
||||
const auto i = _sharingDisabledTimes.find(user);
|
||||
return (i != end(_sharingDisabledTimes))
|
||||
&& (base::unixtime::now() - i->second < 86400);
|
||||
}
|
||||
|
||||
void Session::clearSharingDisabledTime(not_null<UserData*> user) {
|
||||
_sharingDisabledTimes.remove(user);
|
||||
}
|
||||
|
||||
void Session::checkLocalUsersWentOffline() {
|
||||
_watchForOfflineTimer.cancel();
|
||||
|
||||
|
||||
@@ -286,6 +286,11 @@ public:
|
||||
void watchForOffline(not_null<UserData*> user, TimeId now = 0);
|
||||
void maybeStopWatchForOffline(not_null<UserData*> user);
|
||||
|
||||
void recordSharingDisabledTime(not_null<UserData*> user);
|
||||
[[nodiscard]] bool sharingRecentlyDisabledByMe(
|
||||
not_null<UserData*> user) const;
|
||||
void clearSharingDisabledTime(not_null<UserData*> user);
|
||||
|
||||
[[nodiscard]] auto invitedToCallUsers(CallId callId) const
|
||||
-> const base::flat_map<not_null<UserData*>, bool> &;
|
||||
void registerInvitedToCallUser(
|
||||
@@ -1285,6 +1290,7 @@ private:
|
||||
|
||||
base::flat_map<not_null<UserData*>, TimeId> _watchingForOffline;
|
||||
base::Timer _watchForOfflineTimer;
|
||||
base::flat_map<not_null<UserData*>, TimeId> _sharingDisabledTimes;
|
||||
|
||||
base::flat_map<not_null<PeerData*>, MTP::DcId> _peerStatsDcIds;
|
||||
|
||||
|
||||
@@ -656,6 +656,9 @@ void UserData::setNoForwardsFlags(bool myEnabled, bool peerEnabled) {
|
||||
setFlags((flags() & ~mask)
|
||||
| (myEnabled ? Flag::NoForwardsMyEnabled : Flag())
|
||||
| (peerEnabled ? Flag::NoForwardsPeerEnabled : Flag()));
|
||||
if (!myEnabled && !peerEnabled) {
|
||||
owner().clearSharingDisabledTime(this);
|
||||
}
|
||||
}
|
||||
|
||||
int UserData::starsPerMessage() const {
|
||||
|
||||
@@ -1448,6 +1448,11 @@ void Filler::addToggleNoForwards() {
|
||||
MTPint()
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
peer->session().api().applyUpdates(result);
|
||||
if (enabled) {
|
||||
if (const auto user = peer->asUser()) {
|
||||
peer->session().data().recordSharingDisabledTime(user);
|
||||
}
|
||||
}
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
if (error.type() != u"CHAT_NOT_MODIFIED"_q) {
|
||||
controller->showToast(error.type());
|
||||
@@ -1461,7 +1466,27 @@ void Filler::addToggleNoForwards() {
|
||||
if (controller->showFrozenError()) {
|
||||
return;
|
||||
} else if (disabledNow) {
|
||||
const auto willBeRequest = true
|
||||
&& (user->flags() & UserDataFlag::NoForwardsPeerEnabled)
|
||||
&& !peer->session().data().sharingRecentlyDisabledByMe(user);
|
||||
if (willBeRequest) {
|
||||
controller->show(Ui::MakeConfirmBox({
|
||||
.text = tr::lng_enable_sharing_request_text(
|
||||
tr::now,
|
||||
lt_name,
|
||||
tr::marked(user->shortName()),
|
||||
tr::rich),
|
||||
.confirmed = [=](Fn<void()> close) {
|
||||
toggleNoForwards(false);
|
||||
controller->showPeerHistory(peer->id);
|
||||
close();
|
||||
},
|
||||
.confirmText = tr::lng_enable_sharing_request_button(),
|
||||
.title = tr::lng_enable_sharing_request_title(),
|
||||
}));
|
||||
} else {
|
||||
toggleNoForwards(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
auto &settings = peer->session().settings();
|
||||
|
||||
Reference in New Issue
Block a user