Skip to content
Snippets Groups Projects
Commit fe681c02 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Listen for messages only if needed in HomeFeature

parent a156a2aa
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!100Messenger - restore from backup
...@@ -219,6 +219,7 @@ let package = Package( ...@@ -219,6 +219,7 @@ let package = Package(
.target(name: "UserSearchFeature"), .target(name: "UserSearchFeature"),
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"), .product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
.product(name: "ComposablePresentation", package: "swift-composable-presentation"), .product(name: "ComposablePresentation", package: "swift-composable-presentation"),
.product(name: "XXClient", package: "elixxir-dapps-sdk-swift"),
.product(name: "XXMessengerClient", package: "elixxir-dapps-sdk-swift"), .product(name: "XXMessengerClient", package: "elixxir-dapps-sdk-swift"),
], ],
swiftSettings: swiftSettings swiftSettings: swiftSettings
......
...@@ -166,6 +166,9 @@ public let homeReducer = Reducer<HomeState, HomeAction, HomeEnvironment> ...@@ -166,6 +166,9 @@ public let homeReducer = Reducer<HomeState, HomeAction, HomeEnvironment>
if env.messenger.isConnected() == false { if env.messenger.isConnected() == false {
try env.messenger.connect() try env.messenger.connect()
}
if env.messenger.isListeningForMessages() == false {
try env.messenger.listenForMessages() try env.messenger.listenForMessages()
} }
......
...@@ -29,6 +29,7 @@ final class HomeFeatureTests: XCTestCase { ...@@ -29,6 +29,7 @@ final class HomeFeatureTests: XCTestCase {
store.environment.messenger.start.run = { messengerDidStartWithTimeout.append($0) } store.environment.messenger.start.run = { messengerDidStartWithTimeout.append($0) }
store.environment.messenger.isConnected.run = { false } store.environment.messenger.isConnected.run = { false }
store.environment.messenger.connect.run = { messengerDidConnect += 1 } store.environment.messenger.connect.run = { messengerDidConnect += 1 }
store.environment.messenger.isListeningForMessages.run = { false }
store.environment.messenger.listenForMessages.run = { messengerDidListenForMessages += 1 } store.environment.messenger.listenForMessages.run = { messengerDidListenForMessages += 1 }
store.environment.messenger.isLoggedIn.run = { false } store.environment.messenger.isLoggedIn.run = { false }
store.environment.messenger.isRegistered.run = { false } store.environment.messenger.isRegistered.run = { false }
...@@ -69,6 +70,7 @@ final class HomeFeatureTests: XCTestCase { ...@@ -69,6 +70,7 @@ final class HomeFeatureTests: XCTestCase {
store.environment.messenger.start.run = { messengerDidStartWithTimeout.append($0) } store.environment.messenger.start.run = { messengerDidStartWithTimeout.append($0) }
store.environment.messenger.isConnected.run = { false } store.environment.messenger.isConnected.run = { false }
store.environment.messenger.connect.run = { messengerDidConnect += 1 } store.environment.messenger.connect.run = { messengerDidConnect += 1 }
store.environment.messenger.isListeningForMessages.run = { false }
store.environment.messenger.listenForMessages.run = { messengerDidListenForMessages += 1 } store.environment.messenger.listenForMessages.run = { messengerDidListenForMessages += 1 }
store.environment.messenger.isLoggedIn.run = { false } store.environment.messenger.isLoggedIn.run = { false }
store.environment.messenger.isRegistered.run = { true } store.environment.messenger.isRegistered.run = { true }
...@@ -119,6 +121,7 @@ final class HomeFeatureTests: XCTestCase { ...@@ -119,6 +121,7 @@ final class HomeFeatureTests: XCTestCase {
store.environment.messageListener.run = { _ in Cancellable {} } store.environment.messageListener.run = { _ in Cancellable {} }
store.environment.messenger.start.run = { messengerDidStartWithTimeout.append($0) } store.environment.messenger.start.run = { messengerDidStartWithTimeout.append($0) }
store.environment.messenger.isConnected.run = { true } store.environment.messenger.isConnected.run = { true }
store.environment.messenger.isListeningForMessages.run = { true }
store.environment.messenger.isLoggedIn.run = { false } store.environment.messenger.isLoggedIn.run = { false }
store.environment.messenger.isRegistered.run = { true } store.environment.messenger.isRegistered.run = { true }
store.environment.messenger.logIn.run = { messengerDidLogIn += 1 } store.environment.messenger.logIn.run = { messengerDidLogIn += 1 }
...@@ -228,6 +231,7 @@ final class HomeFeatureTests: XCTestCase { ...@@ -228,6 +231,7 @@ final class HomeFeatureTests: XCTestCase {
store.environment.messageListener.run = { _ in Cancellable {} } store.environment.messageListener.run = { _ in Cancellable {} }
store.environment.messenger.start.run = { _ in } store.environment.messenger.start.run = { _ in }
store.environment.messenger.isConnected.run = { true } store.environment.messenger.isConnected.run = { true }
store.environment.messenger.isListeningForMessages.run = { true }
store.environment.messenger.isLoggedIn.run = { false } store.environment.messenger.isLoggedIn.run = { false }
store.environment.messenger.isRegistered.run = { throw error } store.environment.messenger.isRegistered.run = { throw error }
...@@ -260,6 +264,7 @@ final class HomeFeatureTests: XCTestCase { ...@@ -260,6 +264,7 @@ final class HomeFeatureTests: XCTestCase {
store.environment.messageListener.run = { _ in Cancellable {} } store.environment.messageListener.run = { _ in Cancellable {} }
store.environment.messenger.start.run = { _ in } store.environment.messenger.start.run = { _ in }
store.environment.messenger.isConnected.run = { true } store.environment.messenger.isConnected.run = { true }
store.environment.messenger.isListeningForMessages.run = { true }
store.environment.messenger.isLoggedIn.run = { false } store.environment.messenger.isLoggedIn.run = { false }
store.environment.messenger.isRegistered.run = { true } store.environment.messenger.isRegistered.run = { true }
store.environment.messenger.logIn.run = { throw error } store.environment.messenger.logIn.run = { throw error }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment