Fixed admins list update after transfering to non-participant

Fixed peers nearby activity indicators
Fixed Siri shortcut opening from cold start
This commit is contained in:
Ilya Laktyushin 2019-06-20 12:38:50 +02:00
parent 8d723f1c45
commit f0c60c379d
9 changed files with 55 additions and 40 deletions

View File

@ -1641,8 +1641,8 @@ final class SharedApplicationContext {
} else if let sendMessageIntent = userActivity.interaction?.intent as? INSendMessageIntent {
if let contact = sendMessageIntent.recipients?.first, let handle = contact.customIdentifier, handle.hasPrefix("tg") {
let string = handle.suffix(from: handle.index(handle.startIndex, offsetBy: 2))
if let id = Int32(string), let context = self.contextValue {
navigateToChatController(navigationController: context.rootController, context: context.context, chatLocation: .peer(PeerId(namespace: Namespaces.Peer.CloudUser, id: id)))
if let id = Int32(string) {
self.openChatWhenReady(accountId: nil, peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: id), activateInput: true)
}
}
}
@ -1689,7 +1689,7 @@ final class SharedApplicationContext {
})
}
private func openChatWhenReady(accountId: AccountRecordId?, peerId: PeerId, messageId: MessageId? = nil) {
private func openChatWhenReady(accountId: AccountRecordId?, peerId: PeerId, messageId: MessageId? = nil, activateInput: Bool = false) {
let signal = self.sharedContextPromise.get()
|> take(1)
|> mapToSignal { sharedApplicationContext -> Signal<AuthorizedApplicationContext, NoError> in
@ -1707,7 +1707,7 @@ final class SharedApplicationContext {
}
self.openChatWhenReadyDisposable.set((signal
|> deliverOnMainQueue).start(next: { context in
context.openChatWithPeerId(peerId: peerId, messageId: messageId)
context.openChatWithPeerId(peerId: peerId, messageId: messageId, activateInput: activateInput)
}))
}

View File

@ -58,7 +58,7 @@ final class AuthorizedApplicationContext {
let rootController: TelegramRootController
let notificationController: NotificationContainerController
private var scheduledOperChatWithPeerId: PeerId?
private var scheduledOperChatWithPeerId: (PeerId, MessageId?, Bool)?
private var scheduledOpenExternalUrl: URL?
private let passcodeStatusDisposable = MetaDisposable()
@ -268,9 +268,9 @@ final class AuthorizedApplicationContext {
strongSelf.notificationController.view.isHidden = false
if strongSelf.rootController.rootTabController == nil {
strongSelf.rootController.addRootControllers(showCallsTab: strongSelf.showCallsTab)
if let peerId = strongSelf.scheduledOperChatWithPeerId {
if let (peerId, messageId, activateInput) = strongSelf.scheduledOperChatWithPeerId {
strongSelf.scheduledOperChatWithPeerId = nil
strongSelf.openChatWithPeerId(peerId: peerId)
strongSelf.openChatWithPeerId(peerId: peerId, messageId: messageId, activateInput: activateInput)
}
if let url = strongSelf.scheduledOpenExternalUrl {
@ -782,7 +782,7 @@ final class AuthorizedApplicationContext {
self.permissionsDisposable.dispose()
}
func openChatWithPeerId(peerId: PeerId, messageId: MessageId? = nil) {
func openChatWithPeerId(peerId: PeerId, messageId: MessageId? = nil, activateInput: Bool = false) {
var visiblePeerId: PeerId?
if let controller = self.rootController.topViewController as? ChatController, case let .peer(peerId) = controller.chatLocation {
visiblePeerId = peerId
@ -790,9 +790,9 @@ final class AuthorizedApplicationContext {
if visiblePeerId != peerId || messageId != nil {
if self.rootController.rootTabController != nil {
navigateToChatController(navigationController: self.rootController, context: self.context, chatLocation: .peer(peerId), messageId: messageId)
navigateToChatController(navigationController: self.rootController, context: self.context, chatLocation: .peer(peerId), messageId: messageId, activateInput: activateInput)
} else {
self.scheduledOperChatWithPeerId = peerId
self.scheduledOperChatWithPeerId = (peerId, messageId, activateInput)
}
}
}

View File

@ -294,7 +294,9 @@ private final class ChannelMemberSingleCategoryListContext: ChannelMemberCategor
}
switch self.category {
case let .admins(query):
if let updated = updated, let _ = updated.participant.adminInfo, (query == nil || updated.peer.indexName.matchesByTokens(query!)) {
if let updated = updated, (query == nil || updated.peer.indexName.matchesByTokens(query!)) {
if case let .member(_, _, adminInfo, _) = updated.participant, adminInfo == nil {
} else {
var found = false
loop: for i in 0 ..< list.count {
if list[i].peer.id == updated.peer.id {
@ -308,6 +310,7 @@ private final class ChannelMemberSingleCategoryListContext: ChannelMemberCategor
list.insert(updated, at: 0)
updatedList = true
}
}
} else if let previous = previous, let _ = previous.adminInfo {
loop: for i in 0 ..< list.count {
if list[i].peer.id == previous.peerId {

View File

@ -6769,7 +6769,7 @@ public final class ChatController: TelegramController, GalleryHiddenMediaTarget,
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { state in
return state.updatedInterfaceState { interfaceState in
return interfaceState.withUpdatedEffectiveInputState(interfaceState.effectiveInputState)
}.updatedInputMode({ _ in ChatInputMode.text })
}.updatedInputMode({ _ in .text })
})
}
}),
@ -6780,7 +6780,7 @@ public final class ChatController: TelegramController, GalleryHiddenMediaTarget,
return state.updatedInterfaceState { interfaceState in
let effectiveInputState = ChatTextInputState(inputText: NSAttributedString(string: "/"))
return interfaceState.withUpdatedEffectiveInputState(effectiveInputState)
}.updatedInputMode({ _ in ChatInputMode.text })
}.updatedInputMode({ _ in .text })
} else {
return state
}
@ -6794,7 +6794,7 @@ public final class ChatController: TelegramController, GalleryHiddenMediaTarget,
return state.updatedInterfaceState { interfaceState in
let effectiveInputState = ChatTextInputState(inputText: NSAttributedString(string: "@"))
return interfaceState.withUpdatedEffectiveInputState(effectiveInputState)
}.updatedInputMode({ _ in ChatInputMode.text })
}.updatedInputMode({ _ in .text })
} else {
return state
}
@ -6808,7 +6808,7 @@ public final class ChatController: TelegramController, GalleryHiddenMediaTarget,
return state.updatedInterfaceState { interfaceState in
let effectiveInputState = ChatTextInputState(inputText: NSAttributedString(string: "#"))
return interfaceState.withUpdatedEffectiveInputState(effectiveInputState)
}.updatedInputMode({ _ in ChatInputMode.text })
}.updatedInputMode({ _ in .text })
} else {
return state
}
@ -6886,6 +6886,12 @@ public final class ChatController: TelegramController, GalleryHiddenMediaTarget,
}
}
func activateInput() {
self.updateChatPresentationInterfaceState(animated: true, interactive: true, { state in
return state.updatedInputMode({ _ in .text })
})
}
private func clearInputText() {
self.updateChatPresentationInterfaceState(animated: true, interactive: true, { state in
if !state.interfaceState.effectiveInputState.inputText.string.isEmpty {

View File

@ -166,10 +166,10 @@ class ItemListSectionHeaderItemNode: ListViewItemNode {
}
activityIndicator.isHidden = false
if previousItem != nil {
activityIndicator.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
activityIndicator.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2, removeOnCompletion: false)
}
} else if let activityIndicator = strongSelf.activityIndicator {
activityIndicator.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, completion: { finished in
activityIndicator.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { finished in
if finished {
activityIndicator.isHidden = true
}

View File

@ -10,7 +10,7 @@ public enum NavigateToChatKeepStack {
case never
}
public func navigateToChatController(navigationController: NavigationController, chatController: ChatController? = nil, context: AccountContext, chatLocation: ChatLocation, messageId: MessageId? = nil, botStart: ChatControllerInitialBotStart? = nil, updateTextInputState: ChatTextInputState? = nil, keepStack: NavigateToChatKeepStack = .default, purposefulAction: (() -> Void)? = nil, scrollToEndIfExists: Bool = false, animated: Bool = true, parentGroupId: PeerGroupId? = nil, completion: @escaping () -> Void = {}) {
public func navigateToChatController(navigationController: NavigationController, chatController: ChatController? = nil, context: AccountContext, chatLocation: ChatLocation, messageId: MessageId? = nil, botStart: ChatControllerInitialBotStart? = nil, updateTextInputState: ChatTextInputState? = nil, activateInput: Bool = false, keepStack: NavigateToChatKeepStack = .default, purposefulAction: (() -> Void)? = nil, scrollToEndIfExists: Bool = false, animated: Bool = true, parentGroupId: PeerGroupId? = nil, completion: @escaping () -> Void = {}) {
var found = false
var isFirst = true
for controller in navigationController.viewControllers.reversed() {
@ -35,6 +35,9 @@ public func navigateToChatController(navigationController: NavigationController,
completion()
}
controller.purposefulAction = purposefulAction
if activateInput {
controller.activateInput()
}
found = true
break
}
@ -80,6 +83,9 @@ public func navigateToChatController(navigationController: NavigationController,
navigationController.replaceControllersAndPush(controllers: viewControllers, controller: controller, animated: animated, completion: completion)
}
}
if activateInput {
controller.activateInput()
}
}
navigationController.currentWindow?.forEachController { controller in

View File

@ -253,9 +253,7 @@ final class PeerChannelMemberCategoriesContextsManager {
strongSelf.impl.with { impl in
for (contextPeerId, context) in impl.contexts {
if peerId == contextPeerId {
for (previous, updated) in results {
context.replayUpdates([(previous, updated, nil)])
}
context.replayUpdates(results.map { ($0.0, $0.1, nil) })
}
}
}

View File

@ -245,11 +245,11 @@ private struct PeersNearbyData: Equatable {
}
}
private func peersNearbyControllerEntries(data: PeersNearbyData?, presentationData: PresentationData) -> [PeersNearbyEntry] {
private func peersNearbyControllerEntries(data: PeersNearbyData?, presentationData: PresentationData, displayLoading: Bool) -> [PeersNearbyEntry] {
var entries: [PeersNearbyEntry] = []
entries.append(.header(presentationData.theme, presentationData.strings.PeopleNearby_Description))
entries.append(.usersHeader(presentationData.theme, presentationData.strings.PeopleNearby_Users.uppercased(), data == nil))
entries.append(.usersHeader(presentationData.theme, presentationData.strings.PeopleNearby_Users.uppercased(), displayLoading && data == nil))
if let data = data, !data.users.isEmpty {
var i: Int32 = 0
for user in data.users {
@ -260,7 +260,7 @@ private func peersNearbyControllerEntries(data: PeersNearbyData?, presentationDa
entries.append(.empty(presentationData.theme, presentationData.strings.PeopleNearby_UsersEmpty))
}
entries.append(.groupsHeader(presentationData.theme, presentationData.strings.PeopleNearby_Groups.uppercased(), data == nil))
entries.append(.groupsHeader(presentationData.theme, presentationData.strings.PeopleNearby_Groups.uppercased(), displayLoading && data == nil))
entries.append(.createGroup(presentationData.theme, presentationData.strings.PeopleNearby_CreateGroup, data?.latitude, data?.longitude, data?.address))
if let data = data, !data.groups.isEmpty {
var i: Int32 = 0
@ -376,9 +376,11 @@ public func peersNearbyController(context: AccountContext) -> ViewController {
let previousData = Atomic<PeersNearbyData?>(value: nil)
let signal = combineLatest(context.sharedContext.presentationData, dataPromise.get())
let displayLoading: Signal<Bool, NoError> = .single(false) |> then(.single(true) |> delay(1.0, queue: Queue.mainQueue()))
let signal = combineLatest(context.sharedContext.presentationData, dataPromise.get(), displayLoading)
|> deliverOnMainQueue
|> map { presentationData, data -> (ItemListControllerState, (ItemListNodeState<PeersNearbyEntry>, PeersNearbyEntry.ItemGenerationArguments)) in
|> map { presentationData, data, displayLoading -> (ItemListControllerState, (ItemListNodeState<PeersNearbyEntry>, PeersNearbyEntry.ItemGenerationArguments)) in
let previous = previousData.swap(data)
var crossfade = false
@ -390,7 +392,7 @@ public func peersNearbyController(context: AccountContext) -> ViewController {
}
let controllerState = ItemListControllerState(theme: presentationData.theme, title: .text(presentationData.strings.PeopleNearby_Title), leftNavigationButton: nil, rightNavigationButton: nil, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: true)
let listState = ItemListNodeState(entries: peersNearbyControllerEntries(data: data, presentationData: presentationData), style: .blocks, emptyStateItem: nil, crossfadeState: crossfade, animateChanges: !crossfade, userInteractionEnabled: true)
let listState = ItemListNodeState(entries: peersNearbyControllerEntries(data: data, presentationData: presentationData, displayLoading: displayLoading), style: .blocks, emptyStateItem: nil, crossfadeState: crossfade, animateChanges: !crossfade, userInteractionEnabled: true)
return (controllerState, (listState, arguments))
}

View File

@ -6,7 +6,7 @@ public struct CallListSettings: PreferencesEntry, Equatable {
public var showTab: Bool
public static var defaultSettings: CallListSettings {
return CallListSettings(showTab: false)
return CallListSettings(showTab: true)
}
public init(showTab: Bool) {