Chat import fixes

This commit is contained in:
Ali 2021-01-22 18:55:50 +04:00
parent e169107a9e
commit 6e545763df
3 changed files with 111 additions and 84 deletions

View File

@ -191,7 +191,7 @@ public final class ChatImportActivityScreen: ViewController {
if let (layout, navigationHeight) = self.validLayout {
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 {
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: {})
@ -283,6 +283,10 @@ public final class ChatImportActivityScreen: ViewController {
}
self.beginImport()
if let application = UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication {
application.isIdleTimerDisabled = true
}
}
required public init(coder aDecoder: NSCoder) {
@ -291,6 +295,10 @@ public final class ChatImportActivityScreen: ViewController {
deinit {
self.disposable.dispose()
if let application = UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication {
application.isIdleTimerDisabled = false
}
}
@objc private func cancelPressed() {
@ -406,6 +414,10 @@ public final class ChatImportActivityScreen: ViewController {
return
}
strongSelf.controllerNode.updateProgress(totalProgress: 1.0, isDone: true, animated: true)
if let application = UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication {
application.isIdleTimerDisabled = false
}
}))
}
}

View File

@ -2202,13 +2202,6 @@ 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))
if canClear {
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.DialogList_ClearHistoryConfirmation, color: .accent, action: { [weak actionSheet] in
actionSheet?.dismissAnimated()
guard let strongSelf = self else {
return
}
let beginClear: (InteractiveHistoryClearingType) -> Void = { type in
guard let strongSelf = self else {
return
@ -2253,6 +2246,16 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
}), in: .current)
}
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.DialogList_ClearHistoryConfirmation, color: .accent, action: { [weak actionSheet] in
actionSheet?.dismissAnimated()
guard let strongSelf = self else {
return
}
if chatPeer is TelegramSecretChat {
beginClear(.forEveryone)
} else {
if canRemoveGlobally {
let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData)
var items: [ActionSheetItem] = []
@ -2293,6 +2296,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
})
], parseMarkdown: true), in: .window(.root))
}
}
}))
}

View File

@ -48,7 +48,18 @@ final class ChatMessageAvatarAccessoryItem: ListViewAccessoryItem {
if self.day != other.day {
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
}
if let forwardInfo = self.forwardInfo, let otherForwardInfo = other.forwardInfo {