mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Remove some calls to Auth().
This commit is contained in:
@@ -61,7 +61,9 @@ void System::createManager() {
|
||||
}
|
||||
}
|
||||
|
||||
void System::schedule(History *history, HistoryItem *item) {
|
||||
void System::schedule(
|
||||
not_null<History*> history,
|
||||
not_null<HistoryItem*> item) {
|
||||
if (App::quitting()
|
||||
|| !history->currentNotification()
|
||||
|| !AuthSession::Exists()) return;
|
||||
@@ -75,16 +77,16 @@ void System::schedule(History *history, HistoryItem *item) {
|
||||
return;
|
||||
}
|
||||
|
||||
Auth().data().requestNotifySettings(history->peer);
|
||||
history->owner().requestNotifySettings(history->peer);
|
||||
if (notifyBy) {
|
||||
Auth().data().requestNotifySettings(notifyBy);
|
||||
history->owner().requestNotifySettings(notifyBy);
|
||||
}
|
||||
auto haveSetting = !Auth().data().notifyMuteUnknown(history->peer);
|
||||
if (haveSetting && Auth().data().notifyIsMuted(history->peer)) {
|
||||
auto haveSetting = !history->owner().notifyMuteUnknown(history->peer);
|
||||
if (haveSetting && history->owner().notifyIsMuted(history->peer)) {
|
||||
if (notifyBy) {
|
||||
haveSetting = !Auth().data().notifyMuteUnknown(notifyBy);
|
||||
haveSetting = !history->owner().notifyMuteUnknown(notifyBy);
|
||||
if (haveSetting) {
|
||||
if (Auth().data().notifyIsMuted(notifyBy)) {
|
||||
if (history->owner().notifyIsMuted(notifyBy)) {
|
||||
history->popNotification(item);
|
||||
return;
|
||||
}
|
||||
@@ -174,12 +176,12 @@ void System::checkDelayed() {
|
||||
const auto peer = history->peer;
|
||||
auto loaded = false;
|
||||
auto muted = false;
|
||||
if (!Auth().data().notifyMuteUnknown(peer)) {
|
||||
if (!Auth().data().notifyIsMuted(peer)) {
|
||||
if (!peer->owner().notifyMuteUnknown(peer)) {
|
||||
if (!peer->owner().notifyIsMuted(peer)) {
|
||||
loaded = true;
|
||||
} else if (const auto from = i.value().notifyBy) {
|
||||
if (!Auth().data().notifyMuteUnknown(from)) {
|
||||
if (!Auth().data().notifyIsMuted(from)) {
|
||||
if (!peer->owner().notifyMuteUnknown(from)) {
|
||||
if (!peer->owner().notifyIsMuted(from)) {
|
||||
loaded = true;
|
||||
} else {
|
||||
loaded = muted = true;
|
||||
@@ -193,7 +195,7 @@ void System::checkDelayed() {
|
||||
const auto fullId = FullMsgId(
|
||||
history->channelId(),
|
||||
i.value().msg);
|
||||
if (const auto item = Auth().data().message(fullId)) {
|
||||
if (const auto item = peer->owner().message(fullId)) {
|
||||
if (!item->notificationReady()) {
|
||||
loaded = false;
|
||||
}
|
||||
@@ -215,7 +217,7 @@ void System::checkDelayed() {
|
||||
}
|
||||
|
||||
void System::showGrouped() {
|
||||
if (const auto lastItem = Auth().data().message(_lastHistoryItemId)) {
|
||||
if (const auto lastItem = session().data().message(_lastHistoryItemId)) {
|
||||
_waitForAllGroupedTimer.cancel();
|
||||
_manager->showNotification(lastItem, _lastForwardedCount);
|
||||
_lastForwardedCount = 0;
|
||||
@@ -230,7 +232,9 @@ void System::showNext() {
|
||||
if (!_lastHistoryItemId || !item) {
|
||||
return false;
|
||||
}
|
||||
if (const auto lastItem = Auth().data().message(_lastHistoryItemId)) {
|
||||
const auto lastItem = item->history()->owner().message(
|
||||
_lastHistoryItemId);
|
||||
if (lastItem) {
|
||||
return (lastItem->groupId() == item->groupId() || lastItem->author() == item->author());
|
||||
}
|
||||
return false;
|
||||
@@ -242,14 +246,14 @@ void System::showNext() {
|
||||
for (auto i = _whenAlerts.begin(); i != _whenAlerts.end();) {
|
||||
while (!i.value().isEmpty() && i.value().begin().key() <= ms) {
|
||||
const auto peer = i.key()->peer;
|
||||
const auto peerUnknown = Auth().data().notifyMuteUnknown(peer);
|
||||
const auto peerUnknown = peer->owner().notifyMuteUnknown(peer);
|
||||
const auto peerAlert = !peerUnknown
|
||||
&& !Auth().data().notifyIsMuted(peer);
|
||||
&& !peer->owner().notifyIsMuted(peer);
|
||||
const auto from = i.value().begin().value();
|
||||
const auto fromUnknown = (!from
|
||||
|| Auth().data().notifyMuteUnknown(from));
|
||||
|| peer->owner().notifyMuteUnknown(from));
|
||||
const auto fromAlert = !fromUnknown
|
||||
&& !Auth().data().notifyIsMuted(from);
|
||||
&& !peer->owner().notifyIsMuted(from);
|
||||
if (peerAlert || fromAlert) {
|
||||
alert = true;
|
||||
}
|
||||
@@ -432,7 +436,7 @@ void System::ensureSoundCreated() {
|
||||
|
||||
_soundTrack = Media::Audio::Current().createTrack();
|
||||
_soundTrack->fillFromFile(
|
||||
Auth().settings().getSoundPath(qsl("msg_incoming")));
|
||||
session().settings().getSoundPath(qsl("msg_incoming")));
|
||||
}
|
||||
|
||||
void System::updateAll() {
|
||||
@@ -458,7 +462,7 @@ Manager::DisplayOptions Manager::getNotificationOptions(HistoryItem *item) {
|
||||
void Manager::notificationActivated(PeerId peerId, MsgId msgId) {
|
||||
onBeforeNotificationActivated(peerId, msgId);
|
||||
if (auto window = App::wnd()) {
|
||||
auto history = Auth().data().history(peerId);
|
||||
auto history = system()->session().data().history(peerId);
|
||||
window->showFromTray();
|
||||
window->reActivateWindow();
|
||||
if (Core::App().locked()) {
|
||||
@@ -480,7 +484,7 @@ void Manager::openNotificationMessage(
|
||||
|| !IsServerMsgId(messageId)) {
|
||||
return false;
|
||||
}
|
||||
const auto item = Auth().data().message(history->channelId(), messageId);
|
||||
const auto item = history->owner().message(history->channelId(), messageId);
|
||||
if (!item || !item->mentionsMe()) {
|
||||
return false;
|
||||
}
|
||||
@@ -509,7 +513,7 @@ void Manager::notificationReplied(
|
||||
const TextWithTags &reply) {
|
||||
if (!peerId) return;
|
||||
|
||||
const auto history = Auth().data().history(peerId);
|
||||
const auto history = system()->session().data().history(peerId);
|
||||
|
||||
auto message = ApiWrap::MessageToSend(history);
|
||||
message.textWithTags = reply;
|
||||
|
Reference in New Issue
Block a user