-
Notifications
You must be signed in to change notification settings - Fork 0
Fix backup tags on activity edit #479
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
Conversation
cec084b to
98c2620
Compare
Code Review: Fix backup tags on activity editThanks for this fix! This PR addresses an important issue with tag backup when editing activity details. Overall, the changes follow good architectural patterns and improve the codebase. Here's my detailed review: ✅ Strengths
🔍 Code Quality ObservationsActivityDetailViewModel.kt (app/src/main/java/to/bitkit/viewmodels/ActivityDetailViewModel.kt:48-87)
SendCoinSelectionViewModel.kt (app/src/main/java/to/bitkit/ui/screens/wallets/send/SendCoinSelectionViewModel.kt:74-92)
ActivityRepo.kt - New methods are well-designed:
🐛 Potential Issues & ConcernsCritical: Backup Sync Issue (The fix this PR addresses)Root cause identified correctly: The ViewModels were calling Fix verification: ✅ All tag operations now go through Minor: Error Handling Edge CaseIn .onFailure { e ->
Logger.error("Failed to load tags for utxo $txId", e)
// Consider: _tagsByTxId.update { currentMap -> currentMap + (txId to emptyList()) }
}🔒 Security Considerations✅ No security concerns identified:
⚡ Performance Considerations✅ Performance looks good:
🧪 Test CoverageCurrent state: Test file updated minimally (just mock change from Recommendation: Consider adding tests for the tag-related functionality: @Test
fun `loadTags updates tags state on success`() = test {
val activityId = "test-activity-id"
val expectedTags = listOf("tag1", "tag2")
val mockActivity = mock<Activity.Onchain>()
whenever(activityRepo.getActivityTags(activityId))
.thenReturn(Result.success(expectedTags))
sut.setActivity(mockActivity)
sut.loadTags()
assertEquals(expectedTags, sut.tags.value)
}
@Test
fun `addTag calls settingsStore and reloads tags on success`() = test {
val activityId = "test-activity-id"
val tag = "new-tag"
val mockActivity = mock<Activity.Onchain>()
whenever(activityRepo.addTagsToActivity(activityId, listOf(tag)))
.thenReturn(Result.success(Unit))
sut.setActivity(mockActivity)
sut.addTag(tag)
verify(settingsStore).addLastUsedTag(tag)
verify(activityRepo).getActivityTags(activityId) // loadTags called
}However, these additions are not blocking - the current fix is solid and the existing test infrastructure proves the refactoring maintains compatibility. 📝 Summary & RecommendationVerdict: ✅ Approve with minor suggestions This PR successfully fixes the tag backup issue by properly routing tag operations through the repository layer. The architectural improvements are significant and align perfectly with the project's conventions. Key improvements:
Minor suggestions (non-blocking):
Test plan verification: The described test (edit tags → backup → wipe → restore) should now work correctly since all tag modifications trigger the Great work! 🎉 |
Fixes backup of tags when editing activity details.
Test: Go to an actitivy, edit its tags (add and remove), then back up the wallet seed, wipe the wallet, and restore it.