Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Live Observation interfaces to WidgetSDK #1248

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions GliaWidgets/Public/Glia/Glia.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
/// - `GliaError.configuringDuringEngagementIsNotAllowed`
/// - `ConfigurationError`
///
public func configure(

Check warning on line 206 in GliaWidgets/Public/Glia/Glia.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Cyclomatic Complexity Violation: Function should have complexity 10 or less; currently complexity is 11 (cyclomatic_complexity)
with configuration: Configuration,
theme: Theme = Theme(),
uiConfig: RemoteConfiguration? = nil,
Expand Down Expand Up @@ -479,6 +479,20 @@
completion(.failure(GliaError.internalError))
}
}

/// Pauses live observation.
///
/// This method is used to hide sensitive data from the screen by pausing live observation.
public func liveObservationPause() {
environment.coreSdk.liveObservationPause()
}

/// Resumes live observation.
///
/// This method resumes live observation session after it has been paused.
public func liveObservationResume() {
environment.coreSdk.liveObservationResume()
}
}

// MARK: - Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ struct CoreSdkClient {
typealias UnsubscribeFromUnreadCount = (String) -> Void

var unsubscribeFromUnreadCount: UnsubscribeFromUnreadCount

var liveObservationPause: () -> Void

var liveObservationResume: () -> Void
}

extension CoreSdkClient {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ extension CoreSdkClient {
unsubscribeFromPendingSecureConversationStatus: {
GliaCore.sharedInstance.secureConversations.unsubscribeFromPendingSecureConversationStatus($0)
},
unsubscribeFromUnreadCount: GliaCore.sharedInstance.secureConversations.unsubscribeFromUnreadMessageCount
unsubscribeFromUnreadCount: GliaCore.sharedInstance.secureConversations.unsubscribeFromUnreadMessageCount,
liveObservationPause: GliaCore.sharedInstance.liveObservation.pause,
liveObservationResume: GliaCore.sharedInstance.liveObservation.resume
)
}()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ extension CoreSdkClient {
pendingSecureConversationStatus: { $0(.success(false)) },
observePendingSecureConversationStatus: { _ in nil },
unsubscribeFromPendingSecureConversationStatus: { _ in },
unsubscribeFromUnreadCount: { _ in }
unsubscribeFromUnreadCount: { _ in },
liveObservationPause: {},
liveObservationResume: {}
)
}

Expand Down
5 changes: 2 additions & 3 deletions GliaWidgetsTests/Sources/CallViewControllerTests.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@testable import GliaWidgets
import GliaCoreSDK
import XCTest

class CallViewControllerTests: XCTestCase {
Expand Down Expand Up @@ -104,7 +103,7 @@ class CallViewControllerTests: XCTestCase {
notificationCenter.removeObserverClosure = { _ in }
notificationCenter.removeObserverWithNameAndObject = { _, _, _ in }
notificationCenter.addObserverClosure = { _, _, _, _ in }
GliaCore.sharedInstance.liveObservation.pause()
Glia.sharedInstance.liveObservationPause()
let env = CallViewController.Environment(
viewFactory: .mock(),
notificationCenter: notificationCenter,
Expand Down Expand Up @@ -159,7 +158,7 @@ class CallViewControllerTests: XCTestCase {
notificationCenter.removeObserverClosure = { _ in }
notificationCenter.removeObserverWithNameAndObject = { _, _, _ in }
notificationCenter.addObserverClosure = { _, _, _, _ in }
GliaCore.sharedInstance.liveObservation.pause()
Glia.sharedInstance.liveObservationPause()
let env = CallViewController.Environment(
viewFactory: .mock(),
notificationCenter: notificationCenter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ extension CoreSdkClient {
},
unsubscribeFromUnreadCount: { _ in
fail("\(Self.self).unsubscribeFromUnreadCount")
},
liveObservationPause: {
fail("\(Self.self).liveObservationPause")
},
liveObservationResume: {
fail("\(Self.self).liveObservationResume")
}
)
}
Expand Down
6 changes: 3 additions & 3 deletions TestingApp/SensitiveData/SensitiveDataViewController.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import UIKit
import GliaCoreSDK
import GliaWidgets

final class SensitiveDataViewController: UIViewController {
private lazy var message: UILabel = {
Expand All @@ -22,12 +22,12 @@ final class SensitiveDataViewController: UIViewController {
}

override func viewWillAppear(_ animated: Bool) {
GliaCore.sharedInstance.liveObservation.pause()
Glia.sharedInstance.liveObservationPause()
super.viewWillAppear(animated)
}

override func viewWillDisappear(_ animated: Bool) {
GliaCore.sharedInstance.liveObservation.resume()
Glia.sharedInstance.liveObservationResume()
super.viewWillDisappear(animated)
}

Expand Down
Loading