2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 22:16:14 +00:00

stickers emoji tab done, local cache for stickers, recent stickers and voice messages

This commit is contained in:
John Preston
2015-01-02 17:55:24 +03:00
parent 59381b8ad2
commit 091bba0fc5
41 changed files with 5178 additions and 3470 deletions

View File

@@ -26,6 +26,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
#include "mainwidget.h"
#include "boxes/confirmbox.h"
#include "localstorage.h"
#include "audio.h"
TopBarWidget::TopBarWidget(MainWidget *w) : TWidget(w),
@@ -2121,6 +2123,8 @@ void MainWidget::start(const MTPUser &user) {
}
_started = true;
App::wnd()->sendServiceHistoryRequest();
Local::readRecentStickers();
history.updateRecentStickers();
}
bool MainWidget::started() {
@@ -2267,6 +2271,45 @@ void MainWidget::updateNotifySetting(PeerData *peer, bool enabled) {
updateNotifySettingTimer.start(NotifySettingSaveTimeout);
}
void MainWidget::incrementSticker(DocumentData *sticker) {
RecentStickerPack recent(cRecentStickers());
RecentStickerPack::iterator i = recent.begin(), e = recent.end();
for (; i != e; ++i) {
if (i->first == sticker) {
if (i->second > 0) {
++i->second;
} else {
--i->second;
}
if (qAbs(i->second) > 0x4000) {
for (RecentStickerPack::iterator j = recent.begin(); j != e; ++j) {
if (qAbs(j->second) > 1) {
j->second /= 2;
} else if (j->second > 0) {
j->second = 1;
} else {
j->second = -1;
}
}
}
for (; i != recent.begin(); --i) {
if (qAbs((i - 1)->second) > qAbs(i->second)) {
break;
}
qSwap(*i, *(i - 1));
}
break;
}
}
if (i == e) {
recent.push_front(qMakePair(sticker, -(recent.isEmpty() ? 1 : qAbs(recent.front().second))));
}
cSetRecentStickers(recent);
Local::writeRecentStickers();
history.updateRecentStickers();
}
void MainWidget::activate() {
if (!profile && !overview) {
if (hider) {