Skip to content

Commit

Permalink
PR #5596
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello committed Aug 1, 2024
1 parent d0548a0 commit 434d7e3
Show file tree
Hide file tree
Showing 12 changed files with 254 additions and 254 deletions.
2 changes: 1 addition & 1 deletion app/lib/methods/userPreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { create, MMKVLoader, MMKVInstance, ProcessingModes, IOSAccessibleStates
const MMKV = new MMKVLoader()
// MODES.MULTI_PROCESS = ACCESSIBLE BY APP GROUP (iOS)
.setProcessingMode(ProcessingModes.MULTI_PROCESS)
.setAccessibleIOS(IOSAccessibleStates.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY)
.setAccessibleIOS(IOSAccessibleStates.AFTER_FIRST_UNLOCK)
.withEncryption()
.initialize();

Expand Down
2 changes: 1 addition & 1 deletion ios/NotificationService/NotificationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class NotificationService: UNNotificationServiceExtension {
return
}

rocketchat = RocketChat.instanceForServer(server: data.host.removeTrailingSlash())
rocketchat = RocketChat(server: data.host.removeTrailingSlash())

// If the notification has the content on the payload, show it
if data.notificationType != .messageIdOnly {
Expand Down
14 changes: 7 additions & 7 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ PODS:
- libwebp/sharpyuv (1.3.2)
- libwebp/webp (1.3.2):
- libwebp/sharpyuv
- MMKV (1.2.13):
- MMKVCore (~> 1.2.13)
- MMKVCore (1.2.16)
- MMKV (1.3.3):
- MMKVCore (~> 1.3.3)
- MMKVCore (1.3.9)
- nanopb (2.30910.0):
- nanopb/decode (= 2.30910.0)
- nanopb/encode (= 2.30910.0)
Expand Down Expand Up @@ -1041,7 +1041,7 @@ PODS:
- react-native-cookies (6.2.1):
- React-Core
- react-native-mmkv-storage (0.9.1):
- MMKV (= 1.2.13)
- MMKV (= 1.3.3)
- React-Core
- react-native-netinfo (11.3.1):
- React-Core
Expand Down Expand Up @@ -1689,8 +1689,8 @@ SPEC CHECKSUMS:
hermes-engine: 9cecf9953a681df7556b8cc9c74905de8f3293c0
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009
MMKV: aac95d817a100479445633f2b3ed8961b4ac5043
MMKVCore: 9cfef4c48c6c46f66226fc2e4634d78490206a48
MMKV: f902fb6719da13c2ab0965233d8963a59416f911
MMKVCore: af055b00e27d88cd92fad301c5fecd1ff9b26dd9
nanopb: 438bc412db1928dac798aa6fd75726007be04262
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
Expand Down Expand Up @@ -1719,7 +1719,7 @@ SPEC CHECKSUMS:
react-native-background-timer: 17ea5e06803401a379ebf1f20505b793ac44d0fe
react-native-cameraroll: 4593ffad9e619781aed27dda64739387d55ed402
react-native-cookies: f54fcded06bb0cda05c11d86788020b43528a26c
react-native-mmkv-storage: cfb6854594cfdc5f7383a9e464bb025417d1721c
react-native-mmkv-storage: 37d48fde35a00d1f48a69c86baa12b932838895b
react-native-netinfo: bdb108d340cdb41875c9ced535977cac6d2ff321
react-native-notifications: 4601a5a8db4ced6ae7cfc43b44d35fe437ac50c4
react-native-restart: 733a51ad137f15b0f8dc34c4082e55af7da00979
Expand Down
2 changes: 1 addition & 1 deletion ios/ReplyNotification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ReplyNotification: RNNotificationEventHandler {
if let data = (notification["ejson"] as? String)?.data(using: .utf8) {
if let payload = try? JSONDecoder().decode(Payload.self, from: data), let rid = payload.rid {
if let msg = (response as? UNTextInputNotificationResponse)?.userText {
let rocketchat = RocketChat.instanceForServer(server: payload.host.removeTrailingSlash())
let rocketchat = RocketChat(server: payload.host.removeTrailingSlash())
let backgroundTask = UIApplication.shared.beginBackgroundTask(expirationHandler: nil)
rocketchat.sendMessage(rid: rid, message: msg, threadIdentifier: payload.tmid) { response in
guard let response = response, response.success else {
Expand Down
440 changes: 220 additions & 220 deletions ios/RocketChatRN.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions ios/Shared/RocketChat/API/API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,21 @@ final class API {
final let credentials: Credentials?
final let decoder = JSONDecoder()

static var instances: [Server: API] = [:]

convenience init?(server: Server) {
guard let server = URL(string: server.removeTrailingSlash()) else {
return nil
}

guard let credentials = Storage().getCredentials(server: server.absoluteString) else {
return nil
}

self.init(server: server)
self.init(server: server, credentials: credentials)
}

init(server: URL) {
init(server: URL, credentials: Credentials) {
self.server = server
self.credentials = Storage.shared.getCredentials(server: server.absoluteString)
self.credentials = credentials
}

func fetch<T: Request>(request: T, retry: Retry? = nil, completion: @escaping((APIResponse<T.ResponseType>) -> Void)) {
Expand Down
5 changes: 3 additions & 2 deletions ios/Shared/RocketChat/Encryption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ final class Encryption {
private final let encoder = JSONEncoder()

init(server: String, rid: String) {
self.privateKey = Storage.shared.getPrivateKey(server: server)
self.credentials = Storage.shared.getCredentials(server: server)
let storage = Storage()
self.privateKey = storage.getPrivateKey(server: server)
self.credentials = storage.getCredentials(server: server)
self.server = server
self.rid = rid

Expand Down
13 changes: 0 additions & 13 deletions ios/Shared/RocketChat/RocketChat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ final class RocketChat {
let server: Server
let api: API?

static var instances: [Server: RocketChat] = [:]
var encryptionInstances: [RoomId: Encryption] = [:]

static private var queue = DispatchQueue(label: "chat.rocket.instanceQueue")
Expand All @@ -26,18 +25,6 @@ final class RocketChat {
self.api = API(server: server)
}

static func instanceForServer(server: Server) -> RocketChat {
queue.sync {
if let rocketchat = instances[server] {
return rocketchat
}

let rocketchat = RocketChat(server: server)
instances[server] = rocketchat
return rocketchat
}
}

func getPushWithId(_ msgId: String, completion: @escaping((Notification?) -> Void)) {
api?.fetch(request: PushRequest(msgId: msgId), retry: Retry(retries: 4)) { response in
switch response {
Expand Down
2 changes: 0 additions & 2 deletions ios/Shared/RocketChat/Storage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ struct Credentials {
}

final class Storage {
static let shared = Storage()

private let mmkv = MMKV.build()

func getCredentials(server: String) -> Credentials? {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"react-native-localize": "2.1.1",
"react-native-math-view": "3.9.5",
"react-native-mime-types": "2.3.0",
"react-native-mmkv-storage": "^0.9.1",
"react-native-mmkv-storage": "0.9.1",
"react-native-modal": "13.0.1",
"react-native-navigation-bar-color": "2.0.1",
"react-native-notifications": "5.1.0",
Expand Down
12 changes: 12 additions & 0 deletions patches/react-native-mmkv-storage+0.9.1.patch
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,15 @@ index dbea26b..2483375 100644
if(serviceName == nil){
serviceName = [[NSBundle mainBundle] bundleIdentifier];
}
diff --git a/node_modules/react-native-mmkv-storage/react-native-mmkv-storage.podspec b/node_modules/react-native-mmkv-storage/react-native-mmkv-storage.podspec
index dadb094..d660ac2 100644
--- a/node_modules/react-native-mmkv-storage/react-native-mmkv-storage.podspec
+++ b/node_modules/react-native-mmkv-storage/react-native-mmkv-storage.podspec
@@ -14,5 +14,5 @@ Pod::Spec.new do |s|
s.source_files = "ios/**/*.{h,m,mm}"
s.requires_arc = true
s.dependency 'React-Core'
- s.dependency 'MMKV', '1.2.13'
+ s.dependency 'MMKV', '1.3.3'
end
\ No newline at end of file
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12065,7 +12065,7 @@ [email protected]:
dependencies:
mime-db "~1.37.0"

react-native-mmkv-storage@^0.9.1:
[email protected]:
version "0.9.1"
resolved "https://registry.yarnpkg.com/react-native-mmkv-storage/-/react-native-mmkv-storage-0.9.1.tgz#0db7e8c1726713dce68704bb8795dc64096c8cbb"
integrity sha512-FzSx4PKxK2ocT/OuKGlaVziWZyQYHYLUx9595i1oXY263C5mG19PN5RiBgEGL2S5lK4VGUCzO85GAcsrNPtpOg==
Expand Down

0 comments on commit 434d7e3

Please sign in to comment.