Skip to content

Commit

Permalink
chore: bump version to 1.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Cavallando committed Aug 15, 2024
1 parent b4b862e commit b936194
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 54 deletions.
2 changes: 1 addition & 1 deletion CommandBarIOS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'CommandBarIOS'
s.version = '1.1.7'
s.version = '1.1.8'
s.summary = 'HelpHub and Copilot Command Bar for iOS. '

# This description is used to generate tags and improve search results.
Expand Down
6 changes: 3 additions & 3 deletions Example/CommandBarIOS/Views/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import CommandBarIOS
struct HomeView: View {
@State private var showingAlert = false

var ORG_ID = "foocorp"
var ORG_ID = "<your org id>"

func onCopilotFallback(withType type: String) {
func onFallbackAction(withType type: String) {
CommandBarSDK.shared.closeHelpHub()
self.showingAlert = true
}
Expand All @@ -37,7 +37,7 @@ struct HomeView: View {
VStack() {
CustomButton(title: "Open HelpHub") {
// 4. Open HelpHub
CommandBarSDK.shared.openHelpHub(articleId: nil, withCopilotFallback: onCopilotFallback)
CommandBarSDK.shared.openHelpHub(articleId: nil, withFallbackAction: onFallbackAction)
}.alert(isPresented: $showingAlert) {
Alert(title: Text("Copilot Fallback Triggered"), message: Text("You can use this to trigger opening up a third party chat provider or handle custom behavior when copilot can't find an answer or when the user triggers a fallback action!"), dismissButton: .default(Text("Got it!")))
}
Expand Down
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- CommandBarIOS (1.1.7)
- CommandBarIOS (1.1.8)

DEPENDENCIES:
- CommandBarIOS (from `../`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
CommandBarIOS: 705ef945e447d760e28471edce5060f4f8b3d7d0
CommandBarIOS: bc7460b0feb981653c3333eaeecdc523efd85d21

PODFILE CHECKSUM: 6d9bb10e6d829f27934a51717623c1fd87cac734

Expand Down
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/CommandBarIOS.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 3 additions & 11 deletions Sources/CommandBarIOS/CommandBar/CommandBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ import WebKit
public class CommandBar_Deprecated {
private var options: CommandBarOptions_Deprecated;

public weak var delegate: HelpHubWebViewDelegate? // Add this property
private weak var presentedNavigationController: UINavigationController? // Add this property
private weak var presentedNavigationController: UINavigationController?

public init(options: CommandBarOptions_Deprecated) {
self.options = options
}

public func openHelpHub(articleId: Int? = nil) {
public func openHelpHub(articleId: Int? = nil, fallbackAction: ((String) -> Void)? = nil) {
DispatchQueue.main.async {
let viewController = HelpHubViewController(options: self.options, articleId: articleId)
viewController.delegate = self
let viewController = HelpHubViewController(options: self.options, articleId: articleId, fallbackAction: fallbackAction)

let navigationController = UINavigationController(rootViewController: viewController)
navigationController.modalPresentationStyle = .pageSheet
Expand All @@ -31,9 +29,3 @@ public class CommandBar_Deprecated {
presentedNavigationController = nil
}
}

extension CommandBar_Deprecated : HelpHubWebViewDelegate {
public func didTriggerCopilotFallback(_ action: [String : Any]) {
self.delegate?.didTriggerCopilotFallback(action)
}
}
7 changes: 0 additions & 7 deletions Sources/CommandBarIOS/CommandBar/InternalSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import Foundation
protocol CommandBarInternalSDKDelegate: AnyObject {
func didBootComplete(withConfig config: Config)
func didBootFail(withError error: Error?)

func didTriggerCopilotFallback(withType type: String)
}

// MARK: Internal SDK
Expand Down Expand Up @@ -43,9 +41,4 @@ final class CommandBarInternalSDK : CommandBarInternalSDKDelegate {
print("Failed to boot CommandBar: \(String(describing: error))")
CommandBarInternalSDK.shared.delegate?.didBootFail(withError: error)
}

func didTriggerCopilotFallback(withType type: String) {
CommandBarInternalSDK.shared.delegate?.didTriggerCopilotFallback(withType: type)
}

}
25 changes: 3 additions & 22 deletions Sources/CommandBarIOS/CommandBar/SDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public final class CommandBarSDK {
public weak var delegate: CommandBarSDKDelegate?
weak var privateDelagate: CommandBarInternalSDK?

private var copilotFallbackAction: ((String) -> Void)? = nil

public init() {
self.orgId = nil
self.options = nil
Expand All @@ -32,16 +30,14 @@ public final class CommandBarSDK {
public func boot(_ orgId: String, with options: CommandBarOptions? = nil) {
self.orgId = orgId
self.options = options
self.commandbar = CommandBar_Deprecated(options: CommandBarOptions_Deprecated(["orgId": orgId, "launchCode": "local" ]))
self.commandbar?.delegate = self
self.commandbar = CommandBar_Deprecated(options: CommandBarOptions_Deprecated(["orgId": orgId, "launchCode": "prod" ]))
CommandBarSDK.sharedInternal.boot(orgId: orgId, with: options)
}

public func openHelpHub(articleId: Int? = nil, withCopilotFallback copilotFallbackCallback: ((String) -> Void)? = nil) {
public func openHelpHub(articleId: Int? = nil, withFallbackAction fallbackAction: ((String) -> Void)? = nil) {
guard let orgId = CommandBarSDK.shared.orgId else { return }

self.copilotFallbackAction = copilotFallbackCallback
commandbar?.openHelpHub(articleId: articleId)
commandbar?.openHelpHub(articleId: articleId, fallbackAction: fallbackAction)
}

public func closeHelpHub() {
Expand All @@ -60,19 +56,4 @@ extension CommandBarSDK : CommandBarInternalSDKDelegate {
func didBootFail(withError error: Error?) {
CommandBarSDK.shared.delegate?.didFinishBooting(withError: error)
}

func didTriggerCopilotFallback(withType type: String) {
CommandBarSDK.shared.delegate?.didTriggerCopilotFallback(withType: type)
}
}

extension CommandBarSDK : HelpHubWebViewDelegate {
public func didTriggerCopilotFallback(_ action: [String : Any]) {
let meta = action["meta"] as? [String: Any] ?? [:]
let type = meta["type"] as? String ?? ""

if (self.copilotFallbackAction != nil) {
self.copilotFallbackAction!(type)
}
}
}
12 changes: 9 additions & 3 deletions Sources/CommandBarIOS/HelpHub/HelpHubViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ public class HelpHubViewController: UIViewController {
var helpHubView: HelpHubWebView!
private var options: CommandBarOptions_Deprecated
public var delegate: HelpHubWebViewDelegate?

private var fallbackAction: ((String) -> Void)?
private var articleId: Int?

public init(options: CommandBarOptions_Deprecated, articleId: Int? = nil) {
public init(options: CommandBarOptions_Deprecated, articleId: Int? = nil, fallbackAction: ((String) -> Void)? = nil) {
self.options = options
self.articleId = articleId
self.fallbackAction = fallbackAction
super.init(nibName: nil, bundle: nil)
}

Expand Down Expand Up @@ -43,6 +44,11 @@ public class HelpHubViewController: UIViewController {

extension HelpHubViewController : HelpHubWebViewDelegate {
public func didTriggerCopilotFallback(_ action: [String : Any]) {
self.delegate?.didTriggerCopilotFallback(action)
let meta = action["meta"] as? [String: Any] ?? [:]
let type = meta["type"] as? String ?? ""

if (self.fallbackAction != nil) {
self.fallbackAction!(type)
}
}
}

0 comments on commit b936194

Please sign in to comment.