Skip to content

Commit

Permalink
Add company name to live observation confirmation alert message
Browse files Browse the repository at this point in the history
This PR adds company name to live observation alert.

MOB-2739
  • Loading branch information
rasmustautsglia committed Nov 1, 2023
1 parent 316bba0 commit 26bc682
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions GliaWidgets/Localization+Templates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ extension Localization {
static let errorMessage = "{message}"
static let downloadWithFileState = "{downloadedFileName}, {downloadedFileState}"
static let downloadWithFileStateAndPercentValue = "{downloadedFileName}, {downloadedFileState} {downloadPercentValue}%"
static let companyName = "{companyName}"
}
}
24 changes: 23 additions & 1 deletion GliaWidgets/Public/Glia/Glia+StartEngagement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extension Glia {
)

let viewFactory = ViewFactory(
with: theme,
with: modifiedTheme,
messageRenderer: messageRenderer,
environment: .init(
data: environment.data,
Expand Down Expand Up @@ -105,6 +105,28 @@ extension Glia {
}
}

private func applyCompanyName(using interactor: Interactor, theme: Theme) -> Theme {
theme.chat.connect.queue.firstText = companyName(
using: interactor,
themeCompanyName: theme.chat.connect.queue.firstText
)

theme.call.connect.queue.firstText = companyName(
using: interactor,
themeCompanyName: theme.call.connect.queue.firstText
)

// Live Observation Confirmation Alert Message
let companyName = companyName(
using: interactor,
themeCompanyName: theme.alertConfiguration.liveObservationConfirmation.message
)
var liveObservationConfirmationMessage = Localization.LiveObservation.Confirm.message.withCompanyName(companyName)
theme.alertConfiguration.liveObservationConfirmation.message = liveObservationConfirmationMessage

return theme
}

func startRootCoordinator(
with interactor: Interactor,
viewFactory: ViewFactory,
Expand Down
4 changes: 4 additions & 0 deletions GliaWidgets/Sources/Extensions/String+TemplateString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@ extension String {
func withTextLength(_ value: String) -> String {
replacingOccurrences(of: "{textLength}", with: value)
}

func withCompanyName(_ companyName: String) -> String {
return self.replacingOccurrences(of: "{companyName}", with: companyName)
}
}
2 changes: 2 additions & 0 deletions GliaWidgetsTests/Sources/Glia/GliaTests+StartEngagement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,15 @@ extension GliaTests {
let theme = Theme()
theme.call.connect.queue.firstText = "Glia 1"
theme.chat.connect.queue.firstText = "Glia 2"
theme.alertConfiguration.liveObservationConfirmation.message = "Glia 3"

try sdk.configure(with: .mock())
try sdk.startEngagement(engagementKind: .chat, in: ["queueId"], theme: theme)

let configuredSdkTheme = resultingViewFactory?.theme
XCTAssertEqual(configuredSdkTheme?.call.connect.queue.firstText, "Glia 1")
XCTAssertEqual(configuredSdkTheme?.chat.connect.queue.firstText, "Glia 2")
XCTAssertEqual(configuredSdkTheme?.alertConfiguration.liveObservationConfirmation.message?.contains("Glia 3"), true)
}

func testCompanyNameIsReceivedFromLocalFallbackIfCustomLocalesIsEmpty() throws {
Expand Down

0 comments on commit 26bc682

Please sign in to comment.