mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 09:20:08 +00:00
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:
parent
8d723f1c45
commit
f0c60c379d
@ -1641,8 +1641,8 @@ final class SharedApplicationContext {
|
|||||||
} else if let sendMessageIntent = userActivity.interaction?.intent as? INSendMessageIntent {
|
} else if let sendMessageIntent = userActivity.interaction?.intent as? INSendMessageIntent {
|
||||||
if let contact = sendMessageIntent.recipients?.first, let handle = contact.customIdentifier, handle.hasPrefix("tg") {
|
if let contact = sendMessageIntent.recipients?.first, let handle = contact.customIdentifier, handle.hasPrefix("tg") {
|
||||||
let string = handle.suffix(from: handle.index(handle.startIndex, offsetBy: 2))
|
let string = handle.suffix(from: handle.index(handle.startIndex, offsetBy: 2))
|
||||||
if let id = Int32(string), let context = self.contextValue {
|
if let id = Int32(string) {
|
||||||
navigateToChatController(navigationController: context.rootController, context: context.context, chatLocation: .peer(PeerId(namespace: Namespaces.Peer.CloudUser, id: id)))
|
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()
|
let signal = self.sharedContextPromise.get()
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> mapToSignal { sharedApplicationContext -> Signal<AuthorizedApplicationContext, NoError> in
|
|> mapToSignal { sharedApplicationContext -> Signal<AuthorizedApplicationContext, NoError> in
|
||||||
@ -1707,7 +1707,7 @@ final class SharedApplicationContext {
|
|||||||
}
|
}
|
||||||
self.openChatWhenReadyDisposable.set((signal
|
self.openChatWhenReadyDisposable.set((signal
|
||||||
|> deliverOnMainQueue).start(next: { context in
|
|> deliverOnMainQueue).start(next: { context in
|
||||||
context.openChatWithPeerId(peerId: peerId, messageId: messageId)
|
context.openChatWithPeerId(peerId: peerId, messageId: messageId, activateInput: activateInput)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -58,7 +58,7 @@ final class AuthorizedApplicationContext {
|
|||||||
let rootController: TelegramRootController
|
let rootController: TelegramRootController
|
||||||
let notificationController: NotificationContainerController
|
let notificationController: NotificationContainerController
|
||||||
|
|
||||||
private var scheduledOperChatWithPeerId: PeerId?
|
private var scheduledOperChatWithPeerId: (PeerId, MessageId?, Bool)?
|
||||||
private var scheduledOpenExternalUrl: URL?
|
private var scheduledOpenExternalUrl: URL?
|
||||||
|
|
||||||
private let passcodeStatusDisposable = MetaDisposable()
|
private let passcodeStatusDisposable = MetaDisposable()
|
||||||
@ -268,9 +268,9 @@ final class AuthorizedApplicationContext {
|
|||||||
strongSelf.notificationController.view.isHidden = false
|
strongSelf.notificationController.view.isHidden = false
|
||||||
if strongSelf.rootController.rootTabController == nil {
|
if strongSelf.rootController.rootTabController == nil {
|
||||||
strongSelf.rootController.addRootControllers(showCallsTab: strongSelf.showCallsTab)
|
strongSelf.rootController.addRootControllers(showCallsTab: strongSelf.showCallsTab)
|
||||||
if let peerId = strongSelf.scheduledOperChatWithPeerId {
|
if let (peerId, messageId, activateInput) = strongSelf.scheduledOperChatWithPeerId {
|
||||||
strongSelf.scheduledOperChatWithPeerId = nil
|
strongSelf.scheduledOperChatWithPeerId = nil
|
||||||
strongSelf.openChatWithPeerId(peerId: peerId)
|
strongSelf.openChatWithPeerId(peerId: peerId, messageId: messageId, activateInput: activateInput)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let url = strongSelf.scheduledOpenExternalUrl {
|
if let url = strongSelf.scheduledOpenExternalUrl {
|
||||||
@ -782,7 +782,7 @@ final class AuthorizedApplicationContext {
|
|||||||
self.permissionsDisposable.dispose()
|
self.permissionsDisposable.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
func openChatWithPeerId(peerId: PeerId, messageId: MessageId? = nil) {
|
func openChatWithPeerId(peerId: PeerId, messageId: MessageId? = nil, activateInput: Bool = false) {
|
||||||
var visiblePeerId: PeerId?
|
var visiblePeerId: PeerId?
|
||||||
if let controller = self.rootController.topViewController as? ChatController, case let .peer(peerId) = controller.chatLocation {
|
if let controller = self.rootController.topViewController as? ChatController, case let .peer(peerId) = controller.chatLocation {
|
||||||
visiblePeerId = peerId
|
visiblePeerId = peerId
|
||||||
@ -790,9 +790,9 @@ final class AuthorizedApplicationContext {
|
|||||||
|
|
||||||
if visiblePeerId != peerId || messageId != nil {
|
if visiblePeerId != peerId || messageId != nil {
|
||||||
if self.rootController.rootTabController != 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 {
|
} else {
|
||||||
self.scheduledOperChatWithPeerId = peerId
|
self.scheduledOperChatWithPeerId = (peerId, messageId, activateInput)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -294,19 +294,22 @@ private final class ChannelMemberSingleCategoryListContext: ChannelMemberCategor
|
|||||||
}
|
}
|
||||||
switch self.category {
|
switch self.category {
|
||||||
case let .admins(query):
|
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!)) {
|
||||||
var found = false
|
if case let .member(_, _, adminInfo, _) = updated.participant, adminInfo == nil {
|
||||||
loop: for i in 0 ..< list.count {
|
} else {
|
||||||
if list[i].peer.id == updated.peer.id {
|
var found = false
|
||||||
list[i] = updated
|
loop: for i in 0 ..< list.count {
|
||||||
found = true
|
if list[i].peer.id == updated.peer.id {
|
||||||
updatedList = true
|
list[i] = updated
|
||||||
break loop
|
found = true
|
||||||
|
updatedList = true
|
||||||
|
break loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
list.insert(updated, at: 0)
|
||||||
|
updatedList = true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
list.insert(updated, at: 0)
|
|
||||||
updatedList = true
|
|
||||||
}
|
}
|
||||||
} else if let previous = previous, let _ = previous.adminInfo {
|
} else if let previous = previous, let _ = previous.adminInfo {
|
||||||
loop: for i in 0 ..< list.count {
|
loop: for i in 0 ..< list.count {
|
||||||
@ -316,7 +319,7 @@ private final class ChannelMemberSingleCategoryListContext: ChannelMemberCategor
|
|||||||
break loop
|
break loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let updated = updated, case .creator = updated.participant{
|
if let updated = updated, case .creator = updated.participant {
|
||||||
list.insert(updated, at: 0)
|
list.insert(updated, at: 0)
|
||||||
updatedList = true
|
updatedList = true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6769,7 +6769,7 @@ public final class ChatController: TelegramController, GalleryHiddenMediaTarget,
|
|||||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { state in
|
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { state in
|
||||||
return state.updatedInterfaceState { interfaceState in
|
return state.updatedInterfaceState { interfaceState in
|
||||||
return interfaceState.withUpdatedEffectiveInputState(interfaceState.effectiveInputState)
|
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
|
return state.updatedInterfaceState { interfaceState in
|
||||||
let effectiveInputState = ChatTextInputState(inputText: NSAttributedString(string: "/"))
|
let effectiveInputState = ChatTextInputState(inputText: NSAttributedString(string: "/"))
|
||||||
return interfaceState.withUpdatedEffectiveInputState(effectiveInputState)
|
return interfaceState.withUpdatedEffectiveInputState(effectiveInputState)
|
||||||
}.updatedInputMode({ _ in ChatInputMode.text })
|
}.updatedInputMode({ _ in .text })
|
||||||
} else {
|
} else {
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
@ -6794,7 +6794,7 @@ public final class ChatController: TelegramController, GalleryHiddenMediaTarget,
|
|||||||
return state.updatedInterfaceState { interfaceState in
|
return state.updatedInterfaceState { interfaceState in
|
||||||
let effectiveInputState = ChatTextInputState(inputText: NSAttributedString(string: "@"))
|
let effectiveInputState = ChatTextInputState(inputText: NSAttributedString(string: "@"))
|
||||||
return interfaceState.withUpdatedEffectiveInputState(effectiveInputState)
|
return interfaceState.withUpdatedEffectiveInputState(effectiveInputState)
|
||||||
}.updatedInputMode({ _ in ChatInputMode.text })
|
}.updatedInputMode({ _ in .text })
|
||||||
} else {
|
} else {
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
@ -6808,7 +6808,7 @@ public final class ChatController: TelegramController, GalleryHiddenMediaTarget,
|
|||||||
return state.updatedInterfaceState { interfaceState in
|
return state.updatedInterfaceState { interfaceState in
|
||||||
let effectiveInputState = ChatTextInputState(inputText: NSAttributedString(string: "#"))
|
let effectiveInputState = ChatTextInputState(inputText: NSAttributedString(string: "#"))
|
||||||
return interfaceState.withUpdatedEffectiveInputState(effectiveInputState)
|
return interfaceState.withUpdatedEffectiveInputState(effectiveInputState)
|
||||||
}.updatedInputMode({ _ in ChatInputMode.text })
|
}.updatedInputMode({ _ in .text })
|
||||||
} else {
|
} else {
|
||||||
return state
|
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() {
|
private func clearInputText() {
|
||||||
self.updateChatPresentationInterfaceState(animated: true, interactive: true, { state in
|
self.updateChatPresentationInterfaceState(animated: true, interactive: true, { state in
|
||||||
if !state.interfaceState.effectiveInputState.inputText.string.isEmpty {
|
if !state.interfaceState.effectiveInputState.inputText.string.isEmpty {
|
||||||
|
|||||||
@ -166,10 +166,10 @@ class ItemListSectionHeaderItemNode: ListViewItemNode {
|
|||||||
}
|
}
|
||||||
activityIndicator.isHidden = false
|
activityIndicator.isHidden = false
|
||||||
if previousItem != nil {
|
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 {
|
} 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 {
|
if finished {
|
||||||
activityIndicator.isHidden = true
|
activityIndicator.isHidden = true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ public enum NavigateToChatKeepStack {
|
|||||||
case never
|
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 found = false
|
||||||
var isFirst = true
|
var isFirst = true
|
||||||
for controller in navigationController.viewControllers.reversed() {
|
for controller in navigationController.viewControllers.reversed() {
|
||||||
@ -35,6 +35,9 @@ public func navigateToChatController(navigationController: NavigationController,
|
|||||||
completion()
|
completion()
|
||||||
}
|
}
|
||||||
controller.purposefulAction = purposefulAction
|
controller.purposefulAction = purposefulAction
|
||||||
|
if activateInput {
|
||||||
|
controller.activateInput()
|
||||||
|
}
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -80,6 +83,9 @@ public func navigateToChatController(navigationController: NavigationController,
|
|||||||
navigationController.replaceControllersAndPush(controllers: viewControllers, controller: controller, animated: animated, completion: completion)
|
navigationController.replaceControllersAndPush(controllers: viewControllers, controller: controller, animated: animated, completion: completion)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if activateInput {
|
||||||
|
controller.activateInput()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
navigationController.currentWindow?.forEachController { controller in
|
navigationController.currentWindow?.forEachController { controller in
|
||||||
|
|||||||
@ -253,9 +253,7 @@ final class PeerChannelMemberCategoriesContextsManager {
|
|||||||
strongSelf.impl.with { impl in
|
strongSelf.impl.with { impl in
|
||||||
for (contextPeerId, context) in impl.contexts {
|
for (contextPeerId, context) in impl.contexts {
|
||||||
if peerId == contextPeerId {
|
if peerId == contextPeerId {
|
||||||
for (previous, updated) in results {
|
context.replayUpdates(results.map { ($0.0, $0.1, nil) })
|
||||||
context.replayUpdates([(previous, updated, nil)])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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] = []
|
var entries: [PeersNearbyEntry] = []
|
||||||
|
|
||||||
entries.append(.header(presentationData.theme, presentationData.strings.PeopleNearby_Description))
|
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 {
|
if let data = data, !data.users.isEmpty {
|
||||||
var i: Int32 = 0
|
var i: Int32 = 0
|
||||||
for user in data.users {
|
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(.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))
|
entries.append(.createGroup(presentationData.theme, presentationData.strings.PeopleNearby_CreateGroup, data?.latitude, data?.longitude, data?.address))
|
||||||
if let data = data, !data.groups.isEmpty {
|
if let data = data, !data.groups.isEmpty {
|
||||||
var i: Int32 = 0
|
var i: Int32 = 0
|
||||||
@ -376,9 +376,11 @@ public func peersNearbyController(context: AccountContext) -> ViewController {
|
|||||||
|
|
||||||
let previousData = Atomic<PeersNearbyData?>(value: nil)
|
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
|
|> 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)
|
let previous = previousData.swap(data)
|
||||||
|
|
||||||
var crossfade = false
|
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 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))
|
return (controllerState, (listState, arguments))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ public struct CallListSettings: PreferencesEntry, Equatable {
|
|||||||
public var showTab: Bool
|
public var showTab: Bool
|
||||||
|
|
||||||
public static var defaultSettings: CallListSettings {
|
public static var defaultSettings: CallListSettings {
|
||||||
return CallListSettings(showTab: false)
|
return CallListSettings(showTab: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(showTab: Bool) {
|
public init(showTab: Bool) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user