Skip to content

Commit b758daf

Browse files
mauritz-megagmagpayo
authored andcommitted
IOS-6901: Update SDKNodesUpdateListenerRepository on node updates to match MEGAGlobalDelegate
(cherry picked from commit 4fc93ca)
1 parent f2fd948 commit b758daf

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

MEGA.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
0DE3037826B25AA100E4A66B /* FileProviderItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DE3035F26B11E7800E4A66B /* FileProviderItem.swift */; };
2929
0E32FFAA293E817A004BB11D /* NodeUpdateRepositoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E32FFA9293E8179004BB11D /* NodeUpdateRepositoryTests.swift */; };
3030
0E32FFB2293E896A004BB11D /* NodeUpdateRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E32FFB1293E896A004BB11D /* NodeUpdateRepository.swift */; };
31+
0E6F57B4299DEB13005C279F /* SDKNodesUpdateListenerRepositoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E6F57B3299DEB13005C279F /* SDKNodesUpdateListenerRepositoryTests.swift */; };
3132
12084048286120020079127B /* SearchOperation+Initialize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12084047286120020079127B /* SearchOperation+Initialize.swift */; };
3233
1208CEC527FA49EB00F514D4 /* PhotoCellVideoDurationViewModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1208CEC427FA49EB00F514D4 /* PhotoCellVideoDurationViewModifier.swift */; };
3334
120B4A7927430F3E00312B35 /* Strings+Generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 120B4A7827430F3E00312B35 /* Strings+Generated.swift */; };
@@ -2691,6 +2692,7 @@
26912692
0DE3035F26B11E7800E4A66B /* FileProviderItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderItem.swift; sourceTree = "<group>"; };
26922693
0E32FFA9293E8179004BB11D /* NodeUpdateRepositoryTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NodeUpdateRepositoryTests.swift; sourceTree = "<group>"; };
26932694
0E32FFB1293E896A004BB11D /* NodeUpdateRepository.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NodeUpdateRepository.swift; sourceTree = "<group>"; };
2695+
0E6F57B3299DEB13005C279F /* SDKNodesUpdateListenerRepositoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDKNodesUpdateListenerRepositoryTests.swift; sourceTree = "<group>"; };
26942696
12084047286120020079127B /* SearchOperation+Initialize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SearchOperation+Initialize.swift"; sourceTree = "<group>"; };
26952697
1208CEC427FA49EB00F514D4 /* PhotoCellVideoDurationViewModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoCellVideoDurationViewModifier.swift; sourceTree = "<group>"; };
26962698
120B4A7827430F3E00312B35 /* Strings+Generated.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Strings+Generated.swift"; sourceTree = "<group>"; };
@@ -5434,6 +5436,7 @@
54345436
0E32FFA9293E8179004BB11D /* NodeUpdateRepositoryTests.swift */,
54355437
94417EAE296D825B007C9230 /* RubbishBinRepositoryTests.swift */,
54365438
B5CC2A632994A22800A966A0 /* ShareRepositoryTests.swift */,
5439+
0E6F57B3299DEB13005C279F /* SDKNodesUpdateListenerRepositoryTests.swift */,
54375440
);
54385441
path = Repos;
54395442
sourceTree = "<group>";
@@ -14549,6 +14552,7 @@
1454914552
C45A2E3825D2F80900915A83 /* NodeInfoUseCaseTests.swift in Sources */,
1455014553
BFDE0EEB263A44BC00FC586E /* MockUserInviteUseCase.swift in Sources */,
1455114554
8340CB1C284F5507007C3B39 /* HeaderViewModelTests.swift in Sources */,
14555+
0E6F57B4299DEB13005C279F /* SDKNodesUpdateListenerRepositoryTests.swift in Sources */,
1455214556
B6E18AEF29372FA300EDFC10 /* PhotoLibraryCollectionViewScrollTrackerTests.swift in Sources */,
1455314557
C45A2E0825D2B9DE00915A83 /* MockAudioPlaylistViewRouter.swift in Sources */,
1455414558
B5CC2A662994AD8C00A966A0 /* MockShareList.swift in Sources */,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import XCTest
2+
@testable import MEGA
3+
4+
final class SDKNodesUpdateListenerRepositoryTests: XCTestCase {
5+
6+
func testMEGAGlobalDelegateonNodesUpdate_shouldPassNodeEntitiesToUpdateHandler() {
7+
let mockSdk = MockSdk()
8+
let repo = SDKNodesUpdateListenerRepository(sdk: mockSdk)
9+
let nodes = [MockNode(handle: 1),
10+
MockNode(handle: 2)]
11+
let exp = expectation(description: "SDK onNodesUpdate pass to onNodesUpdateHandler")
12+
repo.onNodesUpdateHandler = {
13+
XCTAssertEqual($0, nodes.toNodeEntities())
14+
exp.fulfill()
15+
}
16+
repo.onNodesUpdate(mockSdk, nodeList: MockNodeList(nodes: nodes))
17+
wait(for: [exp], timeout: 0.5)
18+
}
19+
}

iMEGA/Home/Repository/SDK/SDKNodesUpdateListenerRepository.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import MEGADomain
22

3-
final class SDKNodesUpdateListenerRepository: NSObject, MEGAGlobalDelegate, NodesUpdateListenerProtocol {
3+
final class SDKNodesUpdateListenerRepository: NSObject, NodesUpdateListenerProtocol {
44
var onNodesUpdateHandler: (([NodeEntity]) -> Void)?
55

66
private let sdk: MEGASdk
@@ -14,8 +14,10 @@ final class SDKNodesUpdateListenerRepository: NSObject, MEGAGlobalDelegate, Node
1414
deinit {
1515
sdk.remove(self)
1616
}
17-
18-
func onNodesUpdateHandler(_ api: MEGASdk, nodeList: MEGANodeList?) {
17+
}
18+
19+
extension SDKNodesUpdateListenerRepository: MEGAGlobalDelegate {
20+
func onNodesUpdate(_ api: MEGASdk, nodeList: MEGANodeList?) {
1921
guard let updatedNodes = nodeList?.toNodeEntities() else { return }
2022
onNodesUpdateHandler?(updatedNodes)
2123
}

0 commit comments

Comments
 (0)