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 #796 from RocketChat/beta
Browse files Browse the repository at this point in the history
[RELEASE] Merge beta into master
  • Loading branch information
rafaelks authored Oct 17, 2017
2 parents 35135b0 + 8191171 commit fdd28e8
Show file tree
Hide file tree
Showing 60 changed files with 1,256 additions and 384 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Before writing an issue, please make sure you're talking about the native application and not the Cordova one. If you are looking to open an issue to the Cordova application, go to this URL: https://github.com/RocketChat/Rocket.Chat.Cordova.
Before writing an issue, please make sure you're talking about the native application (called Rocket.Chat+ in the App Store) and not the Cordova one (called Rocket.Chat in the App Store). If you are looking to open an issue to the Cordova application, go to this URL: https://github.com/RocketChat/Rocket.Chat.Cordova.

- Your Rocket.Chat app version: ####
- Your Rocket.Chat server version: ####
Expand Down
4 changes: 4 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ excluded:
- Rocket.Chat/Extensions/UIColorCSSColorsExtension.swift
line_length: 300
reporter: "xcode"

identifier_name:
excluded:
- id
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def shared_pods

# UI
pod 'SideMenuController', :git => 'https://github.com/rafaelks/SideMenuController.git'
pod 'SlackTextViewController', :git => 'https://github.com/rafaelks/SlackTextViewController.git', :branch => 'chore/swift4_xcode9_ios11'
pod 'SlackTextViewController', :git => 'https://github.com/rafaelks/SlackTextViewController.git', :branch => 'master'
pod 'MobilePlayer'
pod 'SimpleImageViewer', :git => 'https://github.com/cardoso/SimpleImageViewer.git'

Expand Down
8 changes: 4 additions & 4 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ DEPENDENCIES:
- semver (from `https://github.com/rafaelks/Semver.Swift.git`, branch `chore/swift4`)
- SideMenuController (from `https://github.com/rafaelks/SideMenuController.git`)
- SimpleImageViewer (from `https://github.com/cardoso/SimpleImageViewer.git`)
- SlackTextViewController (from `https://github.com/rafaelks/SlackTextViewController.git`, branch `chore/swift4_xcode9_ios11`)
- SlackTextViewController (from `https://github.com/rafaelks/SlackTextViewController.git`, branch `master`)
- Starscream (from `https://github.com/daltoniam/Starscream.git`, branch `swift4`)
- SwiftyJSON (from `https://github.com/SwiftyJSON/SwiftyJSON.git`, tag `4.0.0-alpha.1`)

Expand All @@ -85,7 +85,7 @@ EXTERNAL SOURCES:
SimpleImageViewer:
:git: https://github.com/cardoso/SimpleImageViewer.git
SlackTextViewController:
:branch: chore/swift4_xcode9_ios11
:branch: master
:git: https://github.com/rafaelks/SlackTextViewController.git
Starscream:
:branch: swift4
Expand All @@ -108,7 +108,7 @@ CHECKOUT OPTIONS:
:commit: 26b54aefeced8039e85f1174ed5e2cd2dfc0251f
:git: https://github.com/cardoso/SimpleImageViewer.git
SlackTextViewController:
:commit: 7deec6edd55ce2e11441f542a18f374ee86bd6ec
:commit: 9ed57435f793d7ed6afa370519a221f28a53e620
:git: https://github.com/rafaelks/SlackTextViewController.git
Starscream:
:commit: e9d10000eca3f682650fb674eecc73ad709b316a
Expand Down Expand Up @@ -142,6 +142,6 @@ SPEC CHECKSUMS:
Starscream: 087670fe088bb12c04398fc343442a4b9eb96b86
SwiftyJSON: c4d27c2ca659d5c91460cd17cc60fd212b26074d

PODFILE CHECKSUM: 898cfdfeab670ca52c619e14ba1822c22affbc38
PODFILE CHECKSUM: d79d13915969296b4f7712eed3cf63b5934fd9c0

COCOAPODS: 1.3.1
28 changes: 28 additions & 0 deletions Rocket.Chat.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//
// SubscriptionMembersRequest.swift
// Rocket.Chat
//
// Created by Matheus Cardoso on 9/21/17.
// Copyright © 2017 Rocket.Chat. All rights reserved.
//

import SwiftyJSON
import Foundation

typealias SubscriptionMessagesResult = APIResult<SubscriptionMessagesRequest>

fileprivate extension SubscriptionType {
var path: String {
switch self {
case .channel:
return "/api/v1/channels.messages"
case .group:
return "/api/v1/groups.messages"
case .directMessage:
return "/api/v1/dm.messages"
}
}
}

class SubscriptionMessagesRequest: APIRequest {
var path: String {
return type.path
}

var query: String?

let roomId: String?
let roomName: String?
let type: SubscriptionType

init(roomId: String, type: SubscriptionType = .channel, query: String? = nil) {
self.type = type
self.roomId = roomId
self.roomName = nil

if let query = query {
self.query = "roomId=\(roomId)&query=\(query)"
} else {
self.query = "roomId=\(roomId)"
}
}

init(roomName: String, type: SubscriptionType = .channel) {
self.type = type
self.roomName = roomName
self.roomId = nil

if let query = query {
self.query = "roomName=\(roomName)&query=\(query)"
} else {
self.query = "roomName=\(roomName)"
}
}
}

extension APIResult where T == SubscriptionMessagesRequest {
var messages: [Message?]? {
return raw?["messages"].arrayValue.map {
let message = Message()
message.map($0, realm: nil)
return message
}
}

var count: Int? {
return raw?["count"].int
}

var offset: Int? {
return raw?["offset"].int
}

var total: Int? {
return raw?["total"].int
}
}
6 changes: 3 additions & 3 deletions Rocket.Chat/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
}

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
return GIDSignIn.sharedInstance().handle(
url,
sourceApplication: options[.sourceApplication] as? String,
Expand All @@ -49,11 +49,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

// MARK: Remote Notification

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
Log.debug("Notification: \(userInfo)")
}

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
Log.debug("Notification: \(userInfo)")
}

Expand Down
11 changes: 7 additions & 4 deletions Rocket.Chat/Controllers/Auth/AuthViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,13 @@ final class AuthViewController: BaseViewController {
}

func stopLoading() {
textFieldUsername.alpha = 1
textFieldPassword.alpha = 1
DispatchQueue.main.async(execute: {
self.textFieldUsername.alpha = 1
self.textFieldPassword.alpha = 1
self.activityIndicator.stopAnimating()
})

connecting = false
activityIndicator.stopAnimating()
buttonAuthenticateGoogle.isEnabled = true
}

Expand All @@ -185,7 +188,7 @@ final class AuthViewController: BaseViewController {
"username": email,
"ldapPass": password,
"ldapOptions": []
] as [String : Any]
] as [String: Any]

AuthManager.auth(params: params, completion: self.handleAuthenticationResponse)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extension AuthViewController: GIDSignInDelegate {
"idToken": user.authentication.idToken,
"expiresIn": Int(user.authentication.accessTokenExpirationDate.timeIntervalSinceNow),
"scope": "profile"
] as [String : Any]
] as [String: Any]

AuthManager.auth(params: params, completion: self.handleAuthenticationResponse)
}
Expand Down
27 changes: 16 additions & 11 deletions Rocket.Chat/Controllers/Auth/ConnectServerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ final class ConnectServerViewController: BaseViewController {

internal let defaultURL = "https://open.rocket.chat"
internal var connecting = false
internal var serverURL: URL!
var url: URL? {
guard var urlText = textFieldServerURL.text else { return nil }
if urlText.isEmpty {
urlText = defaultURL
}
return URL(string: urlText, scheme: "https")
}

var serverPublicSettings: AuthSettings?

Expand Down Expand Up @@ -57,6 +63,11 @@ final class ConnectServerViewController: BaseViewController {

SocketManager.sharedInstance.socket?.disconnect()
DatabaseManager.cleanInvalidDatabases()

if let applicationServerURL = AppManager.applicationServerURL {
textFieldServerURL.text = applicationServerURL.host
connect()
}
}

override func viewDidAppear(_ animated: Bool) {
Expand All @@ -81,7 +92,7 @@ final class ConnectServerViewController: BaseViewController {

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let controller = segue.destination as? AuthViewController, segue.identifier == "Auth" {
controller.serverURL = serverURL
controller.serverURL = url?.socketURL()
controller.serverPublicSettings = self.serverPublicSettings
}
}
Expand Down Expand Up @@ -123,16 +134,11 @@ final class ConnectServerViewController: BaseViewController {
}

func connect() {
var text = textFieldServerURL.text ?? ""
if text.characters.count == 0 {
text = defaultURL
}
textFieldServerURL.text = url?.absoluteString

guard let url = URL(string: text) else { return alertInvalidURL() }
guard let url = url else { return alertInvalidURL() }
guard let socketURL = url.socketURL() else { return alertInvalidURL() }

API.shared.host = url

// Check if server already exists and connect to that instead
if let servers = DatabaseManager.servers {
let sameServerIndex = servers.index(where: {
Expand All @@ -157,8 +163,7 @@ final class ConnectServerViewController: BaseViewController {
activityIndicator.startAnimating()
textFieldServerURL.resignFirstResponder()

serverURL = socketURL

API.shared.host = url
validate { [weak self] (_, error) in
guard !error else {
DispatchQueue.main.async {
Expand Down
5 changes: 5 additions & 0 deletions Rocket.Chat/Controllers/Base/BaseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
import UIKit

class BaseViewController: UIViewController {
func alert(title: String, message: String) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
present(alert, animated: true, completion: nil)
}

override func viewDidLoad() {
super.viewDidLoad()
Expand Down
36 changes: 30 additions & 6 deletions Rocket.Chat/Controllers/Chat/ChannelInfoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import UIKit

fileprivate typealias ListSegueData = (title: String, query: String?)

class ChannelInfoViewController: BaseViewController {

var tableViewData: [[Any]] = [] {
Expand All @@ -22,8 +24,8 @@ class ChannelInfoViewController: BaseViewController {

let channelInfoData = [
ChannelInfoDetailCellData(title: localized("chat.info.item.members"), detail: "", action: showMembersList),
ChannelInfoDetailCellData(title: localized("chat.info.item.pinned"), detail: ""),
ChannelInfoDetailCellData(title: localized("chat.info.item.starred"), detail: "")
ChannelInfoDetailCellData(title: localized("chat.info.item.pinned"), detail: "", action: showPinnedList),
ChannelInfoDetailCellData(title: localized("chat.info.item.starred"), detail: "", action: showStarredList)
]

if subscription.type == .directMessage {
Expand Down Expand Up @@ -85,10 +87,35 @@ class ChannelInfoViewController: BaseViewController {
self.performSegue(withIdentifier: "toMembersList", sender: self)
}

func showPinnedList() {
let data = ListSegueData(title: localized("chat.messages.pinned.list.title"), query: "{\"pinned\":true}")
self.performSegue(withIdentifier: "toMessagesList", sender: data)
}

func showStarredList() {
guard let userId = AuthManager.currentUser()?.identifier else {
alert(title: localized("error.socket.default_error_title"), message: "error.socket.default_error_message")
return
}

let data = ListSegueData(title: localized("chat.messages.starred.list.title"), query: "{\"starred._id\":{\"$in\":[\"\(userId)\"]}}")
self.performSegue(withIdentifier: "toMessagesList", sender: data)
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let membersList = segue.destination as? MembersListViewController {
membersList.data.subscription = self.subscription
}

if let messagesList = segue.destination as? MessagesListViewController {

messagesList.data.subscription = self.subscription

if let segueData = sender as? ListSegueData {
messagesList.data.title = segueData.title
messagesList.data.query = segueData.query
}
}
}

// MARK: IBAction
Expand Down Expand Up @@ -179,9 +206,7 @@ extension ChannelInfoViewController: UITableViewDelegate {

if let data = data as? ChannelInfoDetailCellData {
guard let action = data.action else {
let alert = UIAlertController(title: "Ops!", message: "We're still working on this feature, stay tunned!", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
present(alert, animated: true, completion: nil)
alert(title: localized("alert.feature.wip.title"), message: localized("alert.feature.wip.message"))
return
}

Expand All @@ -192,7 +217,6 @@ extension ChannelInfoViewController: UITableViewDelegate {
}
}
}

}

// MARK: UITableViewDataSource
Expand Down
27 changes: 4 additions & 23 deletions Rocket.Chat/Controllers/Chat/ChatControllerMessageActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,6 @@
import UIKit

extension ChatViewController {

fileprivate func quoteStringFor(_ message: Message) -> String? {
guard let url = subscription.auth?.baseURL() else { return nil }
guard let id = message.identifier else { return nil }

let path: String

switch subscription.type {
case .channel:
path = "channel"
case .group:
path = "group"
case .directMessage:
path = "direct"
}

return "[ ](\(url)/\(path)/\(subscription.name)?msg=\(id))"
}

func presentActionsFor(_ message: Message, view: UIView) {
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)

Expand Down Expand Up @@ -63,10 +44,11 @@ extension ChatViewController {
}))

alert.addAction(UIAlertAction(title: localized("chat.message.actions.quote"), style: .default, handler: { [weak self] (_) in
guard let quoteString = self?.quoteStringFor(message) else { return }
guard let text = self?.textView.text else { return }
self?.reply(to: message, onlyQuote: true)
}))

self?.textView.text = "\(text) \(quoteString)"
alert.addAction(UIAlertAction(title: localized("chat.message.actions.reply"), style: .default, handler: { [weak self] (_) in
self?.reply(to: message)
}))

alert.addAction(UIAlertAction(title: localized("global.cancel"), style: .cancel, handler: nil))
Expand All @@ -93,5 +75,4 @@ extension ChatViewController {
self.present(alert, animated: true, completion: nil)
}
}

}
Loading

0 comments on commit fdd28e8

Please sign in to comment.