Skip to content

Commit

Permalink
fixup! Handle ongoing engagement in EntryWidget
Browse files Browse the repository at this point in the history
Remove logic for changing active engagement outside interactor and add onEngagementChanged interface to interactor that updates active engagement

MOB-3806
  • Loading branch information
rasmustautsglia committed Dec 11, 2024
1 parent 05d3f99 commit 876c0e9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion GliaWidgets/Sources/CallVisualizer/CallVisualizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ extension CallVisualizer {
func startObservingInteractorEvents() {
environment.interactorProviding()?.addObserver(self) { [weak self] event in
if case .stateChanged(.ended(.byOperator)) = event {
self?.environment.interactorProviding()?.currentEngagement = nil
self?.endSession()
self?.environment.log.prefixed(Self.self).info("Call visualizer engagement ended")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ extension CoreSdkClient {
typealias LoggingError = GliaCoreSDK.LoggingError
typealias LogLevel = GliaCoreSDK.LogLevel
typealias Request = GliaCoreSDK.Request
typealias EngagementChangedBlock = GliaCoreSDK.EngagementChangedBlock
}

extension CoreSdkClient {
Expand Down
6 changes: 6 additions & 0 deletions GliaWidgets/Sources/Interactor/Interactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ extension Interactor {
}

extension Interactor: CoreSdkClient.Interactable {
var onEngagementChanged: CoreSdkClient.EngagementChangedBlock {
return { [weak self] engagement in
self?.currentEngagement = engagement
}
}

Check warning on line 242 in GliaWidgets/Sources/Interactor/Interactor.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
var onScreenSharingOffer: CoreSdkClient.ScreenshareOfferBlock {
return { [weak self] answer in
self?.notify(.screenShareOffer(answer: answer))
Expand Down
2 changes: 0 additions & 2 deletions GliaWidgets/Sources/ViewModel/EngagementViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ class EngagementViewModel: CommonEngagementModel {
)
)
engagementDelegate?(.finished)
interactor.currentEngagement = nil
case .ended(let reason) where reason == .byOperator:
interactor.currentEngagement?.getSurvey(completion: { [weak self] result in
guard let self = self else { return }
Expand All @@ -132,7 +131,6 @@ class EngagementViewModel: CommonEngagementModel {
}
self.engagementAction?(.showAlert(.operatorEndedEngagement(action: { [weak self] in
self?.endSession()
self?.interactor.currentEngagement = nil
self?.engagementDelegate?(
.engaged(
operatorImageUrl: nil
Expand Down

0 comments on commit 876c0e9

Please sign in to comment.