Skip to content

Commit

Permalink
Introduced User object in CallParticipant (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmitrevski authored May 9, 2024
1 parent 923e56c commit fed3a58
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
31 changes: 22 additions & 9 deletions Sources/StreamVideo/Models/CallParticipant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ import Foundation

/// Represents a participant in the call.
public struct CallParticipant: Identifiable, Sendable, Equatable {
/// The `User` object for the participant.
public var user: User
/// The unique call id of the participant.
public var id: String
/// The user's id. This is not necessarily unique, since a user can join from multiple devices.
public let userId: String
/// The user's roles in the call.
public let roles: [String]
/// The user's name.
public let name: String
/// The user's profile image url.
public let profileImageURL: URL?
/// The id of the track that's connected to the participant.
public var trackLookupPrefix: String?
/// Returns whether the participant has video.
Expand Down Expand Up @@ -49,6 +45,21 @@ public struct CallParticipant: Identifiable, Sendable, Equatable {
public var audioLevels: [Float]
public var pin: PinInfo?

/// The user's id. This is not necessarily unique, since a user can join from multiple devices.
public var userId: String {
user.id
}

/// The user's name.
public var name: String {
user.name
}

/// The user's profile image url.
public var profileImageURL: URL? {
user.imageURL
}

public init(
id: String,
userId: String,
Expand All @@ -72,11 +83,13 @@ public struct CallParticipant: Identifiable, Sendable, Equatable {
audioLevels: [Float],
pin: PinInfo?
) {
user = User(
id: userId,
name: name,
imageURL: profileImageURL
)
self.id = id
self.userId = userId
self.roles = roles
self.name = name
self.profileImageURL = profileImageURL
self.trackLookupPrefix = trackLookupPrefix
self.hasVideo = hasVideo
self.hasAudio = hasAudio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,9 @@ The following fields are available on the participant:

| Attribute | Description|
| --------- | ---------- |
| `user` | The `User` object for the participant. |
| `id` | The unique call id of the participant. |
| `userId` | The user's id. This is not necessarily unique, since a user can join from multiple devices. |
| `roles` | The user's roles in the call. |
| `name` | The user's name. |
| `profileImageURL`| The user's profile image url. |
| `trackLookupPrefix` | The id of the track that's connected to the participant. |
| `hasVideo` | Returns whether the participant has video. |
| `hasAudio` | Returns whether the participant has audio. |
| `isScreensharing` | Returns whether the participant is screenSharing. |
Expand All @@ -97,8 +94,10 @@ The following fields are available on the participant:
| `sessionId` | Returns whether the participant is speaking. |
| `connectionQuality` | The participant's connection quality. |
| `joinedAt` | Returns the date when the user joined the call. |
| `pin` | Holds pinning information. |
| `isPinned` | Returns whether the user is pinned. |
| `audioLevel` | The audio level for the user. |
| `audioLevels` | A list of the last 10 audio levels. Convenient for audio visualizations. |

### Client State

Expand Down

0 comments on commit fed3a58

Please sign in to comment.