feat(names): UI warning when no server resolves names

Mirror core USWNoNamesServers: add the NoNamesServers variant to
UserServersWarning (Kotlin sealed class + Swift enum) and its
globalWarning / globalServersWarning branch, rendered by the existing
ServersWarningFooter / ServersWarningView. Matches the noChatRelays
warning exactly.
This commit is contained in:
shum
2026-06-13 09:38:35 +00:00
parent af721f75bf
commit f2152b4a5f
4 changed files with 17 additions and 0 deletions
+1
View File
@@ -1825,6 +1825,7 @@ struct UserOperatorServers: Identifiable, Equatable, Codable {
public enum UserServersWarning: Decodable {
case noChatRelays(user: UserRef?)
case noNamesServers(user: UserRef?)
}
enum UserServersError: Decodable {
@@ -417,6 +417,14 @@ func globalServersWarning(_ serverWarnings: [UserServersWarning]) -> String? {
user.localDisplayName
) + " " + text
} else { return text }
case let .noNamesServers(user):
let text = NSLocalizedString("No servers to resolve names.", comment: "servers warning")
if let user = user {
return String.localizedStringWithFormat(
NSLocalizedString("For chat profile %@:", comment: "servers warning"),
user.localDisplayName
) + " " + text
} else { return text }
}
}
return nil
@@ -4642,6 +4642,7 @@ sealed class UserServersError {
@Serializable
sealed class UserServersWarning {
@Serializable @SerialName("noChatRelays") data class NoChatRelays(val user: UserRef? = null): UserServersWarning()
@Serializable @SerialName("noNamesServers") data class NoNamesServers(val user: UserRef? = null): UserServersWarning()
val globalWarning: String?
get() = when (this) {
@@ -4651,6 +4652,12 @@ sealed class UserServersWarning {
String.format(generalGetString(MR.strings.for_chat_profile), user.localDisplayName) + " " + text
} else text
}
is NoNamesServers -> {
val text = generalGetString(MR.strings.no_names_servers_enabled)
if (user != null) {
String.format(generalGetString(MR.strings.for_chat_profile), user.localDisplayName) + " " + text
} else text
}
}
}
@@ -146,6 +146,7 @@
<string name="for_chat_profile">For chat profile %s:</string>
<string name="errors_in_servers_configuration">Errors in servers configuration.</string>
<string name="no_chat_relays_enabled">No chat relays enabled.</string>
<string name="no_names_servers_enabled">No servers to resolve names.</string>
<string name="server_warning">Server warning</string>
<string name="error_accepting_operator_conditions">Error accepting conditions</string>
<string name="blocking_reason_spam">Spam</string>