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

Remove wss:// from relay lists and allow entry of relay without wss:// #1417

Merged
Merged
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added a new image viewer that appears when you tap an image.
- Included the npub in the properties list sent to analytics.
- Removed the like and repost counts from the Main and Profile feeds.
- Replaced hard-coded color values.
lingoslinger marked this conversation as resolved.
Show resolved Hide resolved
- Removed wss:// from relay addresses in lists and removed the need to prepend relay addresses with wss://.

## [0.1.25] - 2024-08-21Z

Expand Down
28 changes: 17 additions & 11 deletions Nos/Assets/Localization/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -9707,70 +9707,76 @@
"relayAddressPlaceholder" : {
"extractionState" : "manual",
"localizations" : {
"ar" : {
"stringUnit" : {
"state" : "translated",
"value" : "yourrelay.com"
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "wss://yourrelay.com"
"value" : "yourrelay.com"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "wss://yourrelay.com"
"value" : "yourrelay.com"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "wss://yourrelay.com"
"value" : "yourrelay.com"
}
},
"fa" : {
"stringUnit" : {
"state" : "translated",
"value" : "wss://yourrelay.com"
"value" : "yourrelay.com"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "wss://votrerelay.com"
"value" : "votrerelay.com"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "wss://yourrelay.com"
"value" : "yourrelay.com"
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
"value" : "wss://jouwrelay.com"
"value" : "jouwrelay.com"
}
},
"pt-BR" : {
"stringUnit" : {
"state" : "translated",
"value" : "wss://seurelay.com"
"value" : "seurelay.com"
}
},
"sv" : {
"stringUnit" : {
"state" : "translated",
"value" : "wss://yourrelay.com"
"value" : "yourrelay.com"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "wss://yourrelay.com"
"value" : "yourrelay.com"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "wss://yourrelay.com"
"value" : "yourrelay.com"
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions Nos/Views/RelayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ struct RelayView: View {
NavigationLink {
RelayDetailView(relay: relay)
} label: {
Text(relay.address ?? String(localized: .localizable.error))
Text(relay.host ?? String(localized: .localizable.error))
.foregroundColor(.primaryTxt)
}
} else {
Text(relay.address ?? String(localized: .localizable.error))
Text(relay.host ?? String(localized: .localizable.error))
.foregroundColor(.primaryTxt)
.textSelection(.enabled)
}
Expand Down Expand Up @@ -106,6 +106,7 @@ struct RelayView: View {
let authorRelayUrls = author.relays.compactMap { $0.address }
let recommendedRelays = Relay.recommended
.filter { !authorRelayUrls.contains($0) }
.map { $0.replacingOccurrences(of: "wss://", with: "") }
.sorted { (lhs, _) in lhs == Relay.nosAddress.absoluteString }

if editable, !recommendedRelays.isEmpty {
Expand Down Expand Up @@ -198,7 +199,10 @@ struct RelayView: View {
guard !newRelayAddress.isEmpty else { return }

do {
let address = newRelayAddress.lowercased().trimmingCharacters(in: .whitespacesAndNewlines)
var address = newRelayAddress.lowercased().trimmingCharacters(in: .whitespacesAndNewlines)
if !address.starts(with: "wss://") {
address = "wss://" + address
}
let relay = try Relay.findOrCreate(by: address, context: viewContext)
currentUser.author?.add(relay: relay)
try viewContext.save()
Expand Down
Loading