From 71e653db307e0cd68d621891a18ee80cc510cec2 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 18 Apr 2017 22:00:21 +0300 Subject: [PATCH] Fix non-available API usage in OS X 10.6-10.7 version. --- .../platform/mac/notifications_manager_mac.mm | 9 +++++++-- Telegram/SourceFiles/window/notifications_manager.cpp | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/platform/mac/notifications_manager_mac.mm b/Telegram/SourceFiles/platform/mac/notifications_manager_mac.mm index 5a8fed367..89741484b 100644 --- a/Telegram/SourceFiles/platform/mac/notifications_manager_mac.mm +++ b/Telegram/SourceFiles/platform/mac/notifications_manager_mac.mm @@ -43,8 +43,13 @@ void queryDoNotDisturbState() { } LastSettingsQueryMs = ms; - id userDefaultsValue = [[[NSUserDefaults alloc] initWithSuiteName:@"com.apple.notificationcenterui"] objectForKey:@"doNotDisturb"]; - DoNotDisturbEnabled = [userDefaultsValue boolValue]; + auto userDefaults = [NSUserDefaults alloc]; + if ([userDefaults respondsToSelector:@selector(initWithSuiteName:)]) { + id userDefaultsValue = [[[NSUserDefaults alloc] initWithSuiteName:@"com.apple.notificationcenterui_test"] objectForKey:@"doNotDisturb"]; + DoNotDisturbEnabled = ([userDefaultsValue boolValue] == YES); + } else { + DoNotDisturbEnabled = false; + } } using Manager = Platform::Notifications::Manager; diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index 5cf8e131a..ebbce19dd 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -60,7 +60,7 @@ void System::createManager() { void System::schedule(History *history, HistoryItem *item) { if (App::quitting() || !history->currentNotification() || !App::api()) return; - PeerData *notifyByFrom = (!history->peer->isUser() && item->mentionsMe()) ? item->from() : 0; + auto notifyByFrom = (!history->peer->isUser() && item->mentionsMe()) ? item->from() : nullptr; if (item->isSilent()) { history->popNotification(item);