Skip to content

Commit

Permalink
Fixed addDeleteFlag in DeleteDataView
Browse files Browse the repository at this point in the history
Fixed adding delete flag in DeleteDataView by modifying .healthKitDescription to return self by default (temporary fix). Also fixed bug where deleting last timestamp in array returns "index out of range."
  • Loading branch information
evelyn-hur committed Mar 5, 2024
1 parent e313203 commit 48e3ca9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
18 changes: 8 additions & 10 deletions Prisma/PrivacyControls/DeleteDataView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ struct DeleteDataView: View {
}
// on delete, remove it on the UI and set flag in firebase
.onDelete { indices in
let timestampsToDelete = indices.map { timeArrayStatic[$0] }
deleteInBackend(identifier: categoryIdentifier, timestamps: timestampsToDelete)
timeArrayStatic.remove(atOffsets: indices)
deleteInBackend(identifier: categoryIdentifier, timestampIndices: indices)
}
}
}
Expand All @@ -59,19 +60,16 @@ struct DeleteDataView: View {
}
}
.navigationTitle(privacyModule.identifierUIString[categoryIdentifier] ?? "Identifier Title Not Found")

}

Check warning on line 63 in Prisma/PrivacyControls/DeleteDataView.swift

View check run for this annotation

Codecov / codecov/patch

Prisma/PrivacyControls/DeleteDataView.swift#L25-L63

Added lines #L25 - L63 were not covered by tests
func deleteInBackend(identifier: String, timestampIndices: IndexSet) {
// loop through all the indices of items deleted
// get correspoding timestamp from timestamp array with index
// set the flag at that corresponding timestamp
for index in timestampIndices where timeArrayStatic.indices.contains(index) {
Task {
await standard.addDeleteFlag(selectedTypeIdentifier: identifier, timestamp: timeArrayStatic[index])
}

func deleteInBackend(identifier: String, timestamps: [String]) {
for timestamp in timestamps {
Task {
await standard.addDeleteFlag(selectedTypeIdentifier: identifier, timestamp: timestamp)
}
}
}

Check warning on line 71 in Prisma/PrivacyControls/DeleteDataView.swift

View check run for this annotation

Codecov / codecov/patch

Prisma/PrivacyControls/DeleteDataView.swift#L65-L71

Added lines #L65 - L71 were not covered by tests
}


#Preview {
Expand Down
3 changes: 2 additions & 1 deletion Prisma/Standard/PrismaStandard+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ extension String {
for prefix in prefixes where self.hasPrefix(prefix) {
return self.dropFirst(prefix.count).lowercased()
}
return "unknown"
// return "unknown"
return self

Check warning on line 25 in Prisma/Standard/PrismaStandard+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Prisma/Standard/PrismaStandard+Extension.swift#L19-L25

Added lines #L19 - L25 were not covered by tests
}
}

Expand Down

0 comments on commit 48e3ca9

Please sign in to comment.