Skip to content

Commit

Permalink
Merge pull request #1789 from nextcloud/fatal-error-in-some-cases
Browse files Browse the repository at this point in the history
Raise fatalError when we reached an inconsistent state
  • Loading branch information
Ivansss authored Sep 3, 2024
2 parents 83d1ecf + fac5e57 commit 14d1d6e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions NextcloudTalk/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import UIKit
private var offlineMode = false
private var hasStoredHistory = true
private var hasStopped = false
private var viewWasShown = false
private var roomWasUpdated = false

private var chatViewPresentedTimestamp = Date().timeIntervalSince1970

Expand Down Expand Up @@ -187,8 +189,23 @@ import UIKit
}

if !self.offlineMode {
if self.room == nil {
fatalRoomError("Room should not be nil")
}

if self.room.token == nil {
fatalRoomError("Room token should not be nil")
}

NCRoomsManager.sharedInstance().joinRoom(self.room.token, forCall: false)
}

self.viewWasShown = true
}

private func fatalRoomError(_ message: String) {
let errorMessage = "\(message): WasShown \(self.viewWasShown) | RoomWasUpdated \(self.roomWasUpdated)"
fatalError(errorMessage)
}

public override func viewWillDisappear(_ animated: Bool) {
Expand Down Expand Up @@ -650,6 +667,8 @@ import UIKit
return
}

self.roomWasUpdated = true

self.room = room
self.setTitleView()

Expand Down

0 comments on commit 14d1d6e

Please sign in to comment.