2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Use crl::time/now instead of TimeMs/getms.

This commit is contained in:
John Preston
2019-02-19 10:57:53 +04:00
parent d208236994
commit fe618bd652
310 changed files with 1133 additions and 1141 deletions

View File

@@ -102,16 +102,16 @@ namespace {
constexpr auto kChannelGetDifferenceLimit = 100;
// 1s wait after show channel history before sending getChannelDifference.
constexpr auto kWaitForChannelGetDifference = TimeMs(1000);
constexpr auto kWaitForChannelGetDifference = crl::time(1000);
// If nothing is received in 1 min we ping.
constexpr auto kNoUpdatesTimeout = 60 * 1000;
// If nothing is received in 1 min when was a sleepmode we ping.
constexpr auto kNoUpdatesAfterSleepTimeout = 60 * TimeMs(1000);
constexpr auto kNoUpdatesAfterSleepTimeout = 60 * crl::time(1000);
// Send channel views each second.
constexpr auto kSendViewsTimeout = TimeMs(1000);
constexpr auto kSendViewsTimeout = crl::time(1000);
// Cache background scaled image after 3s.
constexpr auto kCacheBackgroundTimeout = 3000;
@@ -1110,7 +1110,7 @@ Dialogs::IndexedList *MainWidget::contactsNoDialogsList() {
return _dialogs->contactsNoDialogsList();
}
TimeMs MainWidget::highlightStartTime(not_null<const HistoryItem*> item) const {
crl::time MainWidget::highlightStartTime(not_null<const HistoryItem*> item) const {
return _history->highlightStartTime(item);
}
@@ -1164,7 +1164,7 @@ void MainWidget::itemEdited(not_null<HistoryItem*> item) {
}
void MainWidget::checkLastUpdate(bool afterSleep) {
auto n = getms(true);
auto n = crl::now();
if (_lastUpdateTime && n > _lastUpdateTime + (afterSleep ? kNoUpdatesAfterSleepTimeout : kNoUpdatesTimeout)) {
_lastUpdateTime = n;
MTP::ping();
@@ -2483,7 +2483,7 @@ void MainWidget::paintEvent(QPaintEvent *e) {
}
Painter p(this);
auto progress = _a_show.current(getms(), 1.);
auto progress = _a_show.current(crl::now(), 1.);
if (_a_show.animating()) {
auto coordUnder = _showBack ? anim::interpolate(-st::slideShift, 0, progress) : anim::interpolate(0, -st::slideShift, progress);
auto coordOver = _showBack ? anim::interpolate(0, width(), progress) : anim::interpolate(width(), 0, progress);
@@ -3143,7 +3143,7 @@ void MainWidget::gotChannelDifference(
getChannelDifference(channel);
} else if (_controller->activeChatCurrent().peer() == channel) {
channel->ptsWaitingForShortPoll(timeout
? (timeout * TimeMs(1000))
? (timeout * crl::time(1000))
: kWaitForChannelGetDifference);
}
}
@@ -3172,7 +3172,7 @@ void MainWidget::gotState(const MTPupdates_State &state) {
auto &d = state.c_updates_state();
updSetState(d.vpts.v, d.vdate.v, d.vqts.v, d.vseq.v);
_lastUpdateTime = getms(true);
_lastUpdateTime = crl::now();
_noUpdatesTimer.callOnce(kNoUpdatesTimeout);
_ptsWaiter.setRequesting(false);
@@ -3188,7 +3188,7 @@ void MainWidget::gotDifference(const MTPupdates_Difference &difference) {
auto &d = difference.c_updates_differenceEmpty();
updSetState(_ptsWaiter.current(), d.vdate.v, updQts, d.vseq.v);
_lastUpdateTime = getms(true);
_lastUpdateTime = crl::now();
_noUpdatesTimer.callOnce(kNoUpdatesTimeout);
_ptsWaiter.setRequesting(false);
@@ -3218,7 +3218,7 @@ void MainWidget::gotDifference(const MTPupdates_Difference &difference) {
};
}
bool MainWidget::getDifferenceTimeChanged(ChannelData *channel, int32 ms, ChannelGetDifferenceTime &channelCurTime, TimeMs &curTime) {
bool MainWidget::getDifferenceTimeChanged(ChannelData *channel, int32 ms, ChannelGetDifferenceTime &channelCurTime, crl::time &curTime) {
if (channel) {
if (ms <= 0) {
ChannelGetDifferenceTime::iterator i = channelCurTime.find(channel);
@@ -3228,7 +3228,7 @@ bool MainWidget::getDifferenceTimeChanged(ChannelData *channel, int32 ms, Channe
return false;
}
} else {
auto when = getms(true) + ms;
auto when = crl::now() + ms;
ChannelGetDifferenceTime::iterator i = channelCurTime.find(channel);
if (i != channelCurTime.cend()) {
if (i.value() > when) {
@@ -3248,7 +3248,7 @@ bool MainWidget::getDifferenceTimeChanged(ChannelData *channel, int32 ms, Channe
return false;
}
} else {
auto when = getms(true) + ms;
auto when = crl::now() + ms;
if (!curTime || curTime > when) {
curTime = when;
} else {
@@ -3315,7 +3315,7 @@ bool MainWidget::failDifference(const RPCError &error) {
}
void MainWidget::getDifferenceByPts() {
auto now = getms(true), wait = 0LL;
auto now = crl::now(), wait = 0LL;
if (_getDifferenceTimeByPts) {
if (_getDifferenceTimeByPts > now) {
wait = _getDifferenceTimeByPts - now;
@@ -3340,7 +3340,7 @@ void MainWidget::getDifferenceByPts() {
}
void MainWidget::getDifferenceAfterFail() {
auto now = getms(true), wait = 0LL;
auto now = crl::now(), wait = 0LL;
if (_getDifferenceTimeAfterFail) {
if (_getDifferenceTimeAfterFail > now) {
wait = _getDifferenceTimeAfterFail - now;
@@ -3746,7 +3746,7 @@ bool MainWidget::lastWasOnline() const {
return _lastWasOnline;
}
TimeMs MainWidget::lastSetOnline() const {
crl::time MainWidget::lastSetOnline() const {
return _lastSetOnline;
}
@@ -3778,7 +3778,7 @@ void MainWidget::updateOnline(bool gotOtherOffline) {
updateIn = qMin(updateIn, int(Global::OfflineIdleTimeout() - idle));
}
}
auto ms = getms(true);
auto ms = crl::now();
if (isOnline != _lastWasOnline
|| (isOnline && _lastSetOnline + Global::OnlineUpdatePeriod() <= ms)
|| (isOnline && gotOtherOffline)) {
@@ -3912,7 +3912,7 @@ void MainWidget::updateReceived(const mtpPrime *from, const mtpPrime *end) {
MTPUpdates updates;
updates.read(from, end);
_lastUpdateTime = getms(true);
_lastUpdateTime = crl::now();
_noUpdatesTimer.callOnce(kNoUpdatesTimeout);
if (!requestingDifference()
|| HasForceLogoutNotification(updates)) {