mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Storage calculation
This commit is contained in:
@@ -141,6 +141,7 @@ public final class ComponentView<EnvironmentType> {
|
||||
private var currentSize: CGSize?
|
||||
public private(set) var view: UIView?
|
||||
private(set) var isUpdating: Bool = false
|
||||
public weak var parentState: ComponentState?
|
||||
|
||||
public init() {
|
||||
}
|
||||
@@ -181,10 +182,15 @@ public final class ComponentView<EnvironmentType> {
|
||||
context.erasedEnvironment = environmentResult
|
||||
}
|
||||
|
||||
let isEnvironmentUpdated = context.erasedEnvironment.calculateIsUpdated()
|
||||
|
||||
var isStateUpdated = false
|
||||
if componentState.isUpdated {
|
||||
isStateUpdated = true
|
||||
componentState.isUpdated = false
|
||||
}
|
||||
|
||||
if !forceUpdate, !isEnvironmentUpdated, let currentComponent = self.currentComponent, let currentContainerSize = self.currentContainerSize, let currentSize = self.currentSize {
|
||||
let isEnvironmentUpdated = context.erasedEnvironment.calculateIsUpdated()
|
||||
|
||||
if !forceUpdate, !isEnvironmentUpdated, !isStateUpdated, let currentComponent = self.currentComponent, let currentContainerSize = self.currentContainerSize, let currentSize = self.currentSize {
|
||||
if currentContainerSize == containerSize && currentComponent == component {
|
||||
self.isUpdating = false
|
||||
return currentSize
|
||||
@@ -197,9 +203,13 @@ public final class ComponentView<EnvironmentType> {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
let _ = strongSelf._update(transition: transition, component: component, maybeEnvironment: {
|
||||
preconditionFailure()
|
||||
} as () -> Environment<EnvironmentType>, updateEnvironment: false, forceUpdate: true, containerSize: containerSize)
|
||||
if let parentState = strongSelf.parentState {
|
||||
parentState.updated(transition: transition)
|
||||
} else {
|
||||
let _ = strongSelf._update(transition: transition, component: component, maybeEnvironment: {
|
||||
preconditionFailure()
|
||||
} as () -> Environment<EnvironmentType>, updateEnvironment: false, forceUpdate: true, containerSize: containerSize)
|
||||
}
|
||||
}
|
||||
|
||||
let updatedSize = component._update(view: componentView, availableSize: containerSize, environment: context.erasedEnvironment, transition: transition)
|
||||
@@ -207,6 +217,9 @@ public final class ComponentView<EnvironmentType> {
|
||||
if isEnvironmentUpdated {
|
||||
context.erasedEnvironment._isUpdated = false
|
||||
}
|
||||
if isStateUpdated {
|
||||
context.erasedState.isUpdated = false
|
||||
}
|
||||
|
||||
self.isUpdating = false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user