Skip to content

Commit 18e45aa

Browse files
committed
BUGFIX: MessageDisplayer was broken
1 parent cbc5ac6 commit 18e45aa

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

Lifting Buddy/AppDelegate.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import GBVersionTracking
1616
class AppDelegate: UIResponder, UIApplicationDelegate {
1717

1818
var window: UIWindow?
19+
20+
var mainViewController: MainViewController?
1921

2022
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
2123
// We need this for views to not be hidden under the keyboard

Lifting Buddy/MainViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class MainViewController: UIViewController {
4747
override func viewDidLoad() {
4848
super.viewDidLoad()
4949

50+
(UIApplication.shared.delegate as? AppDelegate)?.mainViewController = self
5051
view.backgroundColor = .lightestBlackWhiteColor
5152
}
5253

Lifting Buddy/MessageQueue.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ public class MessageQueue {
2626

2727
private var messageQueue = [Message]()
2828
private var queueTimer: Timer?
29-
private var md: MessageDisplayer? {
30-
return (UIApplication.shared.delegate as? AppDelegate)?.window?.rootViewController as? MessageDisplayer
29+
private var messageDisplayer: MessageDisplayer? {
30+
return (UIApplication.shared.delegate as? AppDelegate)?.mainViewController
3131
}
3232

3333
public func append(_ message: Message) {
3434
messageQueue.append(message)
3535

3636
if queueTimer == nil {
37-
md?.messageQueueStarted?()
37+
messageDisplayer?.messageQueueStarted?()
3838

3939
queueTimer = Timer.scheduledTimer(withTimeInterval: messageDisplayTime, repeats: true) { (timer) in
40-
if let md = self.md {
40+
if let md = self.messageDisplayer {
4141

4242
if self.messageQueue.count == 0 {
4343
self.queueTimer?.invalidate()

0 commit comments

Comments
 (0)