Skip to content

Commit

Permalink
fix: crash when switching screens frequently (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahroz16 authored Oct 1, 2024
1 parent 8db6293 commit 62268a4
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions Sources/MessagingInApp/State/InAppMessageMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,14 @@ import Foundation
private func middleware(
completion: @escaping MiddlewareCompletion
) -> InAppMessageMiddleware {
{ _,
{ dispatch,
// swiftlint:disable:next closure_parameter_position
getState in {
// swiftlint:disable:next closure_parameter_position
next in {
// swiftlint:disable:next closure_parameter_position
action in
let getStateOrDefault = { getState() ?? InAppMessageState() }
// Use dispatch from InAppMessageManager so that next action is queued in correct order and dispatched
// only after the current action is processed
// Ideally, we should have dispatch as a parameter with completion, but we'll keep it simple for now
let dispatch: DispatchFunction = { action in
DIGraphShared.shared.inAppMessageManager.dispatch(action: action)
}
completion(dispatch, getStateOrDefault, next, action)
}
}
Expand Down

0 comments on commit 62268a4

Please sign in to comment.