Hardcode the sliding sync proxy. (#502)

* Add support for migrating between versions.
* Rename InfoPlistReader property.
* Bump SDK version.
This commit is contained in:
Doug
2023-01-31 17:48:24 +00:00
committed by GitHub
parent 4f8cc08989
commit f6629e0d6e
31 changed files with 143 additions and 99 deletions
@@ -44,10 +44,10 @@ struct AnalyticsPromptStrings {
init() {
// Create the opt in content with a placeholder.
let linkPlaceholder = "{link}"
var optInContent = AttributedString(ElementL10n.analyticsOptInContent(InfoPlistReader.target.bundleDisplayName, linkPlaceholder))
var optInContent = AttributedString(ElementL10n.analyticsOptInContent(InfoPlistReader.main.bundleDisplayName, linkPlaceholder))
guard let range = optInContent.range(of: linkPlaceholder) else {
self.optInContent = AttributedString(ElementL10n.analyticsOptInContent(InfoPlistReader.target.bundleDisplayName,
self.optInContent = AttributedString(ElementL10n.analyticsOptInContent(InfoPlistReader.main.bundleDisplayName,
ElementL10n.analyticsOptInContentLink))
MXLog.failure("Failed to add a link attribute to the opt in content.")
return
@@ -59,7 +59,7 @@ struct AnalyticsPrompt: View {
Image(uiImage: Asset.Images.analyticsLogo.image)
.padding(.bottom, 25)
Text(ElementL10n.analyticsOptInTitle(InfoPlistReader.target.bundleDisplayName))
Text(ElementL10n.analyticsOptInTitle(InfoPlistReader.main.bundleDisplayName))
.font(.element.title2Bold)
.multilineTextAlignment(.center)
.foregroundColor(.element.primaryContent)
@@ -64,6 +64,7 @@ struct LoginScreen: View {
LoginServerInfoSection(address: context.viewState.homeserver.address) {
context.send(viewAction: .selectServer)
}
.disabled(true) // The button is disabled for this demo.
}
/// The form with text fields for username and password, along with a submit button.
@@ -48,6 +48,7 @@ struct LoginServerInfoSection: View {
Image(systemName: "chevron.right")
.foregroundColor(.element.tertiaryContent)
.padding(.trailing, 16)
.hidden() // The button is disabled for this demo.
}
.background(RoundedRectangle(cornerRadius: 14).fill(Color.element.system))
}
@@ -55,8 +55,6 @@ struct ServerSelectionViewState: BindableState {
struct ServerSelectionBindings {
/// The homeserver address input by the user.
var homeserverAddress: String
/// The sliding sync proxy address input by the user.
var slidingSyncProxyAddress: String
/// Information describing the currently displayed alert.
var alertInfo: AlertInfo<ServerSelectionErrorType>?
}
@@ -22,8 +22,7 @@ class ServerSelectionViewModel: ServerSelectionViewModelType, ServerSelectionVie
var callback: (@MainActor (ServerSelectionViewModelAction) -> Void)?
init(homeserverAddress: String, isModallyPresented: Bool) {
let bindings = ServerSelectionBindings(homeserverAddress: homeserverAddress,
slidingSyncProxyAddress: ServiceLocator.shared.settings.slidingSyncProxyBaseURLString)
let bindings = ServerSelectionBindings(homeserverAddress: homeserverAddress)
super.init(initialViewState: ServerSelectionViewState(bindings: bindings,
isModallyPresented: isModallyPresented))
@@ -32,11 +31,6 @@ class ServerSelectionViewModel: ServerSelectionViewModelType, ServerSelectionVie
override func process(viewAction: ServerSelectionViewAction) async {
switch viewAction {
case .confirm:
if !state.bindings.slidingSyncProxyAddress.isEmpty,
state.bindings.slidingSyncProxyAddress != ServiceLocator.shared.settings.slidingSyncProxyBaseURLString {
ServiceLocator.shared.settings.slidingSyncProxyBaseURLString = state.bindings.slidingSyncProxyAddress
}
callback?(.confirm(homeserverAddress: state.bindings.homeserverAddress))
case .dismiss:
callback?(.dismiss)
@@ -71,16 +71,6 @@ struct ServerSelectionScreen: View {
.onSubmit(submit)
.accessibilityIdentifier("addressTextField")
TextField(ElementL10n.ftueAuthChooseServerEntryHint, text: $context.slidingSyncProxyAddress)
.textFieldStyle(.elementInput(labelText: "Sliding sync proxy URL"))
.keyboardType(.URL)
.autocapitalization(.none)
.disableAutocorrection(true)
.submitLabel(.done)
.onSubmit(submit)
.accessibilityIdentifier("slidingSyncProxyAddressTextField")
.padding(.bottom, 8)
Button(action: submit) {
Text(context.viewState.buttonTitle)
}
@@ -62,7 +62,7 @@ struct OnboardingViewState: BindableState {
init() {
content = [
OnboardingPageContent(title: ElementL10n.ftueAuthCarouselWelcomeTitle.tinting(".", color: .element.accent),
message: ElementL10n.ftueAuthCarouselWelcomeBody(InfoPlistReader.target.bundleDisplayName),
message: ElementL10n.ftueAuthCarouselWelcomeBody(InfoPlistReader.main.bundleDisplayName),
image: Asset.Images.onboardingAppLogo)
]
bindings = OnboardingBindings()
@@ -23,7 +23,7 @@ struct InviteFriendsCoordinator: CoordinatorProtocol {
guard let permalink = try? PermalinkBuilder.permalinkTo(userIdentifier: userId).absoluteString else {
return AnyView(EmptyView())
}
let shareText = ElementL10n.inviteFriendsText(InfoPlistReader.target.bundleDisplayName, permalink)
let shareText = ElementL10n.inviteFriendsText(InfoPlistReader.main.bundleDisplayName, permalink)
return AnyView(UIActivityViewControllerWrapper(activityItems: [shareText])
.presentationDetents([.medium])
@@ -57,7 +57,7 @@ struct SettingsScreen: View {
}
private var versionText: some View {
Text(ElementL10n.settingsVersion + ": " + InfoPlistReader.target.bundleShortVersionString + " (" + InfoPlistReader.target.bundleVersion + ")")
Text(ElementL10n.settingsVersion + ": " + InfoPlistReader.main.bundleShortVersionString + " (" + InfoPlistReader.main.bundleVersion + ")")
}
private var backgroundColor: Color {