Skip to content

Commit

Permalink
use test room when tapping on join planetary room
Browse files Browse the repository at this point in the history
  • Loading branch information
martindsq committed Mar 9, 2023
1 parent fc781e0 commit ad23df9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Source/App/AppConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class AppConfiguration: NSObject, NSCoding, Identifiable, @unchecked Sendable {
}
}

var isUsingTestingNetwork: Bool {
network?.name == Environment.Networks.test.name
}

private var secretDidChange = false
var secret: Secret {
didSet {
Expand Down
12 changes: 10 additions & 2 deletions Source/Controller/RoomListController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,20 @@ import Secrets
func joinPlanetaryRoom() {
loadingMessage = Localized.loading.text
Task {
guard let token = Keys.shared.get(key: .planetaryRoomToken) else {
let key: Key
let host: String
if AppConfiguration.current?.isUsingTestingNetwork == true {
key = .lorentzRoomToken
host = "test-room.lorentz.is"
} else {
key = .planetaryRoomToken
host = "planetary.name"
}
guard let token = Keys.shared.get(key: key) else {
loadingMessage = nil
return
}
do {
let host = "planetary.name"
try await RoomInvitationRedeemer.redeem(token: token, at: host, bot: bot)
refresh()
alertMessageTitle = Localized.success.text
Expand Down
4 changes: 2 additions & 2 deletions Source/UI/RoomListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ struct RoomListView<ViewModel>: View where ViewModel: RoomListViewModel {

if viewModel.showJoinPlanetaryRoomButton {
Section {
Button(Localized.Onboarding.joinPlanetarySystem.text) {
Button(Localized.ManageRelays.joinPlanetaryRoom.text) {
viewModel.joinPlanetaryRoom()
}
.foregroundColor(.primaryAction)
Text(Localized.Onboarding.joinPlanetarySystemDescription.text)
Text(Localized.ManageRelays.joinPlanetaryRoomDescription.text)
.foregroundColor(.secondaryText)
.font(.subheadline)
.padding(.top, 4)
Expand Down

0 comments on commit ad23df9

Please sign in to comment.