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

Trim number of resolved alias vias and always default to a join button in the room preview screen #3082

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo

defer {
hideLoadingIndicator()
updateRoomDetails()
}

// Using only the preview API isn't enough as it's not capable
Expand All @@ -105,10 +106,6 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
}

private func updateRoomDetails() {
if roomProxy == nil, roomPreviewDetails == nil {
return
}

let name = roomProxy?.name ?? roomPreviewDetails?.name
state.roomDetails = JoinRoomScreenRoomDetails(name: name,
topic: roomProxy?.topic ?? roomPreviewDetails?.topic,
Expand All @@ -120,19 +117,16 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
}

private func updateMode() {
if roomProxy == nil, roomPreviewDetails == nil {
state.mode = .unknown
return
}

if roomProxy?.isPublic ?? false || roomPreviewDetails?.isPublic ?? false {
state.mode = .join
} else if roomProxy?.membership == .invited || roomPreviewDetails?.isInvited ?? false {
state.mode = .invited
} else if roomPreviewDetails?.canKnock ?? false, allowKnocking { // Knocking is not supported yet, the flag is purely for preview tests.
state.mode = .knock
} else {
state.mode = .unknown
// If everything else fails fallback to showing the join button and
// letting the server figure it out.
state.mode = .join
}
}

Expand Down
9 changes: 8 additions & 1 deletion ElementX/Sources/Services/Client/ClientProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,14 @@ class ClientProxy: ClientProxyProtocol {

func resolveRoomAlias(_ alias: String) async -> Result<ResolvedRoomAlias, ClientProxyError> {
do {
return try await .success(client.resolveRoomAlias(roomAlias: alias))
let resolvedAlias = try await client.resolveRoomAlias(roomAlias: alias)

// Resolving aliases is done through the directory/room API which returns too many / all known
// vias, which in turn results in invalid join requests. Trim them to something manageable
// https://github.com/element-hq/synapse/issues/17298
let limitedAlias = ResolvedRoomAlias(roomId: resolvedAlias.roomId, servers: Array(resolvedAlias.servers.prefix(50)))

return .success(limitedAlias)
} catch {
MXLog.error("Failed resolving room alias: \(alias) with error: \(error)")
return .failure(.sdkError(error))
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading