mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
upload: import Ayu initial
Co-authored-by: SharapaGorg <sharapov.savely@yandex.ru>
This commit is contained in:
@@ -57,6 +57,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "apiwrap.h"
|
||||
#include "ui/text/format_values.h" // Ui::FormatPhone
|
||||
|
||||
#include "ayu/ayu_settings.h"
|
||||
|
||||
namespace Api {
|
||||
namespace {
|
||||
|
||||
@@ -899,8 +901,17 @@ void Updates::updateOnline(crl::time lastNonIdleTime, bool gotOtherOffline) {
|
||||
Core::App().checkAutoLock(lastNonIdleTime);
|
||||
});
|
||||
|
||||
const auto &config = _session->serverConfig();
|
||||
bool isOnline = Core::App().hasActiveWindow(&session());
|
||||
// AyuGram sendOnlinePackets
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
const auto &config = _session->serverConfig();
|
||||
bool isOnlineOrig = Core::App().hasActiveWindow(&session());
|
||||
bool isOnline = settings->sendOnlinePackets && isOnlineOrig;
|
||||
|
||||
// AyuGram sendOfflinePacketAfterOnline
|
||||
if (settings->sendOfflinePacketAfterOnline && _lastWasOnline) {
|
||||
isOnline = false;
|
||||
}
|
||||
|
||||
int updateIn = config.onlineUpdatePeriod;
|
||||
Assert(updateIn >= 0);
|
||||
if (isOnline) {
|
||||
@@ -922,7 +933,7 @@ void Updates::updateOnline(crl::time lastNonIdleTime, bool gotOtherOffline) {
|
||||
|| (isOnline && gotOtherOffline)) {
|
||||
api().request(base::take(_onlineRequest)).cancel();
|
||||
|
||||
_lastWasOnline = isOnline;
|
||||
_lastWasOnline = isOnlineOrig;
|
||||
_lastSetOnline = ms;
|
||||
if (!Core::Quitting()) {
|
||||
_onlineRequest = api().request(MTPaccount_UpdateStatus(
|
||||
@@ -943,7 +954,7 @@ void Updates::updateOnline(crl::time lastNonIdleTime, bool gotOtherOffline) {
|
||||
session().changes().peerUpdated(
|
||||
self,
|
||||
Data::PeerUpdate::Flag::OnlineStatus);
|
||||
if (!isOnline) { // Went offline, so we need to save message draft to the cloud.
|
||||
if (!isOnlineOrig) { // Went offline, so we need to save message draft to the cloud.
|
||||
api().saveCurrentDraftToCloud();
|
||||
session().data().maybeStopWatchForOffline(self);
|
||||
}
|
||||
@@ -953,6 +964,22 @@ void Updates::updateOnline(crl::time lastNonIdleTime, bool gotOtherOffline) {
|
||||
updateIn = qMin(updateIn, int(_lastSetOnline + config.onlineUpdatePeriod - ms));
|
||||
Assert(updateIn >= 0);
|
||||
}
|
||||
|
||||
// AyuGram sendOfflinePacketAfterOnline
|
||||
if (settings->sendOfflinePacketAfterOnline) {
|
||||
session().api().requestFullPeer(session().user());
|
||||
if (session().user()->onlineTill > base::unixtime::now()) {
|
||||
DEBUG_LOG(("[AyuGram] User likely appeared online"));
|
||||
|
||||
_onlineRequest = api().request(MTPaccount_UpdateStatus(
|
||||
MTP_bool(true)
|
||||
)).send();
|
||||
}
|
||||
|
||||
DEBUG_LOG(("[AyuGram] Decreasing updateIn because of enabled features"));
|
||||
updateIn = 1250;
|
||||
}
|
||||
|
||||
_onlineTimer.callOnce(updateIn);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user