Skip to content

Commit 31b78c3

Browse files
authored
Merge pull request #2255 from nextcloud/fix/noid/room-participant-call-state
fix: Correctly parse inCall flag for room participants
2 parents 14fd721 + b76b0d9 commit 31b78c3

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

NextcloudTalk/Rooms/NCRoomParticipant.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public class NCRoomParticipant: NSObject {
4444
self.attendeeId = dictionary["attendeeId"] as? Int ?? 0
4545
self.actorId = dictionary["actorId"] as? String
4646
self.displayName = dictionary["displayName"] as? String ?? ""
47-
self.inCall = dictionary["inCall"] as? CallFlag ?? []
4847
self.lastPing = dictionary["lastPing"] as? Int ?? 0
4948
self.sessionId = dictionary["sessionId"] as? String
5049
self.sessionIds = dictionary["sessionIds"] as? [String]
@@ -62,6 +61,10 @@ public class NCRoomParticipant: NSObject {
6261
self.participantType = participantType
6362
}
6463

64+
if let callFlagRaw = dictionary["inCall"] as? Int {
65+
self.inCall = CallFlag(rawValue: callFlagRaw)
66+
}
67+
6568
// Optional attributes
6669
self.status = dictionary["status"] as? String
6770
self.statusIcon = dictionary["statusIcon"] as? String

NextcloudTalk/Rooms/RoomInfo/RoomInfoParticipantsSection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ struct RoomInfoParticipantsSection: View {
121121
ContactsTableViewCellWrapper(room: $room, participant: $participant)
122122
.frame(height: 72) // Height set in the XIB file
123123
}
124-
.listRowInsets(.init())
124+
.listRowInsets(.init(top: 0, leading: 0, bottom: 0, trailing: 12))
125125
.alignmentGuide(.listRowSeparatorLeading) { _ in
126126
72
127127
}

NextcloudTalkTests/Unit/UnitNCRoomParticipantTest.swift

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,51 @@ final class UnitNCRoomParticipantTest: TestBaseRealm {
7171

7272
XCTAssertEqual(sorted, expectedParticipants)
7373
}
74+
75+
func testInitWithDictionary() throws {
76+
let dataJson = """
77+
{
78+
"roomToken": "tok3n",
79+
"inCall": 7,
80+
"lastPing": 1761683745,
81+
"sessionIds": [
82+
"session1",
83+
"session2"
84+
],
85+
"participantType": 1,
86+
"attendeeId": 72,
87+
"actorId": "admin",
88+
"actorType": "users",
89+
"displayName": "admin",
90+
"permissions": 254,
91+
"attendeePermissions": 0,
92+
"attendeePin": "",
93+
"phoneNumber": "",
94+
"callId": "",
95+
"status": "busy",
96+
"statusIcon": "💬",
97+
"statusMessage": "In a call",
98+
"statusClearAt": null
99+
}
100+
"""
101+
102+
// swiftlint:disable:next force_cast
103+
let participantdict = try JSONSerialization.jsonObject(with: dataJson.data(using: .utf8)!) as! [String: Any]
104+
let participant = NCRoomParticipant(dictionary: participantdict)
105+
106+
XCTAssertEqual(participant.attendeeId, 72)
107+
XCTAssertEqual(participant.actorId, "admin")
108+
XCTAssertEqual(participant.actorType, .user)
109+
XCTAssertEqual(participant.participantType, .owner)
110+
XCTAssertEqual(participant.displayName, "admin")
111+
XCTAssertEqual(participant.lastPing, 1761683745)
112+
XCTAssertEqual(participant.sessionIds?[0], "session1")
113+
XCTAssertEqual(participant.sessionIds?[1], "session2")
114+
XCTAssertEqual(participant.inCall, [.inCall, .withAudio, .withVideo])
115+
XCTAssertEqual(participant.status, "busy")
116+
XCTAssertEqual(participant.statusIcon, "💬")
117+
XCTAssertEqual(participant.statusMessage, "In a call")
118+
XCTAssertNil(participant.userId)
119+
}
120+
74121
}

0 commit comments

Comments
 (0)