Digital PCT265 story PCT-135: Revert onPageNew signature change.

This commit is contained in:
Hedden, Kyle Matthew 2024-05-20 23:16:16 -04:00
parent d377ec84b7
commit 75104dbe4d
3 changed files with 9 additions and 7 deletions

View File

@ -261,9 +261,8 @@ open class AccessibilityHandlerBehavior: PageVisibilityBehavior, PageMoleculeTra
accessibilityHandler = AccessibilityHandler.shared() //Protocol Mandatory init method.
}
open func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) -> [MoleculeModelProtocol]? {
open func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) {
accessibilityHandler?.onPageNew(rootMolecules: rootMolecules, delegateObject)
return nil
}
open func willShowPage(_ delegateObject: MVMCoreUIDelegateObject?) {

View File

@ -263,6 +263,9 @@ import MVMCore
if let replaced = try? newTemplateModel.replaceChildMolecule(with: molecule) {
// Only recognize the molecules that actually changed.
debugLog("Behavior updated \(changes) in template model.")
changes = changes.filter({ model in
behaviorUpdatedModels.contains { $0.id == model.id }
})
behaviorUpdatedModels.append(contentsOf: changes)
} else {
debugLog("Failed to replace \(molecule) in the template model.")

View File

@ -30,7 +30,7 @@ public extension PageBehaviorProtocol {
*/
public protocol PageMoleculeTransformationBehavior: PageBehaviorProtocol {
func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) -> [MoleculeModelProtocol]?
func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?)
func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?, changes: inout [MoleculeModelProtocol]) -> [MoleculeModelProtocol]?
func willSetupMolecule(with model: MoleculeModelProtocol, updating view: MoleculeViewProtocol?)
func didSetupMolecule(view: MoleculeViewProtocol, withModel: MoleculeModelProtocol)
@ -42,11 +42,11 @@ public protocol PageMoleculeTransformationBehavior: PageBehaviorProtocol {
public extension PageMoleculeTransformationBehavior {
// All optional.
func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) -> [MoleculeModelProtocol]? {
var changes = [any MoleculeModelProtocol]()
return onPageNew(rootMolecules: rootMolecules, delegateObject, changes: &changes)
func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) {}
func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?, changes: inout [MoleculeModelProtocol]) -> [MoleculeModelProtocol]? {
onPageNew(rootMolecules: rootMolecules, delegateObject) // Call the original signature.
return nil // Don't return any tranformations.
}
func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?, changes: inout [MoleculeModelProtocol]) -> [MoleculeModelProtocol]? { return nil }
func willSetupMolecule(with model: MoleculeModelProtocol, updating view: MoleculeViewProtocol?) {}
func didSetupMolecule(view: MoleculeViewProtocol, withModel: MoleculeModelProtocol) {}
func willSetupNavigationBar(with model: NavigationItemModelProtocol, updating view: UINavigationBar) {}