diff --git a/RiotSwiftUI/Modules/Common/Util/InlineTextButton.swift b/RiotSwiftUI/Modules/Common/Util/InlineTextButton.swift index 42ce478d7..107b3ee1b 100644 --- a/RiotSwiftUI/Modules/Common/Util/InlineTextButton.swift +++ b/RiotSwiftUI/Modules/Common/Util/InlineTextButton.swift @@ -39,10 +39,11 @@ struct InlineTextButton: View { /// - mainText: The main text that shouldn't appear tappable. This must contain a single `%@` placeholder somewhere within. /// - tappableText: The tappable text that will be substituted into the `%@` placeholder. /// - action: The action to perform when tapping the button. - internal init(_ mainText: String, tappableText: String, action: @escaping () -> Void) { + /// - alwaysCallAction: If true calls the action on tap action even if the `tappableText` isn't found inside the `mainText` + init(_ mainText: String, tappableText: String, alwaysCallAction: Bool = true, action: @escaping () -> Void) { guard let range = mainText.range(of: "%@") else { components = [StringComponent(string: Substring(mainText), isTinted: false)] - self.action = action + self.action = alwaysCallAction ? action : { } return } diff --git a/RiotSwiftUI/Modules/UserSessions/Common/View/UserSessionCardView.swift b/RiotSwiftUI/Modules/UserSessions/Common/View/UserSessionCardView.swift index 350f7b92b..776b28a88 100644 --- a/RiotSwiftUI/Modules/UserSessions/Common/View/UserSessionCardView.swift +++ b/RiotSwiftUI/Modules/UserSessions/Common/View/UserSessionCardView.swift @@ -49,7 +49,7 @@ struct UserSessionCardView: View { .foregroundColor(theme.colors[keyPath: viewData.verificationStatusColor]) .multilineTextAlignment(.center) - InlineTextButton(viewData.verificationStatusAdditionalInfoText, tappableText: VectorL10n.userSessionLearnMore) { + InlineTextButton(viewData.verificationStatusAdditionalInfoText, tappableText: VectorL10n.userSessionLearnMore, alwaysCallAction: false) { onLearnMoreAction?() } .font(theme.fonts.footnote) diff --git a/RiotSwiftUI/Modules/UserSessions/UserOtherSessions/View/UserOtherSessionsHeaderView.swift b/RiotSwiftUI/Modules/UserSessions/UserOtherSessions/View/UserOtherSessionsHeaderView.swift index 11c5683b0..a815d7875 100644 --- a/RiotSwiftUI/Modules/UserSessions/UserOtherSessions/View/UserOtherSessionsHeaderView.swift +++ b/RiotSwiftUI/Modules/UserSessions/UserOtherSessions/View/UserOtherSessionsHeaderView.swift @@ -49,7 +49,7 @@ struct UserOtherSessionsHeaderView: View { .foregroundColor(theme.colors.primaryContent) .padding(.vertical, 9.0) } - InlineTextButton(viewData.subtitle, tappableText: VectorL10n.userSessionLearnMore) { + InlineTextButton(viewData.subtitle, tappableText: VectorL10n.userSessionLearnMore, alwaysCallAction: false) { onLearnMoreAction?() } .font(theme.fonts.footnote)