Skip to content

Commit 03db77e

Browse files
committed
[Hygiene]Reuse default CallSettings instance to avoid reinitialization
1 parent a5448f3 commit 03db77e

File tree

7 files changed

+11
-9
lines changed

7 files changed

+11
-9
lines changed

Sources/StreamVideo/CallState.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public class CallState: ObservableObject {
121121
@Published public internal(set) var anonymousParticipantCount: UInt32 = 0
122122
@Published public internal(set) var participantCount: UInt32 = 0
123123
@Published public internal(set) var isInitialized: Bool = false
124-
@Published public internal(set) var callSettings = CallSettings()
124+
@Published public internal(set) var callSettings: CallSettings = .default
125125

126126
@Published public internal(set) var isCurrentUserScreensharing: Bool = false
127127
@Published public internal(set) var duration: TimeInterval = 0

Sources/StreamVideo/Models/CallSettings.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import Foundation
77

88
/// Represents the settings for a call.
99
public final class CallSettings: ObservableObject, Sendable, Equatable, CustomStringConvertible {
10+
public static let `default` = CallSettings()
11+
1012
/// Whether the audio is on for the current user.
1113
public let audioOn: Bool
1214
/// Whether the video is on for the current user.

Sources/StreamVideo/Utils/AudioSession/Extensions/AVAudioSessionPortOverride+Convenience.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ extension AVAudioSession.PortOverride {
99
public var description: String {
1010
switch self {
1111
case .none:
12-
return "None"
12+
return ".none"
1313
case .speaker:
14-
return "Speaker"
14+
return ".speaker"
1515
@unknown default:
16-
return "Unknown"
16+
return ".unknown"
1717
}
1818
}
1919
}

Sources/StreamVideo/WebRTC/v2/WebRTCStateAdapter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ actor WebRTCStateAdapter: ObservableObject, StreamAudioSessionAdapterDelegate, W
5151
/// Published properties that represent different parts of the WebRTC state.
5252
@Published private(set) var sessionID: String = UUID().uuidString
5353
@Published private(set) var token: String = ""
54-
@Published private(set) var callSettings: CallSettings = .init()
54+
@Published private(set) var callSettings: CallSettings = .default
5555
@Published private(set) var audioSettings: AudioSettings = .init()
5656

5757
/// Published property to track video options and update them.

Sources/StreamVideoSwiftUI/CallView/CallControls/Stateless/StatelessMicrophoneIconView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public struct StatelessMicrophoneIconView: View {
4040
@MainActor
4141
public init(
4242
call: Call?,
43-
callSettings: CallSettings = .init(),
43+
callSettings: CallSettings = .default,
4444
size: CGFloat = 44,
4545
controlStyle: ToggleControlStyle = .init(
4646
enabled: .init(icon: Appearance.default.images.micTurnOn, iconStyle: .transparent),

Sources/StreamVideoSwiftUI/CallView/CallControls/Stateless/StatelessVideoIconView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public struct StatelessVideoIconView: View {
3939
/// - actionHandler: An optional closure to handle button tap actions.
4040
public init(
4141
call: Call?,
42-
callSettings: CallSettings = .init(),
42+
callSettings: CallSettings = .default,
4343
size: CGFloat = 44,
4444
controlStyle: ToggleControlStyle = .init(
4545
enabled: .init(icon: Appearance.default.images.videoTurnOn, iconStyle: .transparent),

Sources/StreamVideoSwiftUI/CallViewModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ open class CallViewModel: ObservableObject {
228228
callSettings: CallSettings? = nil
229229
) {
230230
self.participantsLayout = participantsLayout
231-
self.callSettings = callSettings ?? CallSettings()
231+
self.callSettings = callSettings ?? .default
232232
localCallSettingsChange = callSettings != nil
233233

234234
subscribeToCallEvents()
@@ -672,7 +672,7 @@ open class CallViewModel: ObservableObject {
672672

673673
// Reset the CallSettings so that the next Call will be joined
674674
// with either new overrides or the values provided from the API.
675-
callSettings = .init()
675+
callSettings = .default
676676
localCallSettingsChange = false
677677
}
678678

0 commit comments

Comments
 (0)