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 #449 from RocketChat/beta
Browse files Browse the repository at this point in the history
Merge beta 1.1.0 to master
  • Loading branch information
rafaelks authored May 2, 2017
2 parents d872292 + 068f40d commit f070eb7
Show file tree
Hide file tree
Showing 22 changed files with 480 additions and 133 deletions.
4 changes: 2 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def shared_pods
pod 'semver'

# UI
pod 'SideMenuController'
pod 'SideMenuController', :git => 'https://github.com/rafaelks/SideMenuController.git'
pod 'SlackTextViewController'
pod 'MobilePlayer'
pod 'URBMediaFocusViewController'
Expand Down Expand Up @@ -46,7 +46,7 @@ end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
config.build_settings['SWIFT_VERSION'] = '3.1'
end
end
end
48 changes: 29 additions & 19 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ PODS:
- Crashlytics (3.8.4):
- Fabric (~> 1.6.3)
- Fabric (1.6.11)
- FirebaseAnalytics (3.7.0):
- FirebaseCore (~> 3.5)
- FirebaseAnalytics (3.9.0):
- FirebaseCore (~> 3.6)
- FirebaseInstanceID (~> 1.0)
- GoogleToolboxForMac/NSData+zlib (~> 2.1)
- FirebaseCore (3.5.2):
- FirebaseCore (3.6.0):
- GoogleToolboxForMac/NSData+zlib (~> 2.1)
- FirebaseInstanceID (1.0.9)
- FirebaseInstanceID (1.0.10):
- FirebaseCore (~> 3.6)
- Google/Core (3.0.3):
- FirebaseAnalytics (~> 3.2)
- Google/SignIn (3.0.3):
Expand Down Expand Up @@ -38,16 +39,16 @@ PODS:
- GTMSessionFetcher/Full (1.1.9):
- GTMSessionFetcher/Core (= 1.1.9)
- MobilePlayer (1.2.0)
- Realm (2.5.1):
- Realm/Headers (= 2.5.1)
- Realm/Headers (2.5.1)
- RealmSwift (2.5.1):
- Realm (= 2.5.1)
- Realm (2.6.2):
- Realm/Headers (= 2.6.2)
- Realm/Headers (2.6.2)
- RealmSwift (2.6.2):
- Realm (= 2.6.2)
- SDWebImage (3.8.2):
- SDWebImage/Core (= 3.8.2)
- SDWebImage/Core (3.8.2)
- semver (1.0.0)
- SideMenuController (0.2.4)
- SideMenuController (0.2.4.1)
- SlackTextViewController (1.9.5)
- Starscream (2.0.4)
- SwiftyJSON (3.1.4)
Expand All @@ -63,37 +64,46 @@ DEPENDENCIES:
- RealmSwift
- SDWebImage (~> 3.8)
- semver
- SideMenuController
- SideMenuController (from `[email protected]:rafaelks/SideMenuController.git`)
- SlackTextViewController
- Starscream (~> 2.0.0)
- SwiftyJSON
- TSMarkdownParser
- URBMediaFocusViewController

EXTERNAL SOURCES:
SideMenuController:
:git: [email protected]:rafaelks/SideMenuController.git

CHECKOUT OPTIONS:
SideMenuController:
:commit: a3a55e08f4752b5a4e169c6a8b2ceee0096649f5
:git: [email protected]:rafaelks/SideMenuController.git

SPEC CHECKSUMS:
1PasswordExtension: e775a29310c65851e5a6cec1afc349ab4e334e47
Crashlytics: 79e236942ca1e7fc641df1feb9a275360a78ab6a
Fabric: 5911403591946b8228ab1c51d98f1d7137e863c6
FirebaseAnalytics: 0d1b7d81d5021155be37702a94ba1ec16d45365d
FirebaseCore: a024587e43778508700af8c6b1209f7c4516ba02
FirebaseInstanceID: 2d0518b1378fe9d685ef40cbdd63d2fdc1125339
FirebaseAnalytics: e5fe8486efc01bec33f6bf82e2fa9fce4b124052
FirebaseCore: 9691ee2ade70c098d7cf92440f4303f16d83ca75
FirebaseInstanceID: b9eedd6846fb5e1f0f7279e1deaa7a7e4cf8392e
Google: 813c467362eabc11385f5a5cc9ad0cb651a58f4e
GoogleSignIn: d7ad83f13480e1f30453471d00d19b5293ac46af
GoogleToolboxForMac: 8e329f1b599f2512c6b10676d45736bcc2cbbeb0
GTMOAuth2: 7fc9c10f5c745f4d9850419ea88889fe3baa6b7d
GTMSessionFetcher: 5c046c76a1f859bc9c187e918f18e4fc7bb57b5e
MobilePlayer: 069b13482499f14c25b6ce53f63a91e17975b073
Realm: 32f86104d37c8521f864d4274050b38ba6190733
RealmSwift: f719e7511c902b8908593e8f143f59e47931bdb6
Realm: 29222766425b9f831228f81b63f0e38a97a4d700
RealmSwift: d161a80f96cb91ae88391a7d5a9cf08024a7bc8e
SDWebImage: 098e97e6176540799c27e804c96653ee0833d13c
semver: efe6bf4af25bffab18d442592771be392210b5ce
SideMenuController: b463d2b3aa58e2afe57f57a07938fa9a647894ca
SideMenuController: 44670bc1e1c58d9460fc028e246926227edefec0
SlackTextViewController: fbcdadbb8090673f604484ff5b6eb8d77baed42a
Starscream: df5974ee928b157c8eda8af8de7c620276b7dfcc
SwiftyJSON: c2842d878f95482ffceec5709abc3d05680c0220
TSMarkdownParser: 114779f14d46e7fc6d9880d4797e5abcc01f92c3
URBMediaFocusViewController: 26779e301fe75ec0152fbe8b476bd06ccee9f9b3

PODFILE CHECKSUM: fd2ee0ec8db6ade1f173c9325ad871f595f369fe
PODFILE CHECKSUM: c32cfdea3bd2f983fe06f089235b2dba6f2247a4

COCOAPODS: 1.2.0
COCOAPODS: 1.2.1
16 changes: 10 additions & 6 deletions Rocket.Chat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
415029B91E72D541009F596C /* ChannelInfoDescriptionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 415029B81E72D541009F596C /* ChannelInfoDescriptionCell.swift */; };
415029BB1E72D553009F596C /* ChannelInfoUserCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 415029BA1E72D553009F596C /* ChannelInfoUserCell.swift */; };
415029BD1E72E0FD009F596C /* ChannelInfoCellProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 415029BC1E72E0FD009F596C /* ChannelInfoCellProtocol.swift */; };
4151807B1EAE249F0000A039 /* ChatDataControllerSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 415180791EAE249F0000A039 /* ChatDataControllerSpec.swift */; };
4151807C1EAE249F0000A039 /* ChatMessageTextViewModelSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4151807A1EAE249F0000A039 /* ChatMessageTextViewModelSpec.swift */; };
4151B44E1E2CF19A00F8AA1B /* UserModelHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4151B44D1E2CF19A00F8AA1B /* UserModelHandler.swift */; };
4151B4541E2D1A9E00F8AA1B /* SubscriptionModelHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4151B4531E2D1A9E00F8AA1B /* SubscriptionModelHandler.swift */; };
4151B4561E2D1AFF00F8AA1B /* SubscriptionModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4151B4551E2D1AFF00F8AA1B /* SubscriptionModelMapping.swift */; };
Expand Down Expand Up @@ -147,7 +149,6 @@
D32E28251DFD86C300D6019C /* LauncherProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D32E28221DFD86C300D6019C /* LauncherProtocol.swift */; };
D32E28261DFD86C300D6019C /* PersistencyCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = D32E28231DFD86C300D6019C /* PersistencyCoordinator.swift */; };
D3CFAFBD1E907D8900BADC0A /* ChatMessageTextViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3CFAFBC1E907D8900BADC0A /* ChatMessageTextViewModel.swift */; };
D3CFAFC01E907FCF00BADC0A /* ChatMessageTextViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3CFAFBF1E907FCF00BADC0A /* ChatMessageTextViewModelTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -197,6 +198,8 @@
415029B81E72D541009F596C /* ChannelInfoDescriptionCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChannelInfoDescriptionCell.swift; path = Views/Cells/Chat/Info/ChannelInfoDescriptionCell.swift; sourceTree = "<group>"; };
415029BA1E72D553009F596C /* ChannelInfoUserCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChannelInfoUserCell.swift; path = Views/Cells/Chat/Info/ChannelInfoUserCell.swift; sourceTree = "<group>"; };
415029BC1E72E0FD009F596C /* ChannelInfoCellProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChannelInfoCellProtocol.swift; path = Views/Cells/Chat/Info/ChannelInfoCellProtocol.swift; sourceTree = "<group>"; };
415180791EAE249F0000A039 /* ChatDataControllerSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChatDataControllerSpec.swift; path = Views/Chat/ChatDataControllerSpec.swift; sourceTree = "<group>"; };
4151807A1EAE249F0000A039 /* ChatMessageTextViewModelSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChatMessageTextViewModelSpec.swift; path = Views/Chat/ChatMessageTextViewModelSpec.swift; sourceTree = "<group>"; };
4151B44D1E2CF19A00F8AA1B /* UserModelHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UserModelHandler.swift; path = Models/Handler/UserModelHandler.swift; sourceTree = "<group>"; };
4151B4531E2D1A9E00F8AA1B /* SubscriptionModelHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SubscriptionModelHandler.swift; path = Models/Handler/SubscriptionModelHandler.swift; sourceTree = "<group>"; };
4151B4551E2D1AFF00F8AA1B /* SubscriptionModelMapping.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SubscriptionModelMapping.swift; path = Models/Mapping/SubscriptionModelMapping.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -322,7 +325,6 @@
D32E28221DFD86C300D6019C /* LauncherProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LauncherProtocol.swift; sourceTree = "<group>"; };
D32E28231DFD86C300D6019C /* PersistencyCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PersistencyCoordinator.swift; sourceTree = "<group>"; };
D3CFAFBC1E907D8900BADC0A /* ChatMessageTextViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatMessageTextViewModel.swift; sourceTree = "<group>"; };
D3CFAFBF1E907FCF00BADC0A /* ChatMessageTextViewModelTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatMessageTextViewModelTests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -857,7 +859,8 @@
D3CFAFBE1E907FC100BADC0A /* Chat */ = {
isa = PBXGroup;
children = (
D3CFAFBF1E907FCF00BADC0A /* ChatMessageTextViewModelTests.swift */,
415180791EAE249F0000A039 /* ChatDataControllerSpec.swift */,
4151807A1EAE249F0000A039 /* ChatMessageTextViewModelSpec.swift */,
);
name = Chat;
sourceTree = "<group>";
Expand Down Expand Up @@ -1077,7 +1080,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
5A6B94785E51D859BD0468DE /* [CP] Check Pods Manifest.lock */ = {
Expand All @@ -1092,7 +1095,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
6396FC1046FD3E86C9C3A600 /* [CP] Check Pods Manifest.lock */ = {
Expand Down Expand Up @@ -1356,6 +1359,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4151807B1EAE249F0000A039 /* ChatDataControllerSpec.swift in Sources */,
4171ABA51E7C056E009FC3F0 /* AvatarViewSpec.swift in Sources */,
417A70031D47918200FF46EE /* ResponseMessageSpec.swift in Sources */,
41BA89241D303D8B00CBF526 /* AuthManagerSpec.swift in Sources */,
Expand All @@ -1365,11 +1369,11 @@
4161333C1D46E32F00E09DA2 /* UserSpec.swift in Sources */,
4161333A1D46E0A200E09DA2 /* AuthSpec.swift in Sources */,
41DC7A1F1D3865FE00896FC0 /* MessageManagerSpec.swift in Sources */,
D3CFAFC01E907FCF00BADC0A /* ChatMessageTextViewModelTests.swift in Sources */,
41BAE3E91D71C15A00C2445A /* NSURLExtensionSpec.swift in Sources */,
416133401D46E6A800E09DA2 /* MessageSpec.swift in Sources */,
41ADDD4B1E9E787E0007A458 /* LoaderViewSpec.swift in Sources */,
41DC7A221D386B4700896FC0 /* StringExtensionSpec.swift in Sources */,
4151807C1EAE249F0000A039 /* ChatMessageTextViewModelSpec.swift in Sources */,
416133381D46DB1D00E09DA2 /* BaseModelSpec.swift in Sources */,
4161333E1D46E3AB00E09DA2 /* SubscriptionSpec.swift in Sources */,
);
Expand Down
11 changes: 10 additions & 1 deletion Rocket.Chat/Controllers/Chat/ChatDataController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,16 @@ final class ChatDataController {
return indexPaths
}

func remove(_ items: [ChatData]) {
func update(_ message: Message) -> Int {
for (index, _) in data.enumerated() {
var obj = data[index]

if obj.message?.identifier == message.identifier {
obj.message = message
return obj.indexPath.row
}
}

return -1
}
}
105 changes: 72 additions & 33 deletions Rocket.Chat/Controllers/Chat/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,10 @@ final class ChatViewController: SLKTextViewController {
}

fileprivate func scrollToBottom(_ animated: Bool = false) {
let totalItems = (collectionView?.numberOfItems(inSection: 0) ?? 0) - 1

if totalItems > 0 {
let indexPath = IndexPath(row: totalItems, section: 0)
collectionView?.scrollToItem(at: indexPath, at: .bottom, animated: animated)
}

let boundsHeight = collectionView?.bounds.size.height ?? 0
let sizeHeight = collectionView?.contentSize.height ?? 0
let offset = CGPoint(x: 0, y: max(sizeHeight - boundsHeight, 0))
collectionView?.setContentOffset(offset, animated: animated)
hideButtonScrollToBottom(animated: true)
}

Expand Down Expand Up @@ -253,17 +250,36 @@ final class ChatViewController: SLKTextViewController {
// MARK: Message

fileprivate func sendMessage() {
guard let message = textView.text else { return }

if message.characters.count == 0 {
return
}
guard let messageText = textView.text, messageText.characters.count > 0 else { return }

rightButton.isEnabled = false

SubscriptionManager.sendTextMessage(message, subscription: subscription) { [weak self] _ in
self?.textView.text = ""
self?.rightButton.isEnabled = true
var message: Message?
Realm.executeOnMainThread({ (realm) in
message = Message()
message?.internalType = ""
message?.createdAt = Date()
message?.text = messageText
message?.subscription = self.subscription
message?.identifier = String.random(18)
message?.temporary = true
message?.user = AuthManager.currentUser()

if let message = message {
realm.add(message)
}
})

if let message = message {
textView.text = ""
rightButton.isEnabled = true

SubscriptionManager.sendTextMessage(message) { _ in
Realm.executeOnMainThread({ (realm) in
message.temporary = false
realm.add(message, update: true)
})
}
}
}

Expand Down Expand Up @@ -317,30 +333,57 @@ final class ChatViewController: SLKTextViewController {
isRequestingHistory = true

messages = subscription.fetchMessages()
appendMessages(messages: Array(messages), updateScrollPosition: false, completion: {
guard let messages = self.messages else { return }
messagesToken?.stop()
messagesToken = messages.addNotificationBlock { [weak self] changes in
switch changes {
case .initial(let messages):
self?.appendMessages(messages: Array(messages), updateScrollPosition: false, completion: {
guard let messages = self?.messages else { return }

if messages.count == 0 {
self?.activityIndicator.startAnimating()
} else {
self?.scrollToBottom()
}
})

if messages.count == 0 {
self.activityIndicator.startAnimating()
} else {
self.scrollToBottom()
}
})
break
case .update(_, _, let insertions, let modifications):
guard let messages = self?.subscription.fetchMessages() else { return }

messagesToken?.stop()
messagesToken = messages.addNotificationBlock { [weak self] _ in
guard let isRequestingHistory = self?.isRequestingHistory, !isRequestingHistory else { return }
guard let messages = self?.subscription.fetchMessages() else { return }
if insertions.count > 0 {
self?.appendMessages(messages: Array(messages), updateScrollPosition: true, completion: nil)
}

self?.appendMessages(messages: Array(messages), updateScrollPosition: true, completion: nil)
self?.collectionView?.performBatchUpdates({
var indexPathModifications = [Int]()
for modified in modifications {
if let index = self?.dataController.update(messages[modified]) {
if index >= 0 {
indexPathModifications.append(index)
}
}
}

self?.collectionView?.reloadItems(at: indexPathModifications.map { IndexPath(row: $0, section: 0) })
}, completion: nil)

break
case .error:
break
}
}

MessageManager.getHistory(subscription, lastMessageDate: nil) { [weak self] in
guard let messages = self?.subscription.fetchMessages() else { return }

self?.appendMessages(messages: Array(messages), updateScrollPosition: false, completion: {
self?.activityIndicator.stopAnimating()
self?.scrollToBottom()

UIView.performWithoutAnimation {
self?.scrollToBottom()
}

self?.isRequestingHistory = false
})
}
Expand Down Expand Up @@ -368,8 +411,6 @@ final class ChatViewController: SLKTextViewController {
var offsetY = collectionView.contentOffset.y
var bottomOffset = contentHeight - offsetY

CATransaction.begin()
CATransaction.setDisableActions(true)
UIView.performWithoutAnimation {
collectionView.performBatchUpdates({
// Insert data into collectionView without moving it
Expand Down Expand Up @@ -418,8 +459,6 @@ final class ChatViewController: SLKTextViewController {
collectionView.contentOffset = offset
}

CATransaction.commit()

DispatchQueue.main.async {
completion?()
}
Expand Down
Loading

0 comments on commit f070eb7

Please sign in to comment.