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

Commit c420b1e

Browse files
authored
Merge pull request #2061 from RocketChat/develop
[RELEASE] Merge DEVELOP into BETA
2 parents da997c4 + e5324c9 commit c420b1e

25 files changed

Lines changed: 159 additions & 140 deletions

Rocket.Chat/API/Clients/MessagesClient.swift

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ struct MessagesClient: APIClient {
2929
}
3030

3131
func updateMessage(json: JSON) {
32+
if message.isInvalidated {
33+
return
34+
}
35+
3236
let server = AuthManager.selectedServerHost()
37+
3338
AnalyticsManager.log(event: .messageSent(subscriptionType: subscription.type.rawValue, server: server))
3439

3540
try? realm?.write {
@@ -45,6 +50,10 @@ struct MessagesClient: APIClient {
4550

4651
func setMessageOffline() {
4752
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
53+
if message.isInvalidated {
54+
return
55+
}
56+
4857
try? realm?.write {
4958
message.temporary = false
5059
message.failed = true
@@ -71,7 +80,9 @@ struct MessagesClient: APIClient {
7180
switch error {
7281
case .version:
7382
SubscriptionManager.sendTextMessage(message, completion: { response in
74-
updateMessage(json: response.result["result"])
83+
DispatchQueue.main.async {
84+
updateMessage(json: response.result["result"])
85+
}
7586
})
7687
default:
7788
setMessageOffline()
@@ -237,11 +248,13 @@ struct MessagesClient: APIClient {
237248
case .version:
238249
// version fallback
239250
MessageManager.react(message, emoji: emoji, completion: { _ in
240-
AnalyticsManager.log(
241-
event: .reaction(
242-
subscriptionType: message.subscription?.type.rawValue ?? ""
251+
DispatchQueue.main.async {
252+
AnalyticsManager.log(
253+
event: .reaction(
254+
subscriptionType: message.subscription?.type.rawValue ?? ""
255+
)
243256
)
244-
)
257+
}
245258
})
246259
default:
247260
Alert.defaultError.present()

Rocket.Chat/API/Requests/General/PublicSettingsRequest.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ final class PublicSettingsRequest: APIRequest {
3838
"CAS_enabled",
3939
"CAS_login_url",
4040
"API_Gitlab_URL",
41+
"API_Wordpress_URL",
4142
"Accounts_ShowFormLogin",
4243
"Accounts_RegistrationForm",
4344
"Accounts_PasswordReset",
@@ -50,6 +51,7 @@ final class PublicSettingsRequest: APIRequest {
5051
"Accounts_AllowUsernameChange",
5152
"Accounts_AllowEmailChange",
5253
"Accounts_AllowPasswordChange",
54+
"Accounts_OAuth_Wordpress_server_type",
5355
"FileUpload_Storage_Type",
5456
"Message_HideType_uj",
5557
"Message_HideType_ul",

Rocket.Chat/API/Requests/General/SpotlightRequest.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ final class SpotlightRequest: APIRequest {
1818
let query: String?
1919

2020
init(query: String) {
21-
self.query = "query=\(query)"
21+
if let encodedQuery = query.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) {
22+
self.query = "query=\(encodedQuery)"
23+
} else {
24+
self.query = ""
25+
}
2226
}
2327
}
2428

Rocket.Chat/Controllers/Auth/AuthTableViewController.swift

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,14 @@ class AuthTableViewController: BaseTableViewController {
124124

125125
override func viewDidLoad() {
126126
super.viewDidLoad()
127+
127128
title = serverURL.host
128129

129130
guard let settings = serverPublicSettings else { return }
130131

131132
if !settings.isUsernameEmailAuthenticationEnabled {
132-
emailAuthRow.registerButton.isHidden = true
133+
emailAuthRow.isHidden = true
134+
authSeparatorRow.isHidden = true
133135
} else {
134136
emailAuthRow.registerButton.isHidden = settings.registrationForm != .isPublic
135137
}
@@ -190,14 +192,33 @@ class AuthTableViewController: BaseTableViewController {
190192
return
191193
}
192194

193-
let loginService = loginServices[button.tag]
195+
let loginService = LoginService(value: loginServices[button.tag])
194196
if loginService.service == "gitlab", let url = serverPublicSettings?.gitlabUrl {
195197
loginServices[button.tag].serverUrl = url
196198
try? realm.write {
197199
loginService.serverUrl = url
198200
}
199201
}
200202

203+
if loginService.service == "wordpress" {
204+
if let url = serverPublicSettings?.wordpressUrl, !url.isEmpty {
205+
loginService.serverUrl = url
206+
207+
/*
208+
NOTE: If should be this, but API is broken
209+
serverPublicSettings?.oauthWordpressServerType == "custom"
210+
*/
211+
212+
loginService.mapWordPressCustom()
213+
} else { // oauthWordPressServerType == wordpress-com
214+
loginService.mapWordPress()
215+
} // missing implementation for wp-oauth-server
216+
217+
try? realm.write {
218+
realm.add(loginService, update: true)
219+
}
220+
}
221+
201222
switch loginService.type {
202223
case .cas:
203224
presentCASViewController(for: loginService)
@@ -328,7 +349,11 @@ extension AuthTableViewController {
328349

329350
return LoginServiceTableViewCell.rowHeight
330351
case kEmailAuthSection:
331-
return loginServices.count > 0 ? EmailAuthTableViewCell.rowHeightBelowSeparator : EmailAuthTableViewCell.rowHeight
352+
if loginServices.count > 0 {
353+
return emailAuthRow.isHidden ? .leastNonzeroMagnitude : EmailAuthTableViewCell.rowHeightBelowSeparator
354+
}
355+
356+
return EmailAuthTableViewCell.rowHeight
332357
default:
333358
return 0
334359
}

Rocket.Chat/Controllers/Base/BaseViewController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class BaseViewController: UIViewController, PopPushDelegate, NavigationBarTransp
6161
target: nil,
6262
action: nil
6363
)
64+
65+
popoverPresentationController?.backgroundColor = view.theme?.focusedBackground
6466
}
6567

6668
override func viewWillAppear(_ animated: Bool) {

Rocket.Chat/Controllers/Subscriptions/SubscriptionsList/SubscriptionsViewController.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,15 @@ final class SubscriptionsViewController: BaseViewController {
7777
tableView.performBatchUpdates({
7878
tableView.deleteRows(at: changes.deletions, with: .automatic)
7979
tableView.insertRows(at: changes.insertions, with: .automatic)
80+
tableView.reloadRows(at: changes.modifications, with: .none)
8081
}, completion: nil)
8182
} else {
8283
tableView.beginUpdates()
8384
tableView.deleteRows(at: changes.deletions, with: .automatic)
8485
tableView.insertRows(at: changes.insertions, with: .automatic)
86+
tableView.reloadRows(at: changes.modifications, with: .none)
8587
tableView.endUpdates()
8688
}
87-
88-
UIView.performWithoutAnimation {
89-
tableView.reloadRows(at: changes.modifications, with: .automatic)
90-
}
9189
}
9290
}
9391

Rocket.Chat/Controllers/User/UserDetail/UserDetailViewController.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,13 @@ class UserDetailViewController: BaseViewController, StoryboardInitializable {
7171
}
7272

7373
override func viewDidLoad() {
74-
super.viewDidLoad()
7574
updateForModel()
75+
super.viewDidLoad()
76+
}
77+
78+
override func viewDidLayoutSubviews() {
79+
super.viewDidLayoutSubviews()
80+
view.applyTheme()
7681
}
7782

7883
@IBAction func messageDidPress(_ sender: UIButton) {

Rocket.Chat/Extensions/Models/SubscriptionExtensions.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,22 @@ extension Results where Element == Subscription {
108108
}
109109

110110
func filterBy(name: String) -> Results<Subscription> {
111-
return filter("name CONTAINS[cd] %@", name)
111+
let userIdentifiersForDMs: [String] = Realm.current?.objects(User.self).filter(NSCompoundPredicate(
112+
type: .or,
113+
subpredicates: [
114+
NSPredicate(format: "name CONTAINS[cd] %@", name),
115+
NSPredicate(format: "username CONTAINS[cd] %@", name)
116+
]
117+
)).compactMap({ $0.identifier }) ?? []
118+
119+
return filter(NSCompoundPredicate(
120+
type: .or,
121+
subpredicates: [
122+
NSPredicate(format: "name CONTAINS[cd] %@", name),
123+
NSPredicate(format: "fname CONTAINS[cd] %@", name),
124+
NSPredicate(format: "otherUserId IN %@", userIdentifiersForDMs)
125+
]
126+
))
112127
}
113128

114129
}

Rocket.Chat/External/RCEmojiKit/Views/EmojiPicker/EmojiPicker.swift

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ final class EmojiPicker: UIView, RCEmojiKitLocalizable {
197197
setupCategoriesView()
198198
setupCollectionView()
199199
}
200+
201+
override func layoutSubviews() {
202+
super.layoutSubviews()
203+
applyTheme()
204+
}
200205
}
201206

202207
extension EmojiPicker: UICollectionViewDataSource {
@@ -346,28 +351,6 @@ private class EmojiPickerSectionHeaderView: UICollectionReusableView {
346351
// MARK: Themeable
347352

348353
extension EmojiPicker {
349-
override var theme: Theme? {
350-
guard let theme = super.theme else { return nil }
351-
guard isPopover else { return theme }
352-
let popoverTheme = Theme(
353-
backgroundColor: theme.focusedBackground,
354-
focusedBackground: theme.focusedBackground,
355-
auxiliaryBackground: theme.auxiliaryBackground,
356-
bannerBackground: theme.bannerBackground,
357-
titleText: theme.titleText,
358-
bodyText: theme.bodyText,
359-
controlText: theme.controlText,
360-
auxiliaryText: theme.auxiliaryText,
361-
tintColor: theme.tintColor,
362-
auxiliaryTintColor: theme.auxiliaryTintColor,
363-
hyperlink: theme.hyperlink,
364-
mutedAccent: theme.mutedAccent,
365-
strongAccent: theme.strongAccent,
366-
appearence: theme.appearence
367-
)
368-
return popoverTheme
369-
}
370-
371354
override func applyTheme() {
372355
super.applyTheme()
373356
skinToneButton.backgroundColor = currentSkinTone.color

Rocket.Chat/External/RCEmojiKit/Views/Reaction/ReactorListView.swift

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ final class ReactorListView: UIView {
4747

4848
@IBOutlet weak var reactorTableView: UITableView! {
4949
didSet {
50-
reactorTableView.bounces = false
5150
reactorTableView.tableFooterView = UIView()
5251

5352
reactorTableView.dataSource = self
@@ -82,6 +81,11 @@ final class ReactorListView: UIView {
8281
super.init(coder: aDecoder)
8382
commonInit()
8483
}
84+
85+
override func layoutSubviews() {
86+
super.layoutSubviews()
87+
applyTheme()
88+
}
8589
}
8690

8791
// MARK: Initialization
@@ -140,8 +144,8 @@ extension ReactorListView: UITableViewDelegate {
140144

141145
view.addSubview(stackView)
142146

147+
view.setThemeColor("backgroundColor: bannerBackground")
143148
view.applyTheme()
144-
view.backgroundColor = view.theme?.auxiliaryBackground
145149

146150
return view
147151
}
@@ -156,27 +160,3 @@ extension ReactorListView: UITableViewDelegate {
156160
selectedReactor(model.reactionViewModels[indexPath.section].reactors[indexPath.row], rect)
157161
}
158162
}
159-
160-
extension ReactorListView {
161-
override var theme: Theme? {
162-
guard let theme = super.theme else { return nil }
163-
guard isPopover else { return theme }
164-
let popoverTheme = Theme(
165-
backgroundColor: theme.focusedBackground,
166-
focusedBackground: theme.focusedBackground,
167-
auxiliaryBackground: theme.auxiliaryBackground,
168-
bannerBackground: theme.backgroundColor,
169-
titleText: theme.titleText,
170-
bodyText: theme.bodyText,
171-
controlText: theme.controlText,
172-
auxiliaryText: theme.auxiliaryText,
173-
tintColor: theme.tintColor,
174-
auxiliaryTintColor: theme.auxiliaryTintColor,
175-
hyperlink: theme.hyperlink,
176-
mutedAccent: theme.mutedAccent,
177-
strongAccent: theme.strongAccent,
178-
appearence: theme.appearence
179-
)
180-
return popoverTheme
181-
}
182-
}

0 commit comments

Comments
 (0)