Skip to content

Commit

Permalink
Merge pull request #36 from Trendyol/fix/35-unintended-mock-deletion
Browse files Browse the repository at this point in the history
Fix Unintended mock deletion
  • Loading branch information
yusufozgul authored Nov 25, 2024
2 parents 1e6b123 + f40169b commit fbc2e12
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Features/MockList/Sources/MockList/MockListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ public struct MockListView: View {
Button("Delete", role: .destructive) {
viewModel.deleteSelectedMocks()
}
} message: {
Text("Deleting selected mocks will also delete all associated mock responses. Are you sure you want to do this?") +
Text("\n\n") +
Text("You will delete ^[\(viewModel.selected.count) \("mock")](inflect: true).")
}
.alert("Error", isPresented: $viewModel.shouldShowErrorMessage, actions: {
Button("Ok", role: .cancel, action: { })
Expand Down
7 changes: 7 additions & 0 deletions Features/MockList/Sources/MockList/MockListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ public final class MockListViewModel {

try Task.checkCancellation()

/// Find selected mocks, remove them if they are not included in the new UI list.
selected
.filter { id in !filteredMocks.contains(where: { $0.id == id }) }
.forEach { selected.remove($0) }

try Task.checkCancellation()

try await MainActor.run {
try Task.checkCancellation()
mockListUIModel = filteredMocks.sorted(using: sortOrder)
Expand Down
16 changes: 16 additions & 0 deletions Features/MockList/Sources/MockList/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"sourceLanguage" : "en",
"strings" : {
"\n\n" : {

},
"Are you sure?" : {

},
Expand All @@ -9,6 +12,9 @@
},
"Delete" : {

},
"Deleting selected mocks will also delete all associated mock responses. Are you sure you want to do this?" : {

},
"Error" : {

Expand Down Expand Up @@ -63,6 +69,16 @@
},
"Unselect All Mocks" : {

},
"You will delete ^[%lld %@](inflect: true)." : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "You will delete ^[%1$lld %2$@](inflect: true)."
}
}
}
}
},
"version" : "1.0"
Expand Down

0 comments on commit fbc2e12

Please sign in to comment.