Skip to content

Commit dd70511

Browse files
authored
Fix performActions when message open action is inserted (#504)
1 parent 6d38528 commit dd70511

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

LeanplumSDK/LeanplumSDK/Classes/Features/Actions/LPActionContext.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,6 @@ - (void)runActionNamed:(NSString *)name
494494
childContext->_key = name;
495495
dispatch_async(dispatch_get_main_queue(), ^{
496496
[[LPActionManager shared] triggerWithContexts:@[childContext] priority:PriorityHigh trigger:nil];
497-
498497
});
499498
}
500499

LeanplumSDK/LeanplumSDK/ClassesSwift/Actions/ActionManager+Queue.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,8 @@ import Foundation
1010
extension ActionManager {
1111
final class Queue {
1212
let lock = DispatchQueue(label: "leanplum.access_dispatch_queue", attributes: .concurrent)
13-
var didChange: (() -> Void)?
14-
var queue: [Action] = [] {
15-
didSet {
16-
DispatchQueue.main.async {
17-
self.didChange?()
18-
}
19-
}
20-
}
21-
13+
var queue: [Action] = []
14+
2215
func pushBack(_ item: Action) {
2316
lock.async(flags: .barrier) {
2417
self.queue.append(item)

LeanplumSDK/LeanplumSDK/ClassesSwift/Actions/ActionManager.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ import Foundation
4646

4747
override init() {
4848
super.init()
49-
queue.didChange = {
50-
self.performAvailableActions()
51-
}
5249
scheduler.actionDelayed = {
5350
self.appendActions(actions: [$0])
5451
}
@@ -113,7 +110,9 @@ import Foundation
113110
func performAvailableActions() {
114111
Log.debug("[ActionManager]: performing all available actions.")
115112
Leanplum.onceVariablesChangedAndNoDownloadsPending {
116-
self.performActions()
113+
DispatchQueue.main.async {
114+
self.performActions()
115+
}
117116
}
118117
}
119118
}
@@ -123,6 +122,7 @@ extension ActionManager {
123122
func appendActions(actions: [Action]) {
124123
guard isEnabled else { return }
125124
actions.forEach(queue.pushBack(_:))
125+
performAvailableActions()
126126
}
127127

128128
/// Adds action to front of the queue
@@ -131,5 +131,6 @@ extension ActionManager {
131131
actions
132132
.reversed()
133133
.forEach(queue.pushFront(_:))
134+
performAvailableActions()
134135
}
135136
}

0 commit comments

Comments
 (0)