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

fix: alert on backup failure - WPB-15211 #2387

Draft
wants to merge 131 commits into
base: epic/prepare-for-universal-backups-WPB-14616
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
5ff6f05
feat: add BackupViewMode and new stringsl
KaterinaWire Jan 2, 2025
d4a21e1
feat: add WireBackupUI
KaterinaWire Jan 2, 2025
a768468
feat: add SetBackupPassword
KaterinaWire Jan 2, 2025
85c5107
move to WireSettingsUI
KaterinaWire Jan 2, 2025
7a74f68
add Localizable
KaterinaWire Jan 2, 2025
c9c546c
Merge branch 'develop' into feat/new-backup-export-UI-WPB-15211
KaterinaWire Jan 3, 2025
832f44d
move all files to WireUI
KaterinaWire Jan 3, 2025
7aa58ba
add strings
KaterinaWire Jan 3, 2025
3cc4b5b
Merge branch 'develop' into feat/new-backup-export-UI-WPB-15211
KaterinaWire Jan 3, 2025
2a46189
remove files
KaterinaWire Jan 3, 2025
beac109
clean up
KaterinaWire Jan 3, 2025
ab35e0f
add BackupHandler
KaterinaWire Jan 6, 2025
dc2836a
remove ToDos
KaterinaWire Jan 6, 2025
33d009d
add BackupPasswordValidator
KaterinaWire Jan 6, 2025
5557bf9
fix SwiftFormat issues
KaterinaWire Jan 6, 2025
a4a70de
UI for backup restore
KaterinaWire Jan 7, 2025
3d89bfb
remove old backup code
KaterinaWire Jan 7, 2025
0e4c65a
Merge branch 'develop' into feat/new-backup-export-UI-WPB-15211
KaterinaWire Jan 7, 2025
a2761c3
fix SwiftFormat issues
KaterinaWire Jan 7, 2025
270f041
Merge branch 'develop' into feat/new-backup-export-UI-WPB-15211
KaterinaWire Jan 7, 2025
f0bdfc7
fix SwiftLint issues
KaterinaWire Jan 7, 2025
def2495
fix SwiftFormat issues
KaterinaWire Jan 7, 2025
f98c390
fix SwiftFormat issues
KaterinaWire Jan 7, 2025
52c51ec
attempt to fix linker errors
caldrian Jan 7, 2025
7628212
remove BackupPasswordViewControllerTests and BackupViewControllerTests
KaterinaWire Jan 7, 2025
e2dfc6f
fix dada model tests
KaterinaWire Jan 7, 2025
5eaaa40
Update WireUI/Sources/WireSettingsUI/Account/Backup/Protocols/BackupP…
KaterinaWire Jan 7, 2025
25776e3
Update WireUI/Sources/WireSettingsUI/Resources/en.lproj/Accessibility…
KaterinaWire Jan 7, 2025
57975f8
Update WireUI/Sources/WireSettingsUI/Account/Backup/Models/BackupHand…
KaterinaWire Jan 7, 2025
1ea4744
Update WireUI/Sources/WireSettingsUI/Account/Backup/ViewControllers/B…
KaterinaWire Jan 7, 2025
22b555d
Update WireUI/Sources/WireSettingsUI/Account/Backup/Views/ExportBacku…
KaterinaWire Jan 7, 2025
6d9f90d
address comments
KaterinaWire Jan 7, 2025
d193019
Merge branch 'develop' into feat/new-backup-export-UI-WPB-15211
KaterinaWire Jan 7, 2025
24c1ed3
fix SwiftFormat issues
KaterinaWire Jan 7, 2025
1a6418f
fix SwiftFormat issues
KaterinaWire Jan 7, 2025
7c6e38b
Merge branch 'develop' into feat/new-backup-export-UI-WPB-15211
KaterinaWire Jan 7, 2025
814ad5b
fix SwiftLint issues
KaterinaWire Jan 7, 2025
57d7945
fix SwiftFormat issues
KaterinaWire Jan 7, 2025
89299fa
remove BackupActionsSection
KaterinaWire Jan 7, 2025
49fb38c
solve merge conflicts
KaterinaWire Jan 7, 2025
69032be
add restore backup ligic
KaterinaWire Jan 8, 2025
7babed0
Merge branch 'develop' into feat/new-backup-export-UI-WPB-15211
KaterinaWire Jan 8, 2025
0ab82f0
Merge branch 'feat/new-backup-export-UI-WPB-15211' into feat/restore-…
KaterinaWire Jan 8, 2025
0c79c3b
temp
KaterinaWire Jan 8, 2025
deebdfc
Merge branch 'develop' into feat/new-backup-export-UI-WPB-15211
KaterinaWire Jan 8, 2025
e900fd8
add snapshots
KaterinaWire Jan 9, 2025
d3d570d
Merge branch 'feat/new-backup-export-UI-WPB-15211' into feat/restore-…
KaterinaWire Jan 9, 2025
bb90d8a
add snapshots
KaterinaWire Jan 9, 2025
c093769
Merge branch 'feat/new-backup-export-UI-WPB-15211' into feat/restore-…
KaterinaWire Jan 9, 2025
28e07e9
add snapshots and clean up
KaterinaWire Jan 9, 2025
8cacb05
add snapshots
KaterinaWire Jan 9, 2025
318ed9b
fix typo
KaterinaWire Jan 9, 2025
24f04f9
Merge branch 'feat/new-backup-export-UI-WPB-15211' into feat/restore-…
KaterinaWire Jan 9, 2025
c8ccf2e
temp restore backup
KaterinaWire Jan 9, 2025
fa12d27
Merge branch 'develop' into feat/new-backup-export-UI-WPB-15211
KaterinaWire Jan 9, 2025
9590683
chore: enable SwiftGen for Accessibility.strings - WPB-15211 (#2372)
caldrian Jan 10, 2025
82b1cf8
Merge branch 'develop' into feat/new-backup-export-UI-WPB-15211
KaterinaWire Jan 10, 2025
a6fc9f6
feat: support large fonts
KaterinaWire Jan 10, 2025
ada7359
fix: SwiftLint and SwiftFormat issues
KaterinaWire Jan 10, 2025
e1871ac
fix tests
KaterinaWire Jan 10, 2025
a6d3a54
add snapshots
KaterinaWire Jan 10, 2025
4a16b93
Merge branch 'feat/new-backup-export-UI-WPB-15211' into feat/restore-…
KaterinaWire Jan 10, 2025
5bb1e1d
resolve conflicts
KaterinaWire Jan 10, 2025
c8a4314
clean up
KaterinaWire Jan 10, 2025
5f0b70e
clean up
KaterinaWire Jan 10, 2025
e276615
fix SwiftFormat issues
KaterinaWire Jan 11, 2025
e09f5af
fix SwiftFormat issues
KaterinaWire Jan 11, 2025
89c6a3c
attempt to not switch to a different text field
caldrian Jan 13, 2025
a8a16b7
revert some changes
caldrian Jan 13, 2025
215f01b
attempt to present error
caldrian Jan 13, 2025
67c5ea0
some UI fixes
caldrian Jan 13, 2025
20671e0
renamings
caldrian Jan 13, 2025
e372462
add todo
caldrian Jan 13, 2025
bfc722c
add subview to alertcontroller
caldrian Jan 14, 2025
1e134af
Trigger CI
caldrian Jan 14, 2025
1b40149
Merge branch 'feat/new-backup-export-UI-WPB-15211' into feat/restore-…
caldrian Jan 14, 2025
a52f9f3
fix snapshot reference images
caldrian Jan 14, 2025
a87336d
Merge remote-tracking branch 'github/epic/prepare-for-universal-backu…
caldrian Jan 14, 2025
f318a7a
Merge branch 'feat/new-backup-export-UI-WPB-15211' into feat/restore-…
caldrian Jan 14, 2025
0cd14e4
Merge commit 'a87336dfe33119aceb1859e81b1748bfa9802119' into fix/back…
caldrian Jan 14, 2025
9fef825
format code
caldrian Jan 14, 2025
d0db7b1
revert renaming directory
caldrian Jan 14, 2025
1dd5283
revert some changes
caldrian Jan 14, 2025
850e728
Merge branch 'feat/restore-backup-WPB-11718' into fix/backup-export-a…
caldrian Jan 14, 2025
6d09c8d
Merge remote-tracking branch 'github/epic/prepare-for-universal-backu…
caldrian Jan 14, 2025
c6d41e8
Merge branch 'feat/restore-backup-WPB-11718' into fix/backup-export-a…
caldrian Jan 14, 2025
cf57f18
fix build errors
caldrian Jan 14, 2025
ceb14b0
prepare for creating a custom alert controller
caldrian Jan 14, 2025
ac434b7
custom alert controller
caldrian Jan 14, 2025
a191969
custom action
caldrian Jan 14, 2025
fbc2181
prepare for adding a progress indicator
caldrian Jan 14, 2025
874c3b1
custom layout
caldrian Jan 14, 2025
142c338
finish implementation
caldrian Jan 14, 2025
df99c3a
create snapshot tests
caldrian Jan 14, 2025
d42821e
attempt to create snapshot images
caldrian Jan 14, 2025
1e39fd3
fix style
caldrian Jan 14, 2025
9ad9934
cleanup & refactoring
caldrian Jan 14, 2025
727bc20
renamings and fixes
caldrian Jan 14, 2025
3b34b82
add TODO
caldrian Jan 14, 2025
dc4a05e
fix text style injection
caldrian Jan 14, 2025
5fb161f
rename directory
caldrian Jan 14, 2025
e3f0a23
improve modularization
caldrian Jan 14, 2025
9d24222
separate directory for export backup
caldrian Jan 15, 2025
aba3c2a
refactoring
caldrian Jan 15, 2025
204c369
generic BackupPasswordValidator
caldrian Jan 15, 2025
8ba9555
move password validation into view model
caldrian Jan 15, 2025
b702ea3
fix build errors
caldrian Jan 15, 2025
2935b16
move close button icon into reusable components
caldrian Jan 15, 2025
07a037d
fix build errors
caldrian Jan 15, 2025
9f52d74
use modifier for accessibilityLabel
caldrian Jan 15, 2025
61b64f0
update packages
caldrian Jan 15, 2025
de88a3c
use close button in Wire-iOS
caldrian Jan 15, 2025
9b375ae
Merge branch 'refactor/close-button-WPB-15211' into fix/backup-export…
caldrian Jan 15, 2025
5c34093
combine views
caldrian Jan 15, 2025
8a002bd
format code
caldrian Jan 15, 2025
8a8c87f
add TODO
caldrian Jan 15, 2025
a487e2a
rename and move files
caldrian Jan 15, 2025
882b01f
create ImportBackupViewModel
caldrian Jan 15, 2025
b4773fc
prepare for injecting ImportBackupView into BackupRestoreView
caldrian Jan 15, 2025
a79d02c
prepare more refactoring
caldrian Jan 15, 2025
5df3ff6
prepare fixing crash on iPad
caldrian Jan 15, 2025
4abb76a
add TODO
caldrian Jan 15, 2025
555ba12
revert a few changes of the epic branch
caldrian Jan 15, 2025
8b78151
present activity view controller on iPhone
caldrian Jan 15, 2025
fc33103
more refactoring
caldrian Jan 15, 2025
c002585
trial&error
caldrian Jan 16, 2025
d1f3c2c
finish backup for iPhone
caldrian Jan 16, 2025
02d7010
attempt to present the popover via UIViewRepresentable
caldrian Jan 16, 2025
dee7870
fix popover presentation for iPad
caldrian Jan 16, 2025
d64d8cf
add comment
caldrian Jan 16, 2025
5bfbde0
minor change
caldrian Jan 16, 2025
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 @@ -26,7 +26,7 @@ public struct FeatureConfigsAPIBuilder {

/// Create a new builder.
///
/// - Parameter httpClient: A http client.
/// - Parameter APIService: An api service.

public init(apiService: any APIServiceProtocol) {
self.apiService = apiService
Expand Down
84 changes: 84 additions & 0 deletions WireDomain/Sources/WireDomain/UseCases/PullSelfUserClients.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//
// 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/.
//

import CoreData
import WireAPI

/// Pull self clients from backend and update local state
public struct PullSelfUserClients: PullSelfUserClientsProtocol {
private let userClientsAPI: any UserClientsAPI
private let userClientsLocalStore: any UserClientsLocalStoreProtocol

init(userClientsAPI: any UserClientsAPI, userClientsLocalStore: any UserClientsLocalStoreProtocol) {
self.userClientsAPI = userClientsAPI
self.userClientsLocalStore = userClientsLocalStore
}

public func pullSelfClients() async throws {
let remoteSelfClients = try await userClientsAPI.getSelfClients()

for remoteSelfClient in remoteSelfClients {
let localUserClient = await userClientsLocalStore.fetchOrCreateClient(
id: remoteSelfClient.id
)

try await updateClient(
id: remoteSelfClient.id,
from: remoteSelfClient,
isNewClient: localUserClient.isNew
)
}

let deletedSelfClientsIDs = await userClientsLocalStore.deletedSelfClients(
newClients: remoteSelfClients.map(\.id)
)

for deletedSelfClientID in deletedSelfClientsIDs {
await userClientsLocalStore.deleteClient(id: deletedSelfClientID)
}
}

func updateClient(
id: String,
from remoteClient: WireAPI.SelfUserClient,
isNewClient: Bool
) async throws {
await userClientsLocalStore.updateClient(
id: id,
isNewClient: isNewClient,
userClientInfo: remoteClient.toDomainModel()
)
}

}

public extension PullSelfUserClients {

static func make(
apiService: any APIServiceProtocol,
apiVersion: WireAPI.APIVersion,
context: NSManagedObjectContext
) -> PullSelfUserClientsProtocol {
let userClientsAPI = UserClientsAPIBuilder(apiService: apiService).makeAPI(for: apiVersion)

let userLocalStore = UserLocalStore(context: context)
let userClientsLocalStore = UserClientsLocalStore(context: context, userLocalStore: userLocalStore)

return PullSelfUserClients(userClientsAPI: userClientsAPI, userClientsLocalStore: userClientsLocalStore)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
// along with this program. If not, see http://www.gnu.org/licenses/.
//

import SwiftUI
// sourcery: AutoMockable
public protocol PullSelfUserClientsProtocol {

public extension Image {
static let close = Image(.close)
func pullSelfClients() async throws
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
//
// 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/.
//

import WireAPISupport
import WireDataModel
import WireDataModelSupport
import WireDomainSupport
import WireTestingPackage
import XCTest
@testable import WireAPI
@testable import WireDomain

final class PullSelfUserClientsTests: XCTestCase {

private var sut: PullSelfUserClients!
private var userClientsAPI: MockUserClientsAPI!
private var userClientsLocalStore: MockUserClientsLocalStoreProtocol!
private var stack: CoreDataStack!
private var coreDataStackHelper: CoreDataStackHelper!
private var modelHelper: ModelHelper!

private var context: NSManagedObjectContext {
stack.syncContext
}

override func setUp() async throws {
coreDataStackHelper = CoreDataStackHelper()
modelHelper = ModelHelper()
stack = try await coreDataStackHelper.createStack()
userClientsAPI = MockUserClientsAPI()
userClientsLocalStore = MockUserClientsLocalStoreProtocol()

sut = PullSelfUserClients(
userClientsAPI: userClientsAPI,
userClientsLocalStore: userClientsLocalStore
)
}

override func tearDown() async throws {
stack = nil
userClientsAPI = nil
sut = nil
try coreDataStackHelper.cleanupDirectory()
coreDataStackHelper = nil
modelHelper = nil
}

// MARK: - Tests

func testPullSelfClients_It_Invokes_Local_Store_And_User_Repo_Methods() async throws {
// Mock

let selfUserClient = await context.perform { [self] in
return modelHelper.createSelfClient(
id: Scaffolding.otherUserClientID,
in: context
)
}

userClientsAPI.getSelfClients_MockValue = [
Scaffolding.selfUserClient
]

userClientsLocalStore.fetchOrCreateClientId_MockValue = (selfUserClient, false)
userClientsLocalStore.updateClientIdIsNewClientUserClientInfo_MockMethod = { _, _, _ in }
userClientsLocalStore.deletedSelfClientsNewClients_MockValue = [Scaffolding.userClientID]
userClientsLocalStore.deleteClientId_MockMethod = { _ in }

// When

try await sut.pullSelfClients()

// Then

XCTAssertEqual(userClientsLocalStore.fetchOrCreateClientId_Invocations.count, 1)
XCTAssertEqual(userClientsLocalStore.updateClientIdIsNewClientUserClientInfo_Invocations.count, 1)
XCTAssertEqual(userClientsLocalStore.deletedSelfClientsNewClients_Invocations.count, 1)
XCTAssertEqual(userClientsLocalStore.deleteClientId_Invocations.count, 1)
}

private enum Scaffolding {
static let userClientID = UUID.mockID1.uuidString
static let otherUserClientID = UUID.mockID2.uuidString

static let selfUserClient = WireAPI.SelfUserClient(
id: userClientID,
type: .permanent,
activationDate: .now,
label: "test",
model: "test",
deviceClass: .phone,
capabilities: []
)
}

}
10 changes: 3 additions & 7 deletions WireUI/Sources/WireFolderPickerUI/FolderPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,10 @@ public struct FolderPicker: View {
.toolbar {
if showCloseButton {
ToolbarItem(placement: .topBarTrailing) {
CloseButton(
action: didTapClose,
accessibilityLabel: String(
localized: "folderPicker.close.label",
table: "Accessibility",
bundle: .module
CloseButton(action: didTapClose)
.accessibilityLabel(
Text("folderPicker.close.label", tableName: "Accessibility", bundle: .module)
)
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,10 @@ public struct FolderPicker: View {
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
CloseButton(
action: didTapClose,
accessibilityLabel: String(
localized: "folderPicker.close.label",
table: "Accessibility",
bundle: .module
CloseButton(action: didTapClose)
.accessibilityLabel(
Text("folderPicker.close.label", tableName: "Accessibility", bundle: .module)
)
)
}
ToolbarItem(placement: .navigationBarTrailing) {
NavigationLink {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private extension UIView {
}
}

private var stateKey = 0
@MainActor private var stateKey = 0

// MARK: - Previews

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,18 @@ import WireDesign
public struct CloseButton: View {

private let action: () -> Void
private let accessibilityLabel: String

public var body: some View {
Button(action: action) {
Image.close
Image(.close)
}
.buttonStyle(.plain)
.foregroundColor(Color(uiColor: SemanticColors.Icon.foregroundDefaultBlack))
.accessibilityLabel(Text(accessibilityLabel))
.accessibilityIdentifier("close")
}

public init(action: @escaping @MainActor () -> Void, accessibilityLabel: String) {
public init(action: @escaping @MainActor () -> Void) {
self.action = action
self.accessibilityLabel = accessibilityLabel
}

}
Expand All @@ -46,7 +43,7 @@ public struct CloseButton: View {
Text("Hello, World!")
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
CloseButton(action: { print("Close") }, accessibilityLabel: "Close")
CloseButton { print("Close") }
}
}
}
Expand Down
Loading