Skip to content

Commit

Permalink
Fix missing room controller in join notification
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Müller <[email protected]>
  • Loading branch information
SystemKeeper committed Jul 1, 2024
1 parent b3022de commit 1066742
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 5 additions & 4 deletions NextcloudTalk/NCRoomsManagerExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,22 @@ import Foundation
}

private func joinRoomHelper(_ token: String, forCall call: Bool) {
var userInfo: [AnyHashable: Any] = [:]
userInfo["token"] = token

if let roomController = self.activeRooms[token] as? NCRoomController {
if call {
roomController.inCall = true
} else {
roomController.inChat = true
}

NotificationCenter.default.post(name: .NCRoomsManagerDidJoinRoom, object: self, userInfo: ["token": token])
userInfo["roomController"] = roomController
NotificationCenter.default.post(name: .NCRoomsManagerDidJoinRoom, object: self, userInfo: userInfo)

return
}

var userInfo: [AnyHashable: Any] = [:]

self.joiningRoomToken = token

self.joinRoomHelper(token, forCall: call) { sessionId, room, error, statusCode in
Expand Down Expand Up @@ -90,7 +92,6 @@ import Foundation
NCUtils.log("Could not join room. Status code: \(statusCode). Error: \(error?.localizedDescription ?? "")")
}

userInfo["token"] = token
NotificationCenter.default.post(name: .NCRoomsManagerDidJoinRoom, object: self, userInfo: userInfo)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ final class IntegrationRoomsManagerTest: TestBase {
// swiftlint:disable:next force_cast
XCTAssertEqual(notification.userInfo?["token"] as! String, roomToken)

// There's no NCRoomController when joining fails
XCTAssertNil(notification.userInfo?["roomController"])

return true
}

Expand Down Expand Up @@ -77,6 +80,9 @@ final class IntegrationRoomsManagerTest: TestBase {
// Check if the NCRoomController was correctly added to the activeRooms dictionary
XCTAssertNotNil(NCRoomsManager.sharedInstance().activeRooms[roomToken])

// When successfully joined, the NCRoomController should be included in the notification
XCTAssertNotNil(notification.userInfo?["roomController"])

return true
}

Expand Down

0 comments on commit 1066742

Please sign in to comment.