Don't set the room topic when creating a room if it is blank. (#3821)

* Don't set the room topic when creating a room if it is blank.

Also fix the styling on the room name text field.

* Snapshots

* Add a test for the empty topic.
This commit is contained in:
Doug
2025-02-25 11:10:59 +00:00
committed by GitHub
parent 21223b2492
commit 67342c38d7
13 changed files with 48 additions and 22 deletions

View File

@@ -256,7 +256,7 @@ class CreateRoomViewModel: CreateRoomViewModelType, CreateRoomViewModelProtocol
}
switch await userSession.clientProxy.createRoom(name: createRoomParameters.name,
topic: createRoomParameters.topic,
topic: createRoomParameters.topic.isBlank ? nil : createRoomParameters.topic,
isRoomPrivate: createRoomParameters.isRoomPrivate,
// As of right now we don't want to make private rooms with the knock rule
isKnockingOnly: createRoomParameters.isRoomPrivate ? false : createRoomParameters.isKnockingOnly,

View File

@@ -70,6 +70,9 @@ struct CreateRoomScreen: View {
text: roomNameBinding,
prompt: Text(L10n.commonRoomNamePlaceholder).foregroundColor(.compound.textSecondary),
axis: .horizontal)
.font(.compound.bodyLG)
.foregroundStyle(.compound.textPrimary)
.tint(.compound.iconAccentTertiary)
.focused($focus, equals: .name)
.accessibilityIdentifier(A11yIdentifiers.createRoomScreen.roomName)
.padding(.horizontal, ListRowPadding.horizontal)

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:43b54cc80fa66318f51aab25bf1da468d5fb80bd1a3e3e421a09976a099b5f2b
size 130312
oid sha256:dcc8dd510bf4aa95d2fd10cc7eb946754068582f8f0563e3ad90ddab6b236bf3
size 130451

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:243f03c80c7b5cfb73a8e7dd974b95b20b97e08dc0c39bfb452f874a12f4d7a7
size 128866
oid sha256:ea006d0e1b476d2a9b96d044967c1882a85cfef15145b25dc828742fe97e513e
size 128922

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0860ca1766635147002c8f3253cd96342fd5db0da8a0e8507d8f1bb6da81a7ea
size 127199
oid sha256:84d44465e097c95930f466da5c1512925ac89a6906f2fd5390ad390b7aeba05a
size 127261

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:87798e15e4929dd518b4733e89ed88576a775ac395137094d26fc799ebd6ca7d
size 96316
oid sha256:f716c24e26af4a6eed2f576952b01b7cc179f086ed368fa6a1226b521149453e
size 96300

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1d046772ea3846acbe9ef68f573171d28fbc83188fbed21430e1d21528f0d895
size 96665
oid sha256:d05af6448a4513f425f276cf66427ad1073d3a23f95e16a31a3783351267d5bc
size 96642

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9eef46ce00dd0109951470ae8b12423e9f6675d3e6ed12d28635febb157aec5a
size 164509
oid sha256:101a6816e238f388da0e85028f694bd45394a10cb883e1855a5e3715acdfb191
size 164757

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9eef46ce00dd0109951470ae8b12423e9f6675d3e6ed12d28635febb157aec5a
size 164509
oid sha256:101a6816e238f388da0e85028f694bd45394a10cb883e1855a5e3715acdfb191
size 164757

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9eef46ce00dd0109951470ae8b12423e9f6675d3e6ed12d28635febb157aec5a
size 164509
oid sha256:101a6816e238f388da0e85028f694bd45394a10cb883e1855a5e3715acdfb191
size 164757

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:600ce81a26eb906ab40462af4c73badf5a5c12fe8e84376f43eb58a66068561a
size 127069
oid sha256:9a5221eb946a4d7613adc5d1ffc92c8ab56723f3c9339720f6e74be03514871f
size 127295

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8ed123ad17a24c3d49629ff7fe006095e55a7e11b00d9223410cbd5cc26ced45
size 127639
oid sha256:a94efa2a1ce5958a0573054fee0249921a592cf4c638b87ba467aaea1b42d2b0
size 127861

View File

@@ -62,7 +62,7 @@ class CreateRoomScreenViewModelTests: XCTestCase {
XCTAssertNotEqual(context.viewState.selectedUsers.first?.userID, UserProfileProxy.mockAlice.userID)
}
func testDefaulSecurity() {
func testDefaultSecurity() {
XCTAssertTrue(context.viewState.bindings.isRoomPrivate)
}
@@ -72,6 +72,29 @@ class CreateRoomScreenViewModelTests: XCTestCase {
XCTAssertTrue(context.viewState.canCreateRoom)
}
func testCreateRoom() async throws {
// Given a form with a blank topic.
context.send(viewAction: .updateRoomName("A"))
context.roomTopic = ""
context.isRoomPrivate = false
XCTAssertTrue(context.viewState.canCreateRoom)
// When creating the room.
clientProxy.createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartReturnValue = .success("1")
let deferred = deferFulfillment(viewModel.actions) { action in
guard case .openRoom("1") = action else { return false }
return true
}
context.send(viewAction: .createRoom)
try await deferred.fulfill()
// Then the room should be created and a topic should not be set.
XCTAssertTrue(clientProxy.createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartCalled)
XCTAssertEqual(clientProxy.createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartReceivedArguments?.name, "A")
XCTAssertNil(clientProxy.createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartReceivedArguments?.topic,
"The topic should be sent as nil when it is empty.")
}
func testCreateKnockingRoom() async {
context.send(viewAction: .updateRoomName("A"))
context.roomTopic = "B"