-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: refactor in-app queue classes #802
chore: refactor in-app queue classes #802
Conversation
Sample app builds 📱Below you will find the list of the latest versions of the sample apps. It's recommended to always download the latest builds of the sample apps to accurately test the pull request.
|
266122d
to
37f042f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the looks of it seems like we are not reliant on event listener added by the customer and even the journey actions won't be triggered if that's not provided, which shouldn't be the way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed on call, callbacks should work, now its down to suggestions only
7808f2a
to
4e398a6
Compare
37f042f
to
dcef79d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, added few suggestions
subscribeToInAppMessageState() | ||
} | ||
|
||
func subscribeToInAppMessageState() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this method simplified? i understand whats happening here, but looks very messy.
private var isMessageEmbed: Bool = false | ||
private var messagePosition: MessagePosition = .center | ||
|
||
private var inAppMessageStoreSubscriber: InAppMessageStoreSubscriber? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of store, can we keep a strong reference of the subscription? would that resolve the need to keep strong reference?
private var subscription: Task<Void, Never>?
func subscribeToInAppMessageState() { | ||
inAppMessageStoreSubscriber = InAppMessageStoreSubscriber { [self] state in | ||
switch state.currentMessageState { | ||
case .displayed: | ||
threadUtil.runMain { | ||
self.loadModalMessage() | ||
} | ||
|
||
case .dismissed: | ||
threadUtil.runMain { | ||
self.engine.delegate = nil | ||
self.dismissMessage() | ||
self.inAppMessageStoreSubscriber = nil | ||
} | ||
|
||
default: | ||
break | ||
} | ||
} | ||
if let subscriber = inAppMessageStoreSubscriber { | ||
inAppMessageManager.subscribe(keyPath: \.currentMessageState, subscriber: subscriber) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func subscribeToInAppMessageState() { | |
inAppMessageStoreSubscriber = InAppMessageStoreSubscriber { [self] state in | |
switch state.currentMessageState { | |
case .displayed: | |
threadUtil.runMain { | |
self.loadModalMessage() | |
} | |
case .dismissed: | |
threadUtil.runMain { | |
self.engine.delegate = nil | |
self.dismissMessage() | |
self.inAppMessageStoreSubscriber = nil | |
} | |
default: | |
break | |
} | |
} | |
if let subscriber = inAppMessageStoreSubscriber { | |
inAppMessageManager.subscribe(keyPath: \.currentMessageState, subscriber: subscriber) | |
} | |
func subscribeToInAppMessagdeState() { | |
let subscriber = InAppMessageStoreSubscriber { [self] state in | |
switch state.currentMessageState { | |
case .displayed: | |
self.threadUtil.runMain { | |
self.loadModalMessage() | |
} | |
case .dismissed: | |
self.threadUtil.runMain { | |
self.engine.delegate = nil | |
self.dismissMessage() | |
self.subscription = nil | |
} | |
default: | |
break | |
} | |
} | |
subscription = inAppMessageManager.subscribe(keyPath: \.currentMessageState, subscriber: subscriber) | |
} |
if keeping the reference of subscription works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed on call, we'll merge this for now and think later more on this later
if let modalViewManager = modalViewManager { | ||
modalViewManager.dismissModalView { [weak self] in | ||
guard let self = self else { return } | ||
self.delegate?.messageDismissed(message: self.currentMessage) | ||
guard let _ = self else { return } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are not using self, is there any benefit of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed on call, will be merging this as it looks okay
part of MBL-480
closes MBL-487
Changes
Gist
,MessageManager
, andQueueManager
classes to use the newly added state and managerGist
,MessageManager
, andQueueManager
toDiGraph