mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-07-02 04:51:49 +00:00
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:
@@ -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
|
||||
|
||||
+7
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user