2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +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

@@ -101,7 +101,7 @@ constexpr auto kSkipRepaintWhileScrollMs = 100;
constexpr auto kShowMembersDropdownTimeoutMs = 300;
constexpr auto kDisplayEditTimeWarningMs = 300 * 1000;
constexpr auto kFullDayInMs = 86400 * 1000;
constexpr auto kCancelTypingActionTimeout = TimeMs(5000);
constexpr auto kCancelTypingActionTimeout = crl::time(5000);
constexpr auto kSaveDraftTimeout = 1000;
constexpr auto kSaveDraftAnywayTimeout = 5000;
constexpr auto kSaveCloudDraftIdleTimeout = 14000;
@@ -603,7 +603,7 @@ void HistoryWidget::supportShareContact(Support::Contact contact) {
}
void HistoryWidget::scrollToCurrentVoiceMessage(FullMsgId fromId, FullMsgId toId) {
if (getms() <= _lastUserScrolled + kScrollToVoiceAfterScrolledMs) {
if (crl::now() <= _lastUserScrolled + kScrollToVoiceAfterScrolledMs) {
return;
}
if (!_list) {
@@ -727,7 +727,7 @@ void HistoryWidget::enqueueMessageHighlight(
}
void HistoryWidget::highlightMessage(MsgId universalMessageId) {
_highlightStart = getms();
_highlightStart = crl::now();
_highlightedMessageId = universalMessageId;
_highlightTimer.callEach(AnimationTimerDelta);
}
@@ -760,14 +760,14 @@ void HistoryWidget::updateHighlightedMessage() {
return stopMessageHighlight();
}
auto duration = st::activeFadeInDuration + st::activeFadeOutDuration;
if (getms() - _highlightStart > duration) {
if (crl::now() - _highlightStart > duration) {
return stopMessageHighlight();
}
Auth().data().requestViewRepaint(view);
}
TimeMs HistoryWidget::highlightStartTime(not_null<const HistoryItem*> item) const {
crl::time HistoryWidget::highlightStartTime(not_null<const HistoryItem*> item) const {
auto isHighlighted = [this](not_null<const HistoryItem*> item) {
if (item->id == _highlightedMessageId) {
return (item->history() == _history);
@@ -1027,7 +1027,7 @@ void HistoryWidget::onDraftSaveDelayed() {
void HistoryWidget::onDraftSave(bool delayed) {
if (!_peer) return;
if (delayed) {
auto ms = getms();
auto ms = crl::now();
if (!_saveDraftStart) {
_saveDraftStart = ms;
return _saveDraftTimer.start(kSaveDraftTimeout);
@@ -2564,7 +2564,7 @@ void HistoryWidget::onScroll() {
preloadHistoryIfNeeded();
visibleAreaUpdated();
if (!_synteticScrollEvent) {
_lastUserScrolled = getms();
_lastUserScrolled = crl::now();
}
}
@@ -2616,7 +2616,7 @@ void HistoryWidget::preloadHistoryIfNeeded() {
auto scrollTop = _scroll->scrollTop();
if (scrollTop != _lastScrollTop) {
_lastScrolled = getms();
_lastScrolled = crl::now();
_lastScrollTop = scrollTop;
}
}
@@ -2827,7 +2827,7 @@ void HistoryWidget::send(Qt::KeyboardModifiers modifiers) {
clearFieldText();
_saveDraftText = true;
_saveDraftStart = getms();
_saveDraftStart = crl::now();
onDraftSave();
hideSelectorControlsAnimated();
@@ -4525,7 +4525,7 @@ QPixmap HistoryWidget::grabForShowAnimation(
}
bool HistoryWidget::skipItemRepaint() {
auto ms = getms();
auto ms = crl::now();
if (_lastScrolled + kSkipRepaintWhileScrollMs <= ms) {
return false;
}
@@ -4537,7 +4537,7 @@ bool HistoryWidget::skipItemRepaint() {
void HistoryWidget::onUpdateHistoryItems() {
if (!_list) return;
auto ms = getms();
auto ms = crl::now();
if (_lastScrolled + kSkipRepaintWhileScrollMs <= ms) {
_list->update();
} else {
@@ -5244,7 +5244,7 @@ void HistoryWidget::sendInlineResult(
clearFieldText();
_saveDraftText = true;
_saveDraftStart = getms();
_saveDraftStart = crl::now();
onDraftSave();
auto &bots = cRefRecentInlineBots();
@@ -5392,7 +5392,7 @@ bool HistoryWidget::sendExistingDocument(
if (_fieldAutocomplete->stickersShown()) {
clearFieldText();
//_saveDraftText = true;
//_saveDraftStart = getms();
//_saveDraftStart = crl::now();
//onDraftSave();
onCloudDraftSave(); // won't be needed if SendInlineBotResult will clear the cloud draft
}
@@ -5568,7 +5568,7 @@ void HistoryWidget::replyToMessage(not_null<HistoryItem*> item) {
}
_saveDraftText = true;
_saveDraftStart = getms();
_saveDraftStart = crl::now();
onDraftSave();
_field->setFocus();
@@ -5638,7 +5638,7 @@ void HistoryWidget::editMessage(not_null<HistoryItem*> item) {
updateField();
_saveDraftText = true;
_saveDraftStart = getms();
_saveDraftStart = crl::now();
onDraftSave();
_field->setFocus();
@@ -5750,7 +5750,7 @@ bool HistoryWidget::cancelReply(bool lastKeyboardUsed) {
}
if (wasReply) {
_saveDraftText = true;
_saveDraftStart = getms();
_saveDraftStart = crl::now();
onDraftSave();
}
if (!_editMsgId
@@ -5791,7 +5791,7 @@ void HistoryWidget::cancelEdit() {
}
_saveDraftText = true;
_saveDraftStart = getms();
_saveDraftStart = crl::now();
onDraftSave();
mouseMoveEvent(nullptr);
@@ -5823,7 +5823,7 @@ void HistoryWidget::onFieldBarCancel() {
previewCancel();
_saveDraftText = true;
_saveDraftStart = getms();
_saveDraftStart = crl::now();
onDraftSave();
} else if (_editMsgId) {
cancelEdit();
@@ -5940,7 +5940,7 @@ void HistoryWidget::updatePreview() {
Ui::DialogTextOptions());
const auto timeout = (_previewData->pendingTill - unixtime());
_previewTimer.callOnce(std::max(timeout, 0) * TimeMs(1000));
_previewTimer.callOnce(std::max(timeout, 0) * crl::time(1000));
} else {
QString title, desc;
if (_previewData->siteName.isEmpty()) {
@@ -6497,7 +6497,7 @@ void HistoryWidget::drawPinnedBar(Painter &p) {
}
}
bool HistoryWidget::paintShowAnimationFrame(TimeMs ms) {
bool HistoryWidget::paintShowAnimationFrame(crl::time ms) {
auto progress = _a_show.current(ms, 1.);
if (!_a_show.animating()) {
return false;
@@ -6523,7 +6523,7 @@ bool HistoryWidget::paintShowAnimationFrame(TimeMs ms) {
}
void HistoryWidget::paintEvent(QPaintEvent *e) {
auto ms = getms();
auto ms = crl::now();
_historyDownShown.step(ms);
_unreadMentionsShown.step(ms);
if (paintShowAnimationFrame(ms)) {