Skip to content
This repository has been archived by the owner on Jun 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1726 from RocketChat/fix/qa_bugs
Browse files Browse the repository at this point in the history
[FIX] Various minor QA improvements
  • Loading branch information
rafaelks authored May 30, 2018
2 parents 0b3c309 + 28d99bf commit cb5f7f9
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 86 deletions.
63 changes: 2 additions & 61 deletions Rocket.Chat/API/Clients/AuthClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,68 +42,9 @@ struct AuthClient: APIClient {
SocketManager.sharedInstance.isUserAuthenticated = true
ServerManager.timestampSync()
completion(response)
case .error(let error):
switch error {
case .error:
self.loginVersionFallback(params: params, completion: completion)
default:
completion(response)
}
}
}
}

fileprivate func loginVersionFallback(params: LoginParams, completion: @escaping (APIResponse<LoginResource>) -> Void) {
let object = [
"msg": "method",
"method": "login",
"params": [params]
] as [String: Any]

SocketManager.send(object) { (response) in
let result = response.result

guard !response.isError() else {
completion(.resource(.init(raw: ["error": result["error"]])))
return
}

let auth = Auth()
auth.internalFirstChannelOpened = false
auth.lastSubscriptionFetchWithLastMessage = nil
auth.lastAccess = Date()
auth.serverURL = response.socket?.currentURL.absoluteString ?? ""
auth.token = result["result"]["token"].string
auth.userId = result["result"]["id"].string

if let date = result["result"]["tokenExpires"]["$date"].double {
auth.tokenExpires = Date.dateFromInterval(date)
case .error:
completion(response)
}

AuthManager.persistAuthInformation(auth)
DatabaseManager.changeDatabaseInstance()

Realm.executeOnMainThread({ (realm) in
// Delete all the Auth objects, since we don't
// support multiple-server per database
realm.delete(realm.objects(Auth.self))

PushManager.updatePushToken()
realm.add(auth)
})

SocketManager.sharedInstance.isUserAuthenticated = true
ServerManager.timestampSync()

let resource = LoginResource(raw: [
"status": "success",
"data": [
"authToken": auth.token ?? "",
"userId": auth.userId ?? ""
]
])

completion(.resource(resource))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import RealmSwift

extension AuthViewController {
internal func handleAuthenticationResponse(_ response: LoginResponse) {
if case let .resource(resource) = response, let error = resource.error {
switch response {
case .resource(let resource):
guard let error = resource.error else { break }

stopLoading()

switch error.lowercased() {
Expand All @@ -34,8 +37,15 @@ extension AuthViewController {
auth.serverVersion = version.description
}
}
case .error(let error):
stopLoading()
alert(title: localized("error.login.title"), message: error.description)
}

performMeRequest()
}

internal func performMeRequest() {
API.current()?.fetch(MeRequest()) { [weak self] response in
switch response {
case .resource(let resource):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class NewRoomViewController: BaseViewController {
),
SectionForm(
name: localized("new_room.group.channel.name"),
footer: localized("new_room.group.channel.footer"),
footer: nil,
cells: [
FormCell(
cell: .textField(placeholder: localized("new_room.cell.channel_name.title"), icon: #imageLiteral(resourceName: "Hashtag")),
Expand Down
2 changes: 2 additions & 0 deletions Rocket.Chat/Managers/Requests/InfoRequestHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class InfoRequestHandler: NSObject {
func alert(for error: APIError) {
switch error {
case .notSecured: Alert(key: "alert.connection.not_secured").present()
case .error(let error): Alert(title: localized("global.error"), message: error.localizedDescription).present()
default: alertInvalidURL()
}
}
Expand All @@ -49,6 +50,7 @@ class InfoRequestHandler: NSObject {

internal func validateServerResponse(result: InfoResource?) {
guard let version = result?.version else {
alertInvalidURL()
delegate?.urlNotValid()
return
}
Expand Down
15 changes: 7 additions & 8 deletions Rocket.Chat/Resources/cs.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,18 @@
"user_menu.logout" = "Odhlásit";

// New Room View
"new_room.title" = "New Channel";
"new_room.buttons.create" = "Create";
"new_room.title" = "New Channel"; // TODO
"new_room.buttons.create" = "Create"; // TODO
"new_room.cell.public_channel.title" = "Veřejný kanál";
"new_room.cell.public_channel.description" = "K tomuto kanálu má přístup každý";
"new_room.cell.public_channel.description.public_only" = "You can only create public channels";
"new_room.cell.public_channel.description.private_only" = "You can only create private channels";
"new_room.cell.public_channel.description.public_only" = "You can only create public channels"; // TODO
"new_room.cell.public_channel.description.private_only" = "You can only create private channels"; // TODO
"new_room.cell.read_only.title" = "Kanál pouze pro čtení";
"new_room.cell.read_only.description" = "Pouze admin může psát nové zprávy";
"new_room.cell.read_only.description" = "Only authorized members can write new messages"; // TODO
"new_room.group.channel.name" = "Jméno kanálu";
"new_room.group.channel.footer" = "Názvy musí být malým písmen a kratší než 22 znaků";
"new_room.cell.channel_name.title" = "Jméno kanálu";
"new_room.group.invite_users" = "Invite users";
"new_room.cell.invite_users.placeholder" = "Usernames";
"new_room.group.invite_users" = "Invite users"; // TODO
"new_room.cell.invite_users.placeholder" = "Usernames"; // TODO

// Notifications
"notifications.action.reply" = "Reply";
Expand Down
1 change: 0 additions & 1 deletion Rocket.Chat/Resources/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@
"new_room.cell.read_only.description" = "Nur Moderatoren oder Administratoren können in schreibgeschützten Kanälen schreiben";
"new_room.group.channel.name" = "Name des Kanals";
"new_room.cell.channel_name.title" = "Name des Kanals";
"new_room.group.channel.footer" = "Der Name muss komplett in Kleinbuchstaben und kürzer als 22 Zeichen sein.";
"new_room.group.invite_users" = "Benutzer einladen";
"new_room.cell.invite_users.placeholder" = "Benutzernamen";

Expand Down
3 changes: 1 addition & 2 deletions Rocket.Chat/Resources/el.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,8 @@
"new_room.cell.public_channel.description.public_only" = "Μπορείτε να δημιουργείτε μόνο δημόσια κανάλια";
"new_room.cell.public_channel.description.private_only" = "Μπορείτε να δημιουργείτε μόνο ιδιωτικά κανάλια";
"new_room.cell.read_only.title" = "Κανάλι μόνο ανάγνωσης";
"new_room.cell.read_only.description" = "Μόνο ο διαχειριστής μπορεί να γράψει νέα μηνύματα";
"new_room.cell.read_only.description" = "Only authorized members can write new messages"; // TODO
"new_room.group.channel.name" = "Όνομα Καναλιού";
"new_room.group.channel.footer" = "Τα ονόματα πρέπει να χρησιμοποιούν πεζά γράμματα και να είναι μικρότερα από 22 χαρακτήρες";
"new_room.cell.channel_name.title" = "Όνομα Καναλιού";
"new_room.group.invite_users" = "Προσκαλέστε χρήστες";
"new_room.cell.invite_users.placeholder" = "Ονόματα χρηστών";
Expand Down
3 changes: 1 addition & 2 deletions Rocket.Chat/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,8 @@
"new_room.cell.public_channel.description.public_only" = "You can only create public channels";
"new_room.cell.public_channel.description.private_only" = "You can only create private channels";
"new_room.cell.read_only.title" = "Read only channel";
"new_room.cell.read_only.description" = "Only admin can write new messages";
"new_room.cell.read_only.description" = "Only authorized members can write new messages";
"new_room.group.channel.name" = "Channel Name";
"new_room.group.channel.footer" = "Names must be all lower case and shorter than 22 characters";
"new_room.cell.channel_name.title" = "Channel Name";
"new_room.group.invite_users" = "Invite users";
"new_room.cell.invite_users.placeholder" = "Usernames";
Expand Down
3 changes: 1 addition & 2 deletions Rocket.Chat/Resources/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,8 @@
"new_room.cell.public_channel.description.public_only" = "Solo puedes crear canales públicos";
"new_room.cell.public_channel.description.private_only" = "Solo puedes crear canales privados";
"new_room.cell.read_only.title" = "Canal de solo lectura";
"new_room.cell.read_only.description" = "Solo el administrador puede escribir nuevos mensajes";
"new_room.cell.read_only.description" = "Only authorized members can write new messages"; // TODO
"new_room.group.channel.name" = "Nombre del Canal";
"new_room.group.channel.footer" = "Los nombres deben estar en minúsculas y tener menos de 22 caracteres";
"new_room.cell.channel_name.title" = "Nombre del Canal";
"new_room.group.invite_users" = "Invitar usuarios";
"new_room.cell.invite_users.placeholder" = "Nombres de usuario";
Expand Down
3 changes: 1 addition & 2 deletions Rocket.Chat/Resources/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,8 @@
"new_room.cell.public_channel.description.public_only" = "Vous ne pouvez créer que des canaux publiques";
"new_room.cell.public_channel.description.private_only" = "Vous ne pouvez créer que des canaux privées";
"new_room.cell.read_only.title" = "Lire seulement le canal";
"new_room.cell.read_only.description" = "Seul l'administrateur peut écrire de nouveaux messages";
"new_room.cell.read_only.description" = "Only authorized members can write new messages"; // TODO
"new_room.group.channel.name" = "Nom du canal";
"new_room.group.channel.footer" = "Les noms doivent être tous en minuscules et moins de 22 caractères";
"new_room.cell.channel_name.title" = "Nom du canal";
"new_room.group.invite_users" = "Inviter des utilisateurs";
"new_room.cell.invite_users.placeholder" = "Noms d'utilisateur";
Expand Down
3 changes: 1 addition & 2 deletions Rocket.Chat/Resources/pl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,8 @@
"new_room.cell.public_channel.description.public_only" = "Możesz utworzyć tylko kanały publiczne";
"new_room.cell.public_channel.description.private_only" = "Możesz utworzyć tylko kanały prywatne";
"new_room.cell.read_only.title" = "Kanał tylko do odczytu";
"new_room.cell.read_only.description" = "Tylko administrator może pisać wiadomości";
"new_room.cell.read_only.description" = "Only authorized members can write new messages"; // TODO
"new_room.group.channel.name" = "Nazwa kanału";
"new_room.group.channel.footer" = "Nazwa musi być z małych liter oraz być krótsza niż 22 znaki";
"new_room.cell.channel_name.title" = "Nazwa kanału";
"new_room.group.invite_users" = "Zaproś użytkowników";
"new_room.cell.invite_users.placeholder" = "Nazwy użytkowników";
Expand Down
5 changes: 2 additions & 3 deletions Rocket.Chat/Resources/pt-BR.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,10 @@
"new_room.cell.public_channel.description.public_only" = "Você só pode criar canais públicos";
"new_room.cell.public_channel.description.private_only" = "Você só pode criar canais privados";
"new_room.cell.read_only.title" = "Canal somente leitura";
"new_room.cell.read_only.description" = "Somente o admin pode escrever novas mensagens";
"new_room.cell.read_only.description" = "Apenas usuários autorizados podem enviar novas mensagens";
"new_room.group.channel.name" = "Nome do canal";
"new_room.group.channel.footer" = "O nome precisa ser escrito em minúsculo e ter menos que 22 caracteres";
"new_room.cell.channel_name.title" = "Nome do canal";
"new_room.group.invite_users" = "Invite users";
"new_room.group.invite_users" = "Convidar usuários";
"new_room.cell.invite_users.placeholder" = "Usernames";

// Notifications
Expand Down
2 changes: 1 addition & 1 deletion Rocket.Chat/Storyboards/Preferences.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="E-mail" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="8e8-Ux-MZf">
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="E-mail" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="8e8-Ux-MZf">
<rect key="frame" x="15" y="0.0" width="345" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="TAc-7M-Bpm"/>
Expand Down

0 comments on commit cb5f7f9

Please sign in to comment.