no message

This commit is contained in:
overtake 2018-11-21 02:04:16 +04:00
parent 14aa94d2d6
commit 08cf916a83
5 changed files with 68 additions and 23 deletions

View File

@ -720,10 +720,20 @@ public func channelInfoController(account: Account, peerId: PeerId) -> ViewContr
presentControllerImpl?(channelVisibilityController(account: account, peerId: peerId, mode: .generic), ViewControllerPresentationArguments(presentationAnimation: ViewControllerPresentationAnimation.modalSheet))
}, changeNotificationMuteSettings: {
let presentationData = account.telegramApplicationContext.currentPresentationData.with { $0 }
let controller = notificationMuteSettingsController(presentationData: presentationData, updateSettings: { value in
actionsDisposable.add((account.postbox.preferencesView(keys: [PreferencesKeys.globalNotifications]) |> take(1) |> deliverOnMainQueue).start(next: { view in
let viewSettings: GlobalNotificationSettingsSet
if let settings = view.values[PreferencesKeys.globalNotifications] as? GlobalNotificationSettings {
viewSettings = settings.effective
} else {
viewSettings = GlobalNotificationSettingsSet.defaultSettings
}
let controller = notificationMuteSettingsController(presentationData: presentationData, notificationSettings: viewSettings.privateChats, updateSettings: { value in
changeMuteSettingsDisposable.set(updatePeerMuteSetting(account: account, peerId: peerId, muteInterval: value).start())
})
presentControllerImpl?(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
}))
}, changeNotificationSoundSettings: {
let _ = (account.postbox.transaction { transaction -> (TelegramPeerNotificationSettings, GlobalNotificationSettings) in
let peerSettings: TelegramPeerNotificationSettings = (transaction.getPeerNotificationSettings(peerId) as? TelegramPeerNotificationSettings) ?? TelegramPeerNotificationSettings.defaultSettings

View File

@ -769,12 +769,10 @@ private func groupInfoEntries(account: Account, presentationData: PresentationDa
let peerNotificationSettings: TelegramPeerNotificationSettings = (view.notificationSettings as? TelegramPeerNotificationSettings) ?? TelegramPeerNotificationSettings.defaultSettings
let notificationsText: String
switch peerNotificationSettings.muteState {
case .default:
notificationsText = presentationData.strings.UserInfo_NotificationsDefault
case .muted:
if case .muted = peerNotificationSettings.muteState {
notificationsText = presentationData.strings.UserInfo_NotificationsDisabled
case .unmuted:
} else {
notificationsText = presentationData.strings.UserInfo_NotificationsEnabled
}
@ -1281,10 +1279,20 @@ public func groupInfoController(account: Account, peerId: PeerId) -> ViewControl
presentControllerImpl?(controller, presentationArguments)
}, changeNotificationMuteSettings: {
let presentationData = account.telegramApplicationContext.currentPresentationData.with { $0 }
let controller = notificationMuteSettingsController(presentationData: presentationData, updateSettings: { value in
actionsDisposable.add((account.postbox.preferencesView(keys: [PreferencesKeys.globalNotifications]) |> take(1) |> deliverOnMainQueue).start(next: { view in
let viewSettings: GlobalNotificationSettingsSet
if let settings = view.values[PreferencesKeys.globalNotifications] as? GlobalNotificationSettings {
viewSettings = settings.effective
} else {
viewSettings = GlobalNotificationSettingsSet.defaultSettings
}
let controller = notificationMuteSettingsController(presentationData: presentationData, notificationSettings: viewSettings.privateChats, updateSettings: { value in
changeMuteSettingsDisposable.set(updatePeerMuteSetting(account: account, peerId: peerId, muteInterval: value).start())
})
presentControllerImpl?(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
}))
}, changeNotificationSoundSettings: {
let _ = (account.postbox.transaction { transaction -> (TelegramPeerNotificationSettings, GlobalNotificationSettings) in
let peerSettings: TelegramPeerNotificationSettings = (transaction.getPeerNotificationSettings(peerId) as? TelegramPeerNotificationSettings) ?? TelegramPeerNotificationSettings.defaultSettings

View File

@ -290,6 +290,10 @@ private func notificationsExceptionEntries(presentationData: PresentationData, s
let soundName = localizedPeerNotificationSoundString(strings: presentationData.strings, sound: value.settings.messageSound)
title += (title.isEmpty ? presentationData.strings.Notification_Exceptions_Sound(soundName).0 : ", \(presentationData.strings.Notification_Exceptions_Sound(soundName).0)")
}
if value.peer.displayTitle == "Vyezd Family" {
var bp:Int = 0
bp += 1
}
entries.append(.peer(index: index, peer: value.peer, theme: presentationData.theme, strings: presentationData.strings, dateFormat: presentationData.dateTimeFormat, description: title, notificationSettings: value.settings, revealed: state.revealedPeerId == value.peer.id, editing: state.editing))
index += 1
}

View File

@ -1,5 +1,7 @@
import Foundation
import Display
import TelegramCore
import Postbox
private enum NotificationMuteOption {
case `default`
@ -8,7 +10,9 @@ private enum NotificationMuteOption {
case disable
}
func notificationMuteSettingsController(presentationData: PresentationData, updateSettings: @escaping (Int32?) -> Void) -> ViewController {
func notificationMuteSettingsController(presentationData: PresentationData, notificationSettings: MessageNotificationSettings, updateSettings: @escaping (Int32?) -> Void) -> ViewController {
let controller = ActionSheetController(presentationTheme: presentationData.theme)
let dismissAction: () -> Void = { [weak controller] in
controller?.dismissAnimated()
@ -31,7 +35,7 @@ func notificationMuteSettingsController(presentationData: PresentationData, upda
}
let options: [NotificationMuteOption] = [
.default,
// .default,
.enable,
.interval(1 * 60 * 60),
.interval(8 * 60 * 60),
@ -51,7 +55,11 @@ func notificationMuteSettingsController(presentationData: PresentationData, upda
case .enable:
item = ActionSheetButtonItem(title: presentationData.strings.UserInfo_NotificationsEnable, action: {
dismissAction()
if notificationSettings.enabled {
notificationAction(nil)
} else {
notificationAction(0)
}
})
case let .interval(value):
item = ActionSheetButtonItem(title: muteForIntervalString(strings: presentationData.strings, value: value), action: {
@ -61,7 +69,11 @@ func notificationMuteSettingsController(presentationData: PresentationData, upda
case .disable:
item = ActionSheetButtonItem(title: presentationData.strings.UserInfo_NotificationsDisable, action: {
dismissAction()
if !notificationSettings.enabled {
notificationAction(nil)
} else {
notificationAction(Int32.max)
}
})
}
items.append(item)

View File

@ -860,10 +860,21 @@ public func userInfoController(account: Account, peerId: PeerId, mode: UserInfoC
startSecretChatImpl?()
}, changeNotificationMuteSettings: {
let presentationData = account.telegramApplicationContext.currentPresentationData.with { $0 }
let controller = notificationMuteSettingsController(presentationData: presentationData, updateSettings: { value in
actionsDisposable.add((account.postbox.preferencesView(keys: [PreferencesKeys.globalNotifications]) |> take(1) |> deliverOnMainQueue).start(next: { view in
let viewSettings: GlobalNotificationSettingsSet
if let settings = view.values[PreferencesKeys.globalNotifications] as? GlobalNotificationSettings {
viewSettings = settings.effective
} else {
viewSettings = GlobalNotificationSettingsSet.defaultSettings
}
let controller = notificationMuteSettingsController(presentationData: presentationData, notificationSettings: viewSettings.privateChats, updateSettings: { value in
changeMuteSettingsDisposable.set(updatePeerMuteSetting(account: account, peerId: peerId, muteInterval: value).start())
})
presentControllerImpl?(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
}))
}, changeNotificationSoundSettings: {
let _ = (account.postbox.transaction { transaction -> (TelegramPeerNotificationSettings, GlobalNotificationSettings) in
let peerSettings: TelegramPeerNotificationSettings = (transaction.getPeerNotificationSettings(peerId) as? TelegramPeerNotificationSettings) ?? TelegramPeerNotificationSettings.defaultSettings