mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-09 02:03:43 +00:00
Chat import fixes
This commit is contained in:
parent
e169107a9e
commit
6e545763df
@ -191,7 +191,7 @@ public final class ChatImportActivityScreen: ViewController {
|
|||||||
|
|
||||||
if let (layout, navigationHeight) = self.validLayout {
|
if let (layout, navigationHeight) = self.validLayout {
|
||||||
self.containerLayoutUpdated(layout, navigationHeight: navigationHeight, transition: .immediate)
|
self.containerLayoutUpdated(layout, navigationHeight: navigationHeight, transition: .immediate)
|
||||||
self.radialStatus.transitionToState(.progress(color: self.presentationData.theme.list.itemAccentColor, lineWidth: 6.0, value: self.totalProgress, cancelEnabled: false), animated: animated, synchronous: true, completion: {})
|
self.radialStatus.transitionToState(.progress(color: self.presentationData.theme.list.itemAccentColor, lineWidth: 6.0, value: max(0.09, self.totalProgress), cancelEnabled: false), animated: animated, synchronous: true, completion: {})
|
||||||
if isDone {
|
if isDone {
|
||||||
self.radialCheck.transitionToState(.progress(color: .clear, lineWidth: 6.0, value: self.totalProgress, cancelEnabled: false), animated: false, synchronous: true, completion: {})
|
self.radialCheck.transitionToState(.progress(color: .clear, lineWidth: 6.0, value: self.totalProgress, cancelEnabled: false), animated: false, synchronous: true, completion: {})
|
||||||
self.radialCheck.transitionToState(.check(self.presentationData.theme.list.itemAccentColor), animated: animated, synchronous: true, completion: {})
|
self.radialCheck.transitionToState(.check(self.presentationData.theme.list.itemAccentColor), animated: animated, synchronous: true, completion: {})
|
||||||
@ -283,6 +283,10 @@ public final class ChatImportActivityScreen: ViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.beginImport()
|
self.beginImport()
|
||||||
|
|
||||||
|
if let application = UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication {
|
||||||
|
application.isIdleTimerDisabled = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(coder aDecoder: NSCoder) {
|
required public init(coder aDecoder: NSCoder) {
|
||||||
@ -291,6 +295,10 @@ public final class ChatImportActivityScreen: ViewController {
|
|||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
self.disposable.dispose()
|
self.disposable.dispose()
|
||||||
|
|
||||||
|
if let application = UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication {
|
||||||
|
application.isIdleTimerDisabled = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func cancelPressed() {
|
@objc private func cancelPressed() {
|
||||||
@ -406,6 +414,10 @@ public final class ChatImportActivityScreen: ViewController {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
strongSelf.controllerNode.updateProgress(totalProgress: 1.0, isDone: true, animated: true)
|
strongSelf.controllerNode.updateProgress(totalProgress: 1.0, isDone: true, animated: true)
|
||||||
|
|
||||||
|
if let application = UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication {
|
||||||
|
application.isIdleTimerDisabled = false
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2202,6 +2202,50 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||||||
items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: mainPeer, chatPeer: chatPeer, action: .delete, strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder))
|
items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: mainPeer, chatPeer: chatPeer, action: .delete, strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder))
|
||||||
|
|
||||||
if canClear {
|
if canClear {
|
||||||
|
let beginClear: (InteractiveHistoryClearingType) -> Void = { type in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
strongSelf.chatListDisplayNode.containerNode.updateState({ state in
|
||||||
|
var state = state
|
||||||
|
state.pendingClearHistoryPeerIds.insert(peer.peerId)
|
||||||
|
return state
|
||||||
|
})
|
||||||
|
strongSelf.forEachController({ controller in
|
||||||
|
if let controller = controller as? UndoOverlayController {
|
||||||
|
controller.dismissWithCommitActionAndReplacementAnimation()
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
|
strongSelf.present(UndoOverlayController(presentationData: strongSelf.context.sharedContext.currentPresentationData.with { $0 }, content: .removedChat(text: strongSelf.presentationData.strings.Undo_ChatCleared), elevatedLayout: false, animateInAsReplacement: true, action: { value in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if value == .commit {
|
||||||
|
let _ = clearHistoryInteractively(postbox: strongSelf.context.account.postbox, peerId: peerId, type: type).start(completed: {
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
strongSelf.chatListDisplayNode.containerNode.updateState({ state in
|
||||||
|
var state = state
|
||||||
|
state.pendingClearHistoryPeerIds.remove(peer.peerId)
|
||||||
|
return state
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return true
|
||||||
|
} else if value == .undo {
|
||||||
|
strongSelf.chatListDisplayNode.containerNode.updateState({ state in
|
||||||
|
var state = state
|
||||||
|
state.pendingClearHistoryPeerIds.remove(peer.peerId)
|
||||||
|
return state
|
||||||
|
})
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}), in: .current)
|
||||||
|
}
|
||||||
|
|
||||||
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.DialogList_ClearHistoryConfirmation, color: .accent, action: { [weak actionSheet] in
|
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.DialogList_ClearHistoryConfirmation, color: .accent, action: { [weak actionSheet] in
|
||||||
actionSheet?.dismissAnimated()
|
actionSheet?.dismissAnimated()
|
||||||
|
|
||||||
@ -2209,89 +2253,49 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let beginClear: (InteractiveHistoryClearingType) -> Void = { type in
|
if chatPeer is TelegramSecretChat {
|
||||||
guard let strongSelf = self else {
|
beginClear(.forEveryone)
|
||||||
return
|
|
||||||
}
|
|
||||||
strongSelf.chatListDisplayNode.containerNode.updateState({ state in
|
|
||||||
var state = state
|
|
||||||
state.pendingClearHistoryPeerIds.insert(peer.peerId)
|
|
||||||
return state
|
|
||||||
})
|
|
||||||
strongSelf.forEachController({ controller in
|
|
||||||
if let controller = controller as? UndoOverlayController {
|
|
||||||
controller.dismissWithCommitActionAndReplacementAnimation()
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
strongSelf.present(UndoOverlayController(presentationData: strongSelf.context.sharedContext.currentPresentationData.with { $0 }, content: .removedChat(text: strongSelf.presentationData.strings.Undo_ChatCleared), elevatedLayout: false, animateInAsReplacement: true, action: { value in
|
|
||||||
guard let strongSelf = self else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if value == .commit {
|
|
||||||
let _ = clearHistoryInteractively(postbox: strongSelf.context.account.postbox, peerId: peerId, type: type).start(completed: {
|
|
||||||
guard let strongSelf = self else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
strongSelf.chatListDisplayNode.containerNode.updateState({ state in
|
|
||||||
var state = state
|
|
||||||
state.pendingClearHistoryPeerIds.remove(peer.peerId)
|
|
||||||
return state
|
|
||||||
})
|
|
||||||
})
|
|
||||||
return true
|
|
||||||
} else if value == .undo {
|
|
||||||
strongSelf.chatListDisplayNode.containerNode.updateState({ state in
|
|
||||||
var state = state
|
|
||||||
state.pendingClearHistoryPeerIds.remove(peer.peerId)
|
|
||||||
return state
|
|
||||||
})
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}), in: .current)
|
|
||||||
}
|
|
||||||
|
|
||||||
if canRemoveGlobally {
|
|
||||||
let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData)
|
|
||||||
var items: [ActionSheetItem] = []
|
|
||||||
|
|
||||||
items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: mainPeer, chatPeer: chatPeer, action: .clearHistory, strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder))
|
|
||||||
|
|
||||||
if joined || mainPeer.isDeleted {
|
|
||||||
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Delete, color: .destructive, action: { [weak actionSheet] in
|
|
||||||
beginClear(.forEveryone)
|
|
||||||
actionSheet?.dismissAnimated()
|
|
||||||
}))
|
|
||||||
} else {
|
|
||||||
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.ChatList_DeleteForEveryone(mainPeer.compactDisplayTitle).0, color: .destructive, action: { [weak actionSheet] in
|
|
||||||
beginClear(.forEveryone)
|
|
||||||
actionSheet?.dismissAnimated()
|
|
||||||
}))
|
|
||||||
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.ChatList_DeleteForCurrentUser, color: .destructive, action: { [weak actionSheet] in
|
|
||||||
beginClear(.forLocalPeer)
|
|
||||||
actionSheet?.dismissAnimated()
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
actionSheet.setItemGroups([
|
|
||||||
ActionSheetItemGroup(items: items),
|
|
||||||
ActionSheetItemGroup(items: [
|
|
||||||
ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
|
|
||||||
actionSheet?.dismissAnimated()
|
|
||||||
})
|
|
||||||
])
|
|
||||||
])
|
|
||||||
strongSelf.present(actionSheet, in: .window(.root))
|
|
||||||
} else {
|
} else {
|
||||||
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: strongSelf.presentationData.strings.ChatList_DeleteSavedMessagesConfirmationTitle, text: strongSelf.presentationData.strings.ChatList_DeleteSavedMessagesConfirmationText, actions: [
|
if canRemoveGlobally {
|
||||||
TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_Cancel, action: {
|
let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData)
|
||||||
}),
|
var items: [ActionSheetItem] = []
|
||||||
TextAlertAction(type: .destructiveAction, title: strongSelf.presentationData.strings.ChatList_DeleteSavedMessagesConfirmationAction, action: {
|
|
||||||
beginClear(.forLocalPeer)
|
items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: mainPeer, chatPeer: chatPeer, action: .clearHistory, strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder))
|
||||||
})
|
|
||||||
], parseMarkdown: true), in: .window(.root))
|
if joined || mainPeer.isDeleted {
|
||||||
|
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Delete, color: .destructive, action: { [weak actionSheet] in
|
||||||
|
beginClear(.forEveryone)
|
||||||
|
actionSheet?.dismissAnimated()
|
||||||
|
}))
|
||||||
|
} else {
|
||||||
|
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.ChatList_DeleteForEveryone(mainPeer.compactDisplayTitle).0, color: .destructive, action: { [weak actionSheet] in
|
||||||
|
beginClear(.forEveryone)
|
||||||
|
actionSheet?.dismissAnimated()
|
||||||
|
}))
|
||||||
|
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.ChatList_DeleteForCurrentUser, color: .destructive, action: { [weak actionSheet] in
|
||||||
|
beginClear(.forLocalPeer)
|
||||||
|
actionSheet?.dismissAnimated()
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
actionSheet.setItemGroups([
|
||||||
|
ActionSheetItemGroup(items: items),
|
||||||
|
ActionSheetItemGroup(items: [
|
||||||
|
ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
|
||||||
|
actionSheet?.dismissAnimated()
|
||||||
|
})
|
||||||
|
])
|
||||||
|
])
|
||||||
|
strongSelf.present(actionSheet, in: .window(.root))
|
||||||
|
} else {
|
||||||
|
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: strongSelf.presentationData.strings.ChatList_DeleteSavedMessagesConfirmationTitle, text: strongSelf.presentationData.strings.ChatList_DeleteSavedMessagesConfirmationText, actions: [
|
||||||
|
TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_Cancel, action: {
|
||||||
|
}),
|
||||||
|
TextAlertAction(type: .destructiveAction, title: strongSelf.presentationData.strings.ChatList_DeleteSavedMessagesConfirmationAction, action: {
|
||||||
|
beginClear(.forLocalPeer)
|
||||||
|
})
|
||||||
|
], parseMarkdown: true), in: .window(.root))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,7 +48,18 @@ final class ChatMessageAvatarAccessoryItem: ListViewAccessoryItem {
|
|||||||
if self.day != other.day {
|
if self.day != other.day {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if abs(other.messageTimestamp - self.messageTimestamp) >= 10 * 60 {
|
|
||||||
|
var effectiveTimestamp = self.messageTimestamp
|
||||||
|
if let forwardInfo = self.forwardInfo, forwardInfo.flags.contains(.isImported) {
|
||||||
|
effectiveTimestamp = forwardInfo.date
|
||||||
|
}
|
||||||
|
|
||||||
|
var effectiveOtherTimestamp = other.messageTimestamp
|
||||||
|
if let otherForwardInfo = other.forwardInfo, otherForwardInfo.flags.contains(.isImported) {
|
||||||
|
effectiveOtherTimestamp = otherForwardInfo.date
|
||||||
|
}
|
||||||
|
|
||||||
|
if abs(effectiveTimestamp - effectiveOtherTimestamp) >= 10 * 60 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if let forwardInfo = self.forwardInfo, let otherForwardInfo = other.forwardInfo {
|
if let forwardInfo = self.forwardInfo, let otherForwardInfo = other.forwardInfo {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user