Skip to content

Commit

Permalink
Merge pull request #26 from plaidev/android-1
Browse files Browse the repository at this point in the history
[ios] fix bug: compile event in a block context
  • Loading branch information
RyosukeCla committed Mar 25, 2024
2 parents afe6935 + 98a4f22 commit ca69e58
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Nativebrik.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Nativebrik'
s.version = '0.5.3'
s.version = '0.5.4'
s.summary = 'Nativebrik SDK'
s.description = <<-DESC
Nativebrik SDK for iOS.
Expand Down
20 changes: 19 additions & 1 deletion ios/Nativebrik/Nativebrik/component/action-listener.swift
Expand Up @@ -52,7 +52,25 @@ func configureOnClickGesture(target: UIView, action: Selector, context: UIBlockC
let gesture = ClickListener(target: target, action: action)
gesture.onClick = {
if let event = event {
context.dipatch(event: event)
let variable = context.getVariable()
let deepLink = event.deepLink
let name = event.name
let compiledEvent = UIBlockEventDispatcher(
name: (name != nil) ? compile(name ?? "", variable) : nil,
destinationPageId: event.destinationPageId,
deepLink: (deepLink != nil) ? compile(deepLink ?? "", variable) : nil,
payload: event.payload?.map({ prop in
return Property(
name: prop.name ?? "",
value: compile(prop.value ?? "", variable),
ptype: prop.ptype ?? PropertyType.STRING
)
}),
httpRequest: event.httpRequest,
httpResponseAssertion: event.httpResponseAssertion
)

context.dipatch(event: compiledEvent)
}
}
if event != nil {
Expand Down
24 changes: 3 additions & 21 deletions ios/Nativebrik/Nativebrik/component/page.swift
Expand Up @@ -141,32 +141,14 @@ class PageView: UIView {
base: self?.data,
self?.container.createVariableForTemplate(data: nil, properties: self?.props)
)

// compile event
let deepLink = dispatchedEvent.deepLink
let name = dispatchedEvent.name
let compiledEvent = UIBlockEventDispatcher(
name: (name != nil) ? compile(name ?? "", variable) : nil,
destinationPageId: dispatchedEvent.destinationPageId,
deepLink: (deepLink != nil) ? compile(deepLink ?? "", variable) : nil,
payload: dispatchedEvent.payload?.map({ prop in
return Property(
name: prop.name ?? "",
value: compile(prop.value ?? "", variable),
ptype: prop.ptype ?? PropertyType.STRING
)
}),
httpRequest: dispatchedEvent.httpRequest,
httpResponseAssertion: dispatchedEvent.httpResponseAssertion
)

let assertion = compiledEvent.httpResponseAssertion
let assertion = dispatchedEvent.httpResponseAssertion
let handleEvent = { () -> () in
DispatchQueue.main.async {
parentEventManager?.dispatch(event: compiledEvent)
parentEventManager?.dispatch(event: dispatchedEvent)
}
}
if let httpRequest = compiledEvent.httpRequest {
if let httpRequest = dispatchedEvent.httpRequest {
Task {
Task.detached { [weak self] in
let result = await self?.container.sendHttpRequest(
Expand Down
2 changes: 1 addition & 1 deletion ios/Nativebrik/Nativebrik/sdk.swift
Expand Up @@ -9,7 +9,7 @@ import Foundation
import SwiftUI
import Combine

public let nativebrikSdkVersion = "0.5.3"
public let nativebrikSdkVersion = "0.5.4"
public let isNativebrikAvailable: Bool = {
if #available(iOS 15.0, *) {
return true
Expand Down

0 comments on commit ca69e58

Please sign in to comment.