Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: inject self profile views monitor - WPB-15038 #2348

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ final class ConversationListViewControllerSnapshotTests: XCTestCase {

zClientViewController = ZClientViewController(
account: coreDataStack.account,
selfProfileViewsMonitor: SelfProfileViewsMonitorImplementation(),
userSession: userSession,
trackingManager: nil
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ final class ConversationListViewControllerViewModelSnapshotTests: XCTestCase {
let selfUser = MockUserType.createSelfUser(name: "Bob")
sut = ConversationListViewController.ViewModel(
account: account,
selfProfileViewsMonitor: MockSelfProfileViewsMonitorImplementation(didViewSelfProfile: false),
selfUserLegalHoldSubject: selfUser,
userSession: userSession,
isSelfUserE2EICertifiedUseCase: mockIsSelfUserE2EICertifiedUseCase,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ final class ConversationListViewControllerViewModelTests: XCTestCase {

sut = ConversationListViewController.ViewModel(
account: account,
selfProfileViewsMonitor: MockSelfProfileViewsMonitorImplementation(didViewSelfProfile: false),
selfUserLegalHoldSubject: selfUser,
userSession: userSession,
isSelfUserE2EICertifiedUseCase: mockIsSelfUserE2EICertifiedUseCase,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Wire
// Copyright (C) 2025 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//

@testable import Wire

class MockSelfProfileViewsMonitorImplementation: SelfProfileViewsMonitor {
El-Fitz marked this conversation as resolved.
Show resolved Hide resolved

private(set) var didViewSelfProfile: Bool
private let onDidViewSelfProfileCallback: @Sendable () -> Void

init(didViewSelfProfile: Bool, onDidViewSelfProfileCallback: @escaping @Sendable () -> Void = {}) {
self.didViewSelfProfile = didViewSelfProfile
self.onDidViewSelfProfileCallback = onDidViewSelfProfileCallback
}

func onDidViewSelfProfile() {
didViewSelfProfile = true
onDidViewSelfProfileCallback()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ final class ConversationViewControllerSnapshotTests: ZMSnapshotTestCase, CoreDat

let zClientViewController = ZClientViewController(
account: mockAccount,
selfProfileViewsMonitor: SelfProfileViewsMonitorImplementation(),
userSession: userSession,
trackingManager: nil
)
Expand Down
1 change: 1 addition & 0 deletions wire-ios/Wire-iOS Tests/ZClientViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ final class ZClientViewControllerTests: XCTestCase {
userSession.coreDataStack = coreDataFixture.coreDataStack
sut = ZClientViewController(
account: Account.mockAccount(imageData: mockImageData),
selfProfileViewsMonitor: MockSelfProfileViewsMonitorImplementation(didViewSelfProfile: false),
userSession: userSession,
trackingManager: nil
)
Expand Down
4 changes: 4 additions & 0 deletions wire-ios/Wire-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@
6636CFDE2C519980001403F9 /* EditingStateControllable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6636CFDD2C519980001403F9 /* EditingStateControllable.swift */; };
669105C327397E6A00324115 /* NSAttributedString+DownTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 669105C227397E6900324115 /* NSAttributedString+DownTests.swift */; };
70355A7127AAD96E00F02C76 /* SecurityLevelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70355A7027AAD96E00F02C76 /* SecurityLevelView.swift */; };
764C478D2D1B32C100227531 /* MockSelfProfileViewsMonitorImplementation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 764C478C2D1B32BE00227531 /* MockSelfProfileViewsMonitorImplementation.swift */; };
76D15E712CEFAE8A0059215D /* WireIndividualToTeamMigrationUI in Frameworks */ = {isa = PBXBuildFile; productRef = 76D15E702CEFAE8A0059215D /* WireIndividualToTeamMigrationUI */; };
7A702FB7286322D800004580 /* ConversationEncryptionProtocolCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A702FB6286322D800004580 /* ConversationEncryptionProtocolCell.swift */; };
7C0BB6E61FE682A200386A19 /* AccountSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C0BB6E41FE680F200386A19 /* AccountSelectionViewController.swift */; };
Expand Down Expand Up @@ -2614,6 +2615,7 @@
6636CFDD2C519980001403F9 /* EditingStateControllable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditingStateControllable.swift; sourceTree = "<group>"; };
669105C227397E6900324115 /* NSAttributedString+DownTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSAttributedString+DownTests.swift"; sourceTree = "<group>"; };
70355A7027AAD96E00F02C76 /* SecurityLevelView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SecurityLevelView.swift; sourceTree = "<group>"; };
764C478C2D1B32BE00227531 /* MockSelfProfileViewsMonitorImplementation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockSelfProfileViewsMonitorImplementation.swift; sourceTree = "<group>"; };
7A702FB6286322D800004580 /* ConversationEncryptionProtocolCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationEncryptionProtocolCell.swift; sourceTree = "<group>"; };
7C0BB6E41FE680F200386A19 /* AccountSelectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSelectionViewController.swift; sourceTree = "<group>"; };
7C23A26B20247474005FEB54 /* ShareViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewControllerTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -8034,6 +8036,7 @@
EF4C5D4C23351D230092CA38 /* Container */ = {
isa = PBXGroup;
children = (
764C478C2D1B32BE00227531 /* MockSelfProfileViewsMonitorImplementation.swift */,
A98ECDF2232A9564006A57FD /* MockConversationListContainer.swift */,
EFAFCA8C213433D6002B31A6 /* ConversationListViewControllerSnapshotTests.swift */,
A98ECDF0232A94DD006A57FD /* ConversationListViewControllerViewModelSnapshotTests.swift */,
Expand Down Expand Up @@ -10120,6 +10123,7 @@
EF159F381FD59607006E0A9C /* TextFieldValidatorTests.swift in Sources */,
1658C19620A1E2FA00148F6D /* MockVoiceChannel.swift in Sources */,
5502C6E522B7B800000684B7 /* LegalHoldAlertFactoryTests.swift in Sources */,
764C478D2D1B32C100227531 /* MockSelfProfileViewsMonitorImplementation.swift in Sources */,
BF5127161CC9119400F23DEA /* ZMSnapshotTestCase.swift in Sources */,
E9B580CC27B3E71900A5814D /* ConversationOptionsServicesViewControllerTests.swift in Sources */,
0608828F29EC742B0053772B /* ConversationMessageFailedRecipientsTests.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ final class ConversationListViewController: UIViewController {
) {
let viewModel = ConversationListViewController.ViewModel(
account: account,
selfProfileViewsMonitor: SelfProfileViewsMonitorImplementation(),
selfUserLegalHoldSubject: selfUserLegalHoldSubject,
userSession: userSession,
isSelfUserE2EICertifiedUseCase: isSelfUserE2EICertifiedUseCase,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@

init(
account: Account,
selfProfileViewsMonitor: SelfProfileViewsMonitor,
selfUserLegalHoldSubject: SelfUserLegalHoldable,
userSession: UserSession,
isSelfUserE2EICertifiedUseCase: IsSelfUserE2EICertifiedUseCaseProtocol,
Expand All @@ -144,6 +145,7 @@
getUserAccountImageSourceUseCase: any GetUserAccountImageSourceUseCaseProtocol
) {
self.account = account
self.selfProfileViewsMonitor = selfProfileViewsMonitor
self.selfUserLegalHoldSubject = selfUserLegalHoldSubject
self.userSession = userSession
self.isSelfUserE2EICertifiedUseCase = isSelfUserE2EICertifiedUseCase
Expand All @@ -153,7 +155,6 @@
self.notificationCenter = notificationCenter
self.mainCoordinator = mainCoordinator
self.getUserAccountImageSourceUseCase = getUserAccountImageSourceUseCase
self.selfProfileViewsMonitor = SelfProfileViewsMonitorImplementation()
super.init()

updateE2EICertifiedStatus()
Expand Down Expand Up @@ -182,7 +183,7 @@
extension ConversationListViewController.ViewModel {

func setupObservers() {

Check warning on line 186 in wire-ios/Wire-iOS/Sources/UserInterface/ConversationList/Container/ViewModel/ConversationListViewControllerViewModel.swift

View workflow job for this annotation

GitHub Actions / Test Results

'shared()' is deprecated: This shared instance has been deprecated. Don't use it.

'shared()' is deprecated: This shared instance has been deprecated. Don't use it.

Check warning on line 186 in wire-ios/Wire-iOS/Sources/UserInterface/ConversationList/Container/ViewModel/ConversationListViewControllerViewModel.swift

View workflow job for this annotation

GitHub Actions / Test Results

'shared()' is deprecated: This shared instance has been deprecated. Don't use it.

'shared()' is deprecated: This shared instance has been deprecated. Don't use it.
if let userSession = ZMUserSession.shared() {
userObservationToken = userSession.addUserObserver(self, for: selfUserLegalHoldSubject)

Expand Down Expand Up @@ -325,7 +326,7 @@

extension ConversationListViewController.ViewModel: UserObserving {

@MainActor

Check warning on line 329 in wire-ios/Wire-iOS/Sources/UserInterface/ConversationList/Container/ViewModel/ConversationListViewControllerViewModel.swift

View workflow job for this annotation

GitHub Actions / Test Results

Main actor-isolated instance method 'userDidChange' cannot be used to satisfy nonisolated protocol requirement; this is an error in the Swift 6 language mode

Main actor-isolated instance method 'userDidChange' cannot be used to satisfy nonisolated protocol requirement; this is an error in the Swift 6 language mode

Check warning on line 329 in wire-ios/Wire-iOS/Sources/UserInterface/ConversationList/Container/ViewModel/ConversationListViewControllerViewModel.swift

View workflow job for this annotation

GitHub Actions / Test Results

Main actor-isolated instance method 'userDidChange' cannot be used to satisfy nonisolated protocol requirement; this is an error in the Swift 6 language mode

Main actor-isolated instance method 'userDidChange' cannot be used to satisfy nonisolated protocol requirement; this is an error in the Swift 6 language mode
func userDidChange(_ changeInfo: UserChangeInfo) {

if changeInfo.nameChanged || changeInfo.imageMediumDataChanged || changeInfo
Expand Down Expand Up @@ -360,7 +361,7 @@

extension ConversationListViewController.ViewModel: TeamObserver {

@MainActor

Check warning on line 364 in wire-ios/Wire-iOS/Sources/UserInterface/ConversationList/Container/ViewModel/ConversationListViewControllerViewModel.swift

View workflow job for this annotation

GitHub Actions / Test Results

Main actor-isolated instance method 'teamDidChange' cannot be used to satisfy nonisolated protocol requirement; this is an error in the Swift 6 language mode

Main actor-isolated instance method 'teamDidChange' cannot be used to satisfy nonisolated protocol requirement; this is an error in the Swift 6 language mode

Check warning on line 364 in wire-ios/Wire-iOS/Sources/UserInterface/ConversationList/Container/ViewModel/ConversationListViewControllerViewModel.swift

View workflow job for this annotation

GitHub Actions / Test Results

Main actor-isolated instance method 'teamDidChange' cannot be used to satisfy nonisolated protocol requirement; this is an error in the Swift 6 language mode

Main actor-isolated instance method 'teamDidChange' cannot be used to satisfy nonisolated protocol requirement; this is an error in the Swift 6 language mode
func teamDidChange(_ changeInfo: TeamChangeInfo) {

if changeInfo.imageDataChanged {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct ZClientControllerBuilder {
func build(router: AuthenticatedRouterProtocol) -> ZClientViewController {
let viewController = ZClientViewController(
account: account,
selfProfileViewsMonitor: SelfProfileViewsMonitorImplementation(),
userSession: userSession,
trackingManager: trackingManager
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,15 @@ final class ZClientViewController: UIViewController {
/// init method for testing allows injecting an Account object and self user
required init(
account: Account,
selfProfileViewsMonitor: SelfProfileViewsMonitor,
userSession: UserSession,
trackingManager: TrackingManager?
) {
self.account = account
self.selfProfileViewsMonitor = selfProfileViewsMonitor
self.userSession = userSession
self.trackingManager = trackingManager
self.colorSchemeController = .init(userSession: userSession)
self.selfProfileViewsMonitor = SelfProfileViewsMonitorImplementation()
super.init(nibName: nil, bundle: nil)

self.proximityMonitorManager = ProximityMonitorManager()
Expand Down
Loading