-
Notifications
You must be signed in to change notification settings - Fork 22
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: add AutoLayout constraints to make inline messages visible in UIKit app #718
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because queue manager stores data in-memory, I had to make it a singleton. All changes in this commit are to make it a singleton. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ import Foundation | |
import UIKit | ||
|
||
protocol MessageQueueManager: AutoMockable { | ||
var interval: Double { get set } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although I do prefer to use property getter/setters for an API, I found this API to be safer with having the class be a singleton. Here is some sample code with what I mean: // If you use a property getter/setter API:
let queueManager: MessageQueueManager = ... get singleton instance
queueManager.interval = 500
// 🤔 Did we update the shared singleton `inventory` property? Or did we update the `queueManager` local variable, only?
// if we change to getter/setter functions:
MessageQueueManager.singletonInstance.setInventory(500)
// This is much more clear that we are editing the singleton, not a locally scoped instance. |
||
func getInterval() -> Double | ||
func setInterval(_ newInterval: Double) | ||
func setup(skipQueueCheck: Bool) | ||
func fetchUserMessagesFromLocalStore() | ||
func removeMessageFromLocalStore(message: Message) | ||
|
@@ -12,8 +13,9 @@ protocol MessageQueueManager: AutoMockable { | |
} | ||
|
||
// sourcery: InjectRegisterShared = "MessageQueueManager" | ||
// sourcery: InjectSingleton | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class has always been used as a singleton. The whole SDK would use |
||
class MessageQueueManagerImpl: MessageQueueManager { | ||
@Atomic var interval: Double = 600 | ||
@Atomic private var interval: Double = 600 | ||
private var queueTimer: Timer? | ||
|
||
// The local message store is used to keep messages that can't be displayed because the route rule doesnt match and inline messages. | ||
|
@@ -23,6 +25,14 @@ class MessageQueueManagerImpl: MessageQueueManager { | |
DIGraphShared.shared.gist | ||
} | ||
|
||
func getInterval() -> Double { | ||
interval | ||
} | ||
|
||
func setInterval(_ newInterval: Double) { | ||
interval = newInterval | ||
} | ||
|
||
func setup(skipQueueCheck: Bool) { | ||
queueTimer?.invalidate() | ||
queueTimer = nil | ||
|
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.
Changed because
MessageQueueManager
is a singleton now. Use a property getter to get the shared singleton instance.