2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 08:55:59 +00:00

version 0.7.21.dev prepared - replies, mentions

This commit is contained in:
John Preston
2015-03-19 12:18:19 +03:00
parent 39acdd8725
commit 1f7e39e184
45 changed files with 5860 additions and 3676 deletions

View File

@@ -484,6 +484,8 @@ void Window::clearPasscode() {
_passcode = 0;
if (intro) {
intro->animShow(bg, true);
} else if (settings) {
settings->animShow(bg, true);
} else {
main->animShow(bg, true);
}
@@ -1204,16 +1206,33 @@ void Window::quit() {
notifyClearFast();
}
void Window::notifySchedule(History *history, MsgId msgId) {
void Window::notifySchedule(History *history, HistoryItem *item) {
if (App::quiting() || !history->currentNotification() || !main) return;
UserData *notifyByFrom = (history->peer->chat && item->notifyByFrom()) ? item->from() : 0;
bool haveSetting = (history->peer->notify != UnknownNotifySettings);
if (haveSetting) {
if (history->peer->notify != EmptyNotifySettings && history->peer->notify->mute > unixtime()) {
history->clearNotifications();
return;
if (notifyByFrom) {
haveSetting = (item->from()->notify != UnknownNotifySettings);
if (haveSetting) {
if (notifyByFrom->notify != EmptyNotifySettings && notifyByFrom->notify->mute > unixtime()) {
history->popNotification(item);
return;
}
} else {
App::wnd()->getNotifySetting(MTP_inputNotifyPeer(notifyByFrom->input));
}
} else {
history->popNotification(item);
return;
}
}
} else {
if (notifyByFrom && notifyByFrom->notify == UnknownNotifySettings) {
App::wnd()->getNotifySetting(MTP_inputNotifyPeer(notifyByFrom->input), 10);
}
App::wnd()->getNotifySetting(MTP_inputNotifyPeer(history->peer->input));
}
@@ -1228,19 +1247,19 @@ void Window::notifySchedule(History *history, MsgId msgId) {
}
uint64 when = getms(true) + delay;
notifyWhenAlerts[history].insert(when, NullType());
notifyWhenAlerts[history].insert(when, notifyByFrom);
if (cDesktopNotify() && !psSkipDesktopNotify()) {
NotifyWhenMaps::iterator i = notifyWhenMaps.find(history);
if (i == notifyWhenMaps.end()) {
i = notifyWhenMaps.insert(history, NotifyWhenMap());
}
if (i.value().constFind(msgId) == i.value().cend()) {
i.value().insert(msgId, when);
if (i.value().constFind(item->id) == i.value().cend()) {
i.value().insert(item->id, when);
}
NotifyWaiters *addTo = haveSetting ? &notifyWaiters : &notifySettingWaiters;
NotifyWaiters::const_iterator it = addTo->constFind(history);
if (it == addTo->cend() || it->when > when) {
addTo->insert(history, NotifyWaiter(msgId, when));
addTo->insert(history, NotifyWaiter(item->id, when, notifyByFrom));
}
}
if (haveSetting) {
@@ -1300,6 +1319,13 @@ void Window::notifySettingGot() {
} else {
if (history->peer->notify == EmptyNotifySettings || history->peer->notify->mute <= t) {
notifyWaiters.insert(i.key(), i.value());
} else if (UserData *from = i.value().notifyByFrom) {
if (from->notify == UnknownNotifySettings) {
++i;
continue;
} else if (from->notify == EmptyNotifySettings || from->notify->mute <= t) {
notifyWaiters.insert(i.key(), i.value());
}
}
i = notifySettingWaiters.erase(i);
}
@@ -1323,11 +1349,14 @@ void Window::notifyShowNext(NotifyWindow *remove) {
uint64 ms = getms(true), nextAlert = 0;
bool alert = false;
int32 now = unixtime();
for (NotifyWhenAlerts::iterator i = notifyWhenAlerts.begin(); i != notifyWhenAlerts.end();) {
while (!i.value().isEmpty() && i.value().begin().key() <= ms) {
NotifySettingsPtr n = i.key()->peer->notify, f = i.value().begin().value() ? i.value().begin().value()->notify : UnknownNotifySettings;
i.value().erase(i.value().begin());
NotifySettingsPtr n = i.key()->peer->notify;
if (n == EmptyNotifySettings || (n != UnknownNotifySettings && n->mute <= unixtime())) {
if (n == EmptyNotifySettings || (n != UnknownNotifySettings && n->mute <= now)) {
alert = true;
} else if (f == EmptyNotifySettings || (f != UnknownNotifySettings && f->mute <= now)) { // notify by from()
alert = true;
}
}