Add the ability to share logs before the UI loads

This commit is contained in:
Ali 2021-04-01 01:13:34 +04:00
parent fd1bf9eddb
commit 1a2ae61be4
3 changed files with 49 additions and 1 deletions

View File

@ -270,8 +270,42 @@ public class Window1 {
private var shouldNotAnimateLikelyKeyboardAutocorrectionSwitch: Bool = false
public private(set) var forceInCallStatusBarText: String? = nil
public var inCallNavigate: (() -> Void)? {
public var inCallNavigate: (() -> Void)?
private var debugTapCounter: (Double, Int) = (0.0, 0)
private var debugTapRecognizer: UITapGestureRecognizer?
public var debugAction: (() -> Void)? {
didSet {
if self.debugAction != nil {
if self.debugTapRecognizer == nil {
let debugTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.debugTapGesture(_:)))
self.debugTapRecognizer = debugTapRecognizer
self.hostView.containerView.addGestureRecognizer(debugTapRecognizer)
}
} else if let debugTapRecognizer = self.debugTapRecognizer {
self.debugTapRecognizer = nil
self.hostView.containerView.removeGestureRecognizer(debugTapRecognizer)
}
}
}
@objc private func debugTapGesture(_ recognizer: UITapGestureRecognizer) {
if case .ended = recognizer.state {
let timestamp = CACurrentMediaTime()
if self.debugTapCounter.0 < timestamp - 0.4 {
self.debugTapCounter.0 = timestamp
self.debugTapCounter.1 = 0
}
if self.debugTapCounter.0 >= timestamp - 0.4 {
self.debugTapCounter.0 = timestamp
self.debugTapCounter.1 += 1
}
if self.debugTapCounter.1 >= 10 {
self.debugTapCounter.1 = 0
self.debugAction?()
}
}
}

View File

@ -1406,6 +1406,8 @@ public final class Postbox {
self.basePath = basePath
self.seedConfiguration = seedConfiguration
self.tempDir = tempDir
sleep(1)
print("MediaBox path: \(self.basePath + "/media")")

View File

@ -33,6 +33,7 @@ import AccountUtils
import CoreSpotlight
import LightweightAccountData
import TelegramAudio
import DebugSettingsUI
#if canImport(BackgroundTasks)
import BackgroundTasks
@ -813,6 +814,15 @@ final class SharedApplicationContext {
}
}
})
self.mainWindow.debugAction = {
self.mainWindow.debugAction = nil
let presentationData = sharedContext.currentPresentationData.with { $0 }
let navigationController = NavigationController(mode: .single, theme: NavigationControllerTheme(presentationTheme: presentationData.theme))
navigationController.viewControllers = [debugController(sharedContext: sharedContext, context: nil)]
self.mainWindow.present(navigationController, on: .root)
}
presentationDataPromise.set(sharedContext.presentationData)
@ -1083,6 +1093,8 @@ final class SharedApplicationContext {
print("Application: context took \(readyTime) to become ready")
}
print("Launch to ready took \((CFAbsoluteTimeGetCurrent() - launchStartTime) * 1000.0) ms")
self.mainWindow.debugAction = nil
self.mainWindow.viewController = context.rootController
if firstTime {