Various fixes

This commit is contained in:
Peter 2019-06-17 23:03:25 +01:00
parent 66a7e1f63d
commit afc8d304bb
19 changed files with 3006 additions and 3113 deletions

View File

@ -1614,7 +1614,10 @@
"ShareMenu.Send" = "Send";
"Conversation.ReportSpam" = "Report Spam";
"Conversation.ReportSpamAndLeave" = "Report Spam and Leave";
"Conversation.ReportSpamConfirmation" = "Are you sure you want to report spam from this user?";
"Conversation.ReportSpamGroupConfirmation" = "Are you sure you want to report spam from this group?";
"Conversation.ReportSpamChannelConfirmation" = "Are you sure you want to report spam from this channel?";
"SharedMedia.EmptyMusicText" = "All music shared in this chat will appear here.";
"ChatSettings.AutoPlayAnimations" = "Autoplay GIFs";
@ -4348,6 +4351,7 @@ Any member of this group will be able to see messages in the channel.";
"Appearance.ThemeCarouselNight" = "Monochrome";
"Notification.Exceptions.DeleteAll" = "Delete All";
"Notification.Exceptions.DeleteAllConfirmation" = "Are you sure you want to delete all exceptions?";
"Notification.Exceptions.Add" = "Add";
"Exceptions.AddToExceptions" = "ADD TO EXCEPTIONS";
@ -4358,6 +4362,7 @@ Any member of this group will be able to see messages in the channel.";
"Conversation.Block" = "Block";
"Conversation.BlockUser" = "Block User";
"Conversation.ShareMyPhoneNumber" = "Share My Phone Number";
"Conversation.ShareMyPhoneNumberConfirmation" = "Are you sure you want to share your phone number %1$@ with %2$@?";
"Conversation.AddToContacts" = "Add to Contacts";
"Conversation.AddNameToContacts" = "Add %@ to Contacts";

View File

@ -478,36 +478,6 @@ final class MutableMessageHistoryView {
self.sampledState = self.state.sample(postbox: postbox)
}
/*for operationSet in operations {
for operation in operationSet {
switch operation {
case let .InsertMessage(intermediateMessage):
for i in 0 ..< self.entries.count {
switch self.entries[i] {
case let .MessageEntry(value):
let message = value.message
if message.associatedMessageIds.count != message.associatedMessages.count {
if message.associatedMessageIds.contains(intermediateMessage.id) && message.associatedMessages[intermediateMessage.id] == nil {
var updatedAssociatedMessages = message.associatedMessages
let renderedMessage = renderIntermediateMessage(intermediateMessage)
updatedAssociatedMessages[intermediateMessage.id] = renderedMessage
let updatedMessage = Message(stableId: message.stableId, stableVersion: message.stableVersion, id: message.id, globallyUniqueId: message.globallyUniqueId, groupingKey: message.groupingKey, groupInfo: message.groupInfo, timestamp: message.timestamp, flags: message.flags, tags: message.tags, globalTags: message.globalTags, localTags: message.localTags, forwardInfo: message.forwardInfo, author: message.author, text: message.text, attributes: message.attributes, media: message.media, peers: message.peers, associatedMessages: updatedAssociatedMessages, associatedMessageIds: message.associatedMessageIds)
self.entries[i] = .MessageEntry(MessageHistoryMessageEntry(message: updatedMessage, location: value.location, monthLocation: value.monthLocation, attributes: value.attributes))
hasChanges = true
}
}
break
default:
break
}
}
break
default:
break
}
}
}*/
for operationSet in operations {
for operation in operationSet {
switch operation {
@ -786,150 +756,6 @@ public final class MessageHistoryView {
self.isLoading = isLoading
}
/*var entries: [MessageHistoryEntry] = []
if let transientReadStates = mutableView.transientReadStates, case let .peer(states) = transientReadStates {
for entry in mutableView.entries {
switch entry {
case let .MessageEntry(value):
let read: Bool
if value.message.flags.contains(.Incoming) {
read = false
} else if let readState = states[value.message.id.peerId] {
read = readState.isOutgoingMessageIndexRead(value.message.index)
} else {
read = false
}
entries.append(MessageHistoryEntry(message: value.message, isRead: read, location: value.location, monthLocation: value.monthLocation, attributes: value.attributes))
case .IntermediateMessageEntry:
assertionFailure("unexpected IntermediateMessageEntry in MessageHistoryView.init()")
}
}
} else {
for entry in mutableView.entries {
switch entry {
case let .MessageEntry(value):
entries.append(MessageHistoryEntry(message: value.message, isRead: false, location: value.location, monthLocation: value.monthLocation, attributes: value.attributes))
case .IntermediateMessageEntry:
assertionFailure("unexpected IntermediateMessageEntry in MessageHistoryView.init()")
}
}
}
var holeEarlier = false
var holeLater = false
if mutableView.clipHoles {
if entries.isEmpty {
if !mutableView.holes.isEmpty {
holeEarlier = true
holeLater = true
}
} else {
var clearAllEntries = false
if case let .message(index) = self.anchorIndex {
for (holeKey, indices) in mutableView.holes {
if holeKey.peerId == index.id.peerId && holeKey.namespace == index.id.namespace && indices.contains(Int(index.id.id)) {
entries.removeAll()
earlierId = nil
holeEarlier = true
laterId = nil
holeLater = true
clearAllEntries = true
break
}
}
}
if !clearAllEntries {
var referenceIndex = entries.count - 1
for i in 0 ..< entries.count {
if self.anchorIndex.isLessOrEqual(to: entries[i].index) {
referenceIndex = i
break
}
}
var groupStart: (Int, MessageGroupInfo)?
for i in referenceIndex ..< entries.count {
let id = entries[i].message.id
if let holeIndices = mutableView.holes[PeerIdAndNamespace(peerId: id.peerId, namespace: id.namespace)] {
if holeIndices.contains(Int(id.id)) {
if let groupStart = groupStart {
entries.removeSubrange(groupStart.0 ..< entries.count)
} else {
entries.removeSubrange(i ..< entries.count)
}
laterId = nil
holeLater = true
break
}
}
/*if let groupStart = groupStart {
entries.removeSubrange(groupStart.0 ..< entries.count)
laterId = nil
} else {
if i != entries.count - 1 {
entries.removeSubrange(i + 1 ..< entries.count)
laterId = nil
}
}*/
if let groupInfo = entries[i].message.groupInfo {
if let groupStart = groupStart, groupStart.1 == groupInfo {
} else {
groupStart = (i, groupInfo)
}
} else {
groupStart = nil
}
}
if let groupStart = groupStart, laterId != nil {
entries.removeSubrange(groupStart.0 ..< entries.count)
}
groupStart = nil
if !entries.isEmpty {
for i in (0 ... min(referenceIndex, entries.count - 1)).reversed() {
let id = entries[i].message.id
if let holeIndices = mutableView.holes[PeerIdAndNamespace(peerId: id.peerId, namespace: id.namespace)] {
if holeIndices.contains(Int(id.id)) {
if let groupStart = groupStart {
entries.removeSubrange(0 ..< groupStart.0 + 1)
} else {
entries.removeSubrange(0 ... i)
}
earlierId = nil
holeEarlier = true
break
}
}
/*if let groupStart = groupStart {
entries.removeSubrange(0 ..< groupStart.0 + 1)
earlierId = nil
} else {
if i != 0 {
entries.removeSubrange(0 ..< i)
earlierId = nil
}
}
break
*/
if let groupInfo = entries[i].message.groupInfo {
if let groupStart = groupStart, groupStart.1 == groupInfo {
} else {
groupStart = (i, groupInfo)
}
} else {
groupStart = nil
}
}
if let groupStart = groupStart, earlierId != nil {
entries.removeSubrange(0 ..< groupStart.0 + 1)
}
}
}
}
}
self.holeEarlier = holeEarlier
self.holeLater = holeLater
self.entries = entries*/
var topTaggedMessages: [Message] = []
for (_, message) in mutableView.topTaggedMessages {
if let message = message {

View File

@ -1560,6 +1560,9 @@ public final class Postbox {
fileprivate func clearHistory(_ peerId: PeerId) {
self.messageHistoryTable.clearHistory(peerId: peerId, operationsByPeerId: &self.currentOperationsByPeerId, updatedMedia: &self.currentUpdatedMedia, unsentMessageOperations: &currentUnsentOperations, updatedPeerReadStateOperations: &self.currentUpdatedSynchronizeReadStateOperations, globalTagsOperations: &self.currentGlobalTagsOperations, pendingActionsOperations: &self.currentPendingMessageActionsOperations, updatedMessageActionsSummaries: &self.currentUpdatedMessageActionsSummaries, updatedMessageTagSummaries: &self.currentUpdatedMessageTagSummaries, invalidateMessageTagSummaries: &self.currentInvalidateMessageTagSummaries, localTagsOperations: &self.currentLocalTagsOperations)
for namespace in self.messageHistoryHoleIndexTable.existingNamespaces(peerId: peerId, holeSpace: .everywhere) {
self.messageHistoryHoleIndexTable.remove(peerId: peerId, namespace: namespace, space: .everywhere, range: 1 ... Int32.max - 1, operations: &self.currentPeerHoleOperations)
}
}
fileprivate func removeAllMessagesWithAuthor(_ peerId: PeerId, authorId: PeerId, namespace: MessageId.Namespace) {

View File

@ -22,12 +22,15 @@ public final class NotificationExceptionsList: Equatable {
}
}
public func notificationExceptionsList(network: Network) -> Signal<NotificationExceptionsList, NoError> {
return network.request(Api.functions.account.getNotifyExceptions(flags: 1 << 1, peer: nil)) |> retryRequest |> map { result in
switch result {
public func notificationExceptionsList(postbox: Postbox, network: Network) -> Signal<NotificationExceptionsList, NoError> {
return network.request(Api.functions.account.getNotifyExceptions(flags: 1 << 1, peer: nil))
|> retryRequest
|> mapToSignal { result -> Signal<NotificationExceptionsList, NoError> in
return postbox.transaction { transaction -> NotificationExceptionsList in
switch result {
case let .updates(updates, users, chats, _, _):
var peers:[PeerId: Peer] = [:]
var settings:[PeerId : TelegramPeerNotificationSettings] = [:]
var peers: [PeerId: Peer] = [:]
var settings: [PeerId: TelegramPeerNotificationSettings] = [:]
for user in users {
let peer = TelegramUser(user: user)
@ -39,32 +42,35 @@ public func notificationExceptionsList(network: Network) -> Signal<NotificationE
}
}
updatePeers(transaction: transaction, peers: Array(peers.values), update: { _, updated in updated })
for update in updates {
switch update {
case let .updateNotifySettings(apiPeer, notifySettings):
switch apiPeer {
case let .notifyPeer(notifyPeer):
let peerId: PeerId
switch notifyPeer {
case let .peerUser(userId):
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
case let .peerChat(chatId):
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
case let .peerChannel(channelId):
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
}
settings[peerId] = TelegramPeerNotificationSettings(apiSettings: notifySettings)
default:
break
case let .updateNotifySettings(apiPeer, notifySettings):
switch apiPeer {
case let .notifyPeer(notifyPeer):
let peerId: PeerId
switch notifyPeer {
case let .peerUser(userId):
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
case let .peerChat(chatId):
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
case let .peerChannel(channelId):
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
}
settings[peerId] = TelegramPeerNotificationSettings(apiSettings: notifySettings)
default:
break
}
default:
break
}
}
return NotificationExceptionsList(peers: peers, settings: settings)
default:
return NotificationExceptionsList(peers: [:], settings: [:])
}
}
}
}

View File

@ -18,7 +18,7 @@ public struct PeerStatusSettings: OptionSet {
public static let canBlock = PeerStatusSettings(rawValue: 1 << 3)
public static let canAddContact = PeerStatusSettings(rawValue: 1 << 4)
public static let addExceptionWhenAddingContact = PeerStatusSettings(rawValue: 1 << 5)
public static let canReportIrrelevantGeoLocation = PeerStatusSettings(rawValue: 1 << 5)
public static let canReportIrrelevantGeoLocation = PeerStatusSettings(rawValue: 1 << 6)
}
extension PeerStatusSettings {

View File

@ -1573,7 +1573,7 @@ public final class ChatController: TelegramController, GalleryHiddenMediaTarget,
}
var didDisplayActionsPanel = false
if let contactStatus = strongSelf.presentationInterfaceState.contactStatus, let peerStatusSettings = contactStatus.peerStatusSettings {
if let contactStatus = strongSelf.presentationInterfaceState.contactStatus, !contactStatus.isEmpty, let peerStatusSettings = contactStatus.peerStatusSettings {
if !peerStatusSettings.isEmpty {
if contactStatus.canAddContact && peerStatusSettings.contains(.canAddContact) {
didDisplayActionsPanel = true
@ -1588,7 +1588,7 @@ public final class ChatController: TelegramController, GalleryHiddenMediaTarget,
}
var displayActionsPanel = false
if let contactStatus = contactStatus, let peerStatusSettings = contactStatus.peerStatusSettings {
if let contactStatus = contactStatus, !contactStatus.isEmpty, let peerStatusSettings = contactStatus.peerStatusSettings {
if !peerStatusSettings.isEmpty {
if contactStatus.canAddContact && peerStatusSettings.contains(.canAddContact) {
displayActionsPanel = true
@ -5918,9 +5918,15 @@ public final class ChatController: TelegramController, GalleryHiddenMediaTarget,
let title: String
var infoString: String?
if let _ = peer as? TelegramGroup {
title = self.presentationData.strings.Conversation_ReportSpam
} else if let _ = peer as? TelegramChannel {
title = self.presentationData.strings.Conversation_ReportSpam
title = self.presentationData.strings.Conversation_ReportSpamAndLeave
infoString = self.presentationData.strings.Conversation_ReportSpamGroupConfirmation
} else if let channel = peer as? TelegramChannel {
title = self.presentationData.strings.Conversation_ReportSpamAndLeave
if case .group = channel.info {
infoString = self.presentationData.strings.Conversation_ReportSpamGroupConfirmation
} else {
infoString = self.presentationData.strings.Conversation_ReportSpamChannelConfirmation
}
} else {
title = self.presentationData.strings.Conversation_ReportSpam
infoString = self.presentationData.strings.Conversation_ReportSpamConfirmation
@ -5953,25 +5959,42 @@ public final class ChatController: TelegramController, GalleryHiddenMediaTarget,
guard let strongSelf = self else {
return
}
guard let _ = accountPeer as? TelegramUser else {
guard let user = accountPeer as? TelegramUser, let phoneNumber = user.phone else {
return
}
guard let peer = strongSelf.presentationInterfaceState.renderedPeer?.chatMainPeer as? TelegramUser else {
return
}
let _ = (acceptAndShareContact(account: strongSelf.context.account, peerId: peer.id)
|> deliverOnMainQueue).start(error: { _ in
let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme)
var items: [ActionSheetItem] = []
items.append(ActionSheetTextItem(title: strongSelf.presentationData.strings.Conversation_ShareMyPhoneNumberConfirmation(formatPhoneNumber(phoneNumber), peer.compactDisplayTitle).0))
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_ShareMyPhoneNumber, action: { [weak actionSheet] in
actionSheet?.dismissAnimated()
guard let strongSelf = self else {
return
}
strongSelf.present(textAlertController(context: strongSelf.context, title: nil, text: strongSelf.presentationData.strings.Login_UnknownError, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
}, completed: {
guard let strongSelf = self else {
return
}
strongSelf.present(OverlayStatusController(theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, type: .genericSuccess(strongSelf.presentationData.strings.Conversation_ShareMyPhoneNumber_StatusSuccess(peer.compactDisplayTitle).0, true)), in: .window(.root))
})
let _ = (acceptAndShareContact(account: strongSelf.context.account, peerId: peer.id)
|> deliverOnMainQueue).start(error: { _ in
guard let strongSelf = self else {
return
}
strongSelf.present(textAlertController(context: strongSelf.context, title: nil, text: strongSelf.presentationData.strings.Login_UnknownError, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
}, completed: {
guard let strongSelf = self else {
return
}
strongSelf.present(OverlayStatusController(theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, type: .genericSuccess(strongSelf.presentationData.strings.Conversation_ShareMyPhoneNumber_StatusSuccess(peer.compactDisplayTitle).0, true)), in: .window(.root))
})
}))
actionSheet.setItemGroups([ActionSheetItemGroup(items: items), ActionSheetItemGroup(items: [
ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Cancel, color: .accent, action: { [weak actionSheet] in
actionSheet?.dismissAnimated()
})
])])
strongSelf.chatDisplayNode.dismissInput()
strongSelf.present(actionSheet, in: .window(.root))
})
}

View File

@ -100,38 +100,39 @@ func chatHistoryEntriesForView(location: ChatLocation, view: MessageHistoryView,
}
if let cachedPeerData = cachedPeerData as? CachedUserData, let botInfo = cachedPeerData.botInfo, !botInfo.description.isEmpty {
entries.insert(.ChatInfoEntry(botInfo.description, presentationData), at: 0)
}
var isEmpty = true
if entries.count <= 3 {
loop: for entry in view.entries {
var isEmptyMedia = false
for media in entry.message.media {
if let action = media as? TelegramMediaAction {
switch action.action {
case .groupCreated, .photoUpdated, .channelMigratedFromGroup, .groupMigratedToChannel:
isEmptyMedia = true
default:
break
} else {
var isEmpty = true
if entries.count <= 3 {
loop: for entry in view.entries {
var isEmptyMedia = false
for media in entry.message.media {
if let action = media as? TelegramMediaAction {
switch action.action {
case .groupCreated, .photoUpdated, .channelMigratedFromGroup, .groupMigratedToChannel:
isEmptyMedia = true
default:
break
}
}
}
var isCreator = false
if let peer = entry.message.peers[entry.message.id.peerId] as? TelegramGroup, case .creator = peer.role {
isCreator = true
} else if let peer = entry.message.peers[entry.message.id.peerId] as? TelegramChannel, case .group = peer.info, peer.flags.contains(.isCreator) {
isCreator = true
}
if isEmptyMedia && isCreator {
} else {
isEmpty = false
break loop
}
}
var isCreator = false
if let peer = entry.message.peers[entry.message.id.peerId] as? TelegramGroup, case .creator = peer.role {
isCreator = true
} else if let peer = entry.message.peers[entry.message.id.peerId] as? TelegramChannel, case .group = peer.info, peer.flags.contains(.isCreator) {
isCreator = true
}
if isEmptyMedia && isCreator {
} else {
isEmpty = false
break loop
}
} else {
isEmpty = false
}
if isEmpty {
entries.removeAll()
}
} else {
isEmpty = false
}
if isEmpty {
entries.removeAll()
}
}
} else if includeSearchEntry {

View File

@ -530,12 +530,12 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
if let filteredEntries = historyView?.filteredEntries, let visibleRange = displayRange.visibleRange {
let lastEntry = filteredEntries[filteredEntries.count - 1 - visibleRange.lastIndex]
strongSelf.chatHistoryLocationValue = ChatHistoryLocationInput(content: .Navigation(index: .message(lastEntry.index), anchorIndex: .message(lastEntry.index), count: historyMessageCount), id: 0)
strongSelf.chatHistoryLocationValue = ChatHistoryLocationInput(content: .Navigation(index: .message(lastEntry.index), anchorIndex: .message(lastEntry.index), count: historyMessageCount), id: (strongSelf.chatHistoryLocationValue?.id).flatMap({ $0 + 1 }) ?? 0)
} else {
if let messageId = messageId {
strongSelf.chatHistoryLocationValue = ChatHistoryLocationInput(content: .InitialSearch(location: .id(messageId), count: 60), id: 0)
strongSelf.chatHistoryLocationValue = ChatHistoryLocationInput(content: .InitialSearch(location: .id(messageId), count: 60), id: (strongSelf.chatHistoryLocationValue?.id).flatMap({ $0 + 1 }) ?? 0)
} else {
strongSelf.chatHistoryLocationValue = ChatHistoryLocationInput(content: .Initial(count: 60), id: 0)
strongSelf.chatHistoryLocationValue = ChatHistoryLocationInput(content: .Initial(count: 60), id: (strongSelf.chatHistoryLocationValue?.id).flatMap({ $0 + 1 }) ?? 0)
}
}
}
@ -993,11 +993,11 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
if let loaded = displayedRange.loadedRange, let firstEntry = historyView.filteredEntries.first, let lastEntry = historyView.filteredEntries.last {
if loaded.firstIndex < 5 && historyView.originalView.laterId != nil {
self.chatHistoryLocationValue = ChatHistoryLocationInput(content: .Navigation(index: .message(lastEntry.index), anchorIndex: .message(lastEntry.index), count: historyMessageCount), id: 0)
self.chatHistoryLocationValue = ChatHistoryLocationInput(content: .Navigation(index: .message(lastEntry.index), anchorIndex: .message(lastEntry.index), count: historyMessageCount), id: (self.chatHistoryLocationValue?.id).flatMap({ $0 + 1 }) ?? 0)
} else if loaded.firstIndex < 5, historyView.originalView.laterId == nil, !historyView.originalView.holeLater, let chatHistoryLocationValue = self.chatHistoryLocationValue, !chatHistoryLocationValue.isAtUpperBound, historyView.originalView.anchorIndex != .upperBound {
self.chatHistoryLocationValue = ChatHistoryLocationInput(content: .Navigation(index: .upperBound, anchorIndex: .upperBound, count: historyMessageCount), id: 0)
self.chatHistoryLocationValue = ChatHistoryLocationInput(content: .Navigation(index: .upperBound, anchorIndex: .upperBound, count: historyMessageCount), id: (self.chatHistoryLocationValue?.id).flatMap({ $0 + 1 }) ?? 0)
} else if loaded.lastIndex >= historyView.filteredEntries.count - 5 && historyView.originalView.earlierId != nil {
self.chatHistoryLocationValue = ChatHistoryLocationInput(content: .Navigation(index: .message(firstEntry.index), anchorIndex: .message(firstEntry.index), count: historyMessageCount), id: 0)
self.chatHistoryLocationValue = ChatHistoryLocationInput(content: .Navigation(index: .message(firstEntry.index), anchorIndex: .message(firstEntry.index), count: historyMessageCount), id: (self.chatHistoryLocationValue?.id).flatMap({ $0 + 1 }) ?? 0)
}
}

View File

@ -323,6 +323,16 @@ final class ChatRecordedMediaPreview: Equatable {
struct ChatContactStatus: Equatable {
var canAddContact: Bool
var peerStatusSettings: PeerStatusSettings?
var isEmpty: Bool {
guard var peerStatusSettings = self.peerStatusSettings else {
return false
}
if !self.canAddContact {
peerStatusSettings.remove(.canAddContact)
}
return peerStatusSettings.isEmpty
}
}
final class ChatPresentationInterfaceState: Equatable {

View File

@ -26,7 +26,7 @@ private enum ChatReportPeerTitleButton: Equatable {
case .shareMyPhoneNumber:
return strings.Conversation_ShareMyPhoneNumber
case .reportSpam:
return strings.Conversation_ReportSpam
return strings.Conversation_ReportSpamAndLeave
case .reportIrrelevantGeoLocation:
return strings.Conversation_ReportGroupLocation
}
@ -131,11 +131,12 @@ final class ChatReportPeerTitlePanelNode: ChatTitleAccessoryPanelNode {
let view = UIButton()
view.setTitle(button.title(strings: interfaceState.strings), for: [])
view.titleLabel?.font = Font.regular(16.0)
if case .block = button {
switch button {
case .block, .reportSpam:
view.setTitleColor(interfaceState.theme.chat.inputPanel.panelControlDestructiveColor, for: [])
view.setTitleColor(interfaceState.theme.chat.inputPanel.panelControlDestructiveColor.withAlphaComponent(0.7), for: [.highlighted])
} else {
view.setTitleColor(interfaceState.theme.rootController.navigationBar.accentTextColor, for: [])
default:
view.setTitleColor(interfaceState.theme.rootController.navigationBar.accentTextColor, for: [])
view.setTitleColor(interfaceState.theme.rootController.navigationBar.accentTextColor.withAlphaComponent(0.7), for: [.highlighted])
}
view.addTarget(self, action: #selector(self.buttonPressed(_:)), for: [.touchUpInside])
@ -154,7 +155,7 @@ final class ChatReportPeerTitlePanelNode: ChatTitleAccessoryPanelNode {
nextButtonOrigin += buttonWidth
}
} else {
let additionalRightInset: CGFloat = 18.0
let additionalRightInset: CGFloat = 36.0
let areaWidth = width - maxInset * 2.0 - additionalRightInset
let maxButtonWidth = floor(areaWidth / CGFloat(self.buttons.count))
let buttonSizes = self.buttons.map { button -> CGFloat in

View File

@ -414,9 +414,9 @@ private enum DeviceContactInfoEntry: ItemListNodeEntry {
arguments.setPhoneIdWithRevealedOptions(lhs, rhs)
}, updated: { value in
arguments.updatePhone(id, value)
}, selectLabel: {
}, selectLabel: nil /*{
arguments.updatePhoneLabel(id, label)
}, delete: {
}*/, delete: {
arguments.deletePhone(id)
}, tag: DeviceContactInfoEntryTag.editingPhone(id))
case let .addPhoneNumber(_, theme, title):

View File

@ -883,6 +883,7 @@ final class NotificationExceptionsControllerNode: ViewControllerTracingNode {
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
let actionSheet = ActionSheetController(presentationTheme: presentationData.theme)
actionSheet.setItemGroups([ActionSheetItemGroup(items: [
ActionSheetTextItem(title: presentationData.strings.Notification_Exceptions_DeleteAllConfirmation),
ActionSheetButtonItem(title: presentationData.strings.Notification_Exceptions_DeleteAll, color: .destructive, action: { [weak actionSheet] in
actionSheet?.dismissAnimated()

View File

@ -219,27 +219,36 @@ func playSound(context: AccountContext, sound: PeerMessageSound, defaultSound: P
var currentPlayer: AudioPlayerWrapper?
var deactivateImpl: (() -> Void)?
let session = context.sharedContext.mediaManager.audioSession.push(audioSessionType: .play, activate: { _ in
if let url = Bundle.main.url(forResource: fileNameForNotificationSound(sound, defaultSound: defaultSound), withExtension: "m4a") {
currentPlayer = AudioPlayerWrapper(url: url, completed: {
deactivateImpl?()
})
currentPlayer?.play()
Queue.mainQueue().async {
if let url = Bundle.main.url(forResource: fileNameForNotificationSound(sound, defaultSound: defaultSound), withExtension: "m4a") {
currentPlayer = AudioPlayerWrapper(url: url, completed: {
deactivateImpl?()
})
currentPlayer?.play()
}
}
}, deactivate: {
currentPlayer?.stop()
currentPlayer = nil
return .complete()
return Signal { subscriber in
Queue.mainQueue().async {
currentPlayer?.stop()
currentPlayer = nil
subscriber.putCompletion()
}
return EmptyDisposable
}
})
deactivateImpl = {
session.dispose()
}
return ActionDisposable {
session.dispose()
currentPlayer?.stop()
currentPlayer = nil
Queue.mainQueue().async {
currentPlayer?.stop()
currentPlayer = nil
}
}
} |> runOn(Queue.mainQueue())
}
|> runOn(Queue.mainQueue())
}
}

View File

@ -1002,7 +1002,7 @@ public func notificationsAndSoundsController(context: AccountContext, exceptions
let sharedData = context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.inAppNotificationSettings])
let preferences = context.account.postbox.preferencesView(keys: [PreferencesKeys.globalNotifications])
let exceptionsSignal = Signal<NotificationExceptionsList?, NoError>.single(exceptionsList) |> then(notificationExceptionsList(network: context.account.network) |> map(Optional.init))
let exceptionsSignal = Signal<NotificationExceptionsList?, NoError>.single(exceptionsList) |> then(notificationExceptionsList(postbox: context.account.postbox, network: context.account.network) |> map(Optional.init))
notificationExceptions.set(exceptionsSignal |> map { list -> (NotificationExceptionMode, NotificationExceptionMode, NotificationExceptionMode) in
var users:[PeerId : NotificationExceptionWrapper] = [:]

View File

@ -1074,7 +1074,7 @@ public func settingsController(context: AccountContext, accountManager: AccountM
|> mapToSignal { context -> Signal<NotificationExceptionsList?, NoError> in
return .single(NotificationExceptionsList(peers: [:], settings: [:]))
|> then(
notificationExceptionsList(network: context.account.network)
notificationExceptionsList(postbox: context.account.postbox, network: context.account.network)
|> map(Optional.init)
)
}

View File

@ -20,11 +20,11 @@ class UserInfoEditingPhoneItem: ListViewItem, ItemListItem {
let sectionId: ItemListSectionId
let setPhoneIdWithRevealedOptions: (Int64?, Int64?) -> Void
let updated: (String) -> Void
let selectLabel: () -> Void
let selectLabel: (() -> Void)?
let delete: () -> Void
let tag: ItemListItemTag?
init(theme: PresentationTheme, strings: PresentationStrings, id: Int64, label: String, value: String, editing: UserInfoEditingPhoneItemEditing, sectionId: ItemListSectionId, setPhoneIdWithRevealedOptions: @escaping (Int64?, Int64?) -> Void, updated: @escaping (String) -> Void, selectLabel: @escaping () -> Void, delete: @escaping () -> Void, tag: ItemListItemTag?) {
init(theme: PresentationTheme, strings: PresentationStrings, id: Int64, label: String, value: String, editing: UserInfoEditingPhoneItemEditing, sectionId: ItemListSectionId, setPhoneIdWithRevealedOptions: @escaping (Int64?, Int64?) -> Void, updated: @escaping (String) -> Void, selectLabel: (() -> Void)?, delete: @escaping () -> Void, tag: ItemListItemTag?) {
self.theme = theme
self.strings = strings
self.id = id
@ -237,6 +237,7 @@ class UserInfoEditingPhoneItemNode: ItemListRevealOptionsItemNode, ItemListItemN
let labelFrame = CGRect(origin: CGPoint(x: revealOffset + leftInset + 30.0, y: 12.0), size: labelLayout.size)
strongSelf.labelNode.frame = labelFrame
strongSelf.labelButtonNode.frame = labelFrame
strongSelf.labelButtonNode.isUserInteractionEnabled = item.selectLabel != nil
strongSelf.labelSeparatorNode.frame = CGRect(origin: CGPoint(x: labelFrame.maxX + 8.0, y: 0.0), size: CGSize(width: UIScreenPixel, height: layout.contentSize.height))
let phoneX = labelFrame.maxX + 16.0
@ -293,7 +294,7 @@ class UserInfoEditingPhoneItemNode: ItemListRevealOptionsItemNode, ItemListItemN
}
@objc func labelPressed() {
self.item?.selectLabel()
self.item?.selectLabel?()
}
func focus() {

View File

@ -12,7 +12,7 @@
<key>Lottie_iOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>44</integer>
<integer>46</integer>
</dict>
</dict>
</dict>