-
Notifications
You must be signed in to change notification settings - Fork 75
DROID-4082 Sets | Enhancement | Sync type's recommended relations to DataView properties (#3035) #3038
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
DROID-4082 Sets | Enhancement | Sync type's recommended relations to DataView properties (#3035) #3038
Conversation
…DataView properties (#3035)
…ollection and view model tests
…syncing recommended relations in TypeSet
…havior for TypeSet relations
… in SearchRelationViewModel and update tests for visibility rules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements functionality to sync a type's recommended relations to DataView properties when opening a TypeSet. This ensures that type-specific relations (like "Done" for task types) are available as filter options in the DataView, matching desktop application behavior.
Key changes:
- Added
SetDataViewPropertiesuse case and integrated it intoObjectSetViewModel - Refactored
SearchRelationViewModelto simplify relation filtering logic - Added comprehensive test coverage for the new TypeSet relation syncing functionality
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| presentation/src/main/java/com/anytypeio/anytype/presentation/sets/ObjectSetViewModel.kt | Adds subscribeToSyncTypeRelations() method to sync type's recommended relations to DataView when TypeSet is initialized |
| presentation/src/main/java/com/anytypeio/anytype/presentation/sets/ObjectSetViewModelFactory.kt | Adds SetDataViewProperties parameter to factory for dependency injection |
| presentation/src/main/java/com/anytypeio/anytype/presentation/sets/SearchRelationViewModel.kt | Refactors relation filtering by introducing getRelationsForViewer() method and moving format restrictions to companion object |
| presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetSyncTypeRelationsTest.kt | New comprehensive test file covering TypeSet relation syncing for various scenarios (TypeSet, Set, Collection states) |
| presentation/src/test/java/com/anytypeio/anytype/presentation/sets/main/ObjectSetViewModelTestSetup.kt | Updates test setup with SetDataViewProperties mock and reordered imports |
| presentation/src/test/java/com/anytypeio/anytype/presentation/sets/SearchRelationViewModelTest.kt | Refactors existing tests and adds new test cases for search functionality, filtering, and edge cases |
| presentation/src/test/java/com/anytypeio/anytype/presentation/collections/CollectionCreateAndAddObjectTest.kt | Updates ViewModel instantiation to include new setDataViewProperties parameter |
| app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetDI.kt | Adds DI provider for SetDataViewProperties and wires it into factory |
Comments suppressed due to low confidence (1)
presentation/src/test/java/com/anytypeio/anytype/presentation/sets/SearchRelationViewModelTest.kt:159
- The test name says "non-hidden relations with allowed formats should be visible" but the assertions check for
isVisible = falseon all relations (lines 111, 120, 129, 138, 147). This is misleading. Either the test name should be updated to reflect that it's checking for non-hidden relations being returned (not necessarily visible), or the implementation should properly setisVisiblebased on the viewerRelations as described in the bug comment for SearchRelationViewModel.kt.
fun `non-hidden relations with allowed formats should be visible`() = runTest {
// SETUP - use only non-hidden relations with allowed formats
// Note: Hidden relations (isHidden=true) are filtered out by notAllowedRelations()
val relationNotAcceptedFormat = StubRelationObject(
key = "key_not_accepted_format",
name = "Not accepted format",
format = notAllowedRelationFormats.random(),
isHidden = false,
isReadOnly = false,
objectTypes = listOf()
)
val relations = listOf(
relationLastModifiedDate, // isHidden=false, DATE format
relationCustomNumber, // isHidden=false, NUMBER format
relationCustomText, // isHidden=false, LONG_TEXT format
relationStatus, // isHidden=false, STATUS format
relationTag, // isHidden=false, TAG format
relationNotAcceptedFormat // isHidden=false, Not Accepted format
)
val state = MutableStateFlow(
MockObjectSetFactory.makeDefaultSetObjectState(
dataViewId = dataViewId,
relations = relations,
viewerRelations = relations.map { DVViewerRelation(key = it.key, isVisible = true) }
)
)
storeOfRelations.merge(relations)
val vm = buildViewModel(state)
vm.onStart(viewerId = state.value.dataViewState()!!.viewers.first().id)
// TESTING - all non-hidden relations should be visible
val expected = listOf(
SimpleRelationView(
key = relationLastModifiedDate.key,
title = relationLastModifiedDate.name.orEmpty(),
format = RelationFormat.DATE,
isVisible = false,
isHidden = false,
isReadonly = false,
isDefault = true
),
SimpleRelationView(
key = relationCustomNumber.key,
title = relationCustomNumber.name.orEmpty(),
format = RelationFormat.NUMBER,
isVisible = false,
isHidden = false,
isReadonly = false,
isDefault = false
),
SimpleRelationView(
key = relationCustomText.key,
title = relationCustomText.name.orEmpty(),
format = RelationFormat.LONG_TEXT,
isVisible = false,
isHidden = false,
isReadonly = false,
isDefault = false
),
SimpleRelationView(
key = relationStatus.key,
title = relationStatus.name.orEmpty(),
format = RelationFormat.STATUS,
isVisible = false,
isHidden = false,
isReadonly = false,
isDefault = false
),
SimpleRelationView(
key = relationTag.key,
title = relationTag.name.orEmpty(),
format = RelationFormat.TAG,
isVisible = false,
isHidden = false,
isReadonly = false,
isDefault = false
)
)
vm.views.test {
delay(100)
assertEquals(expected = expected, actual = awaitItem())
cancelAndConsumeRemainingEvents()
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
presentation/src/main/java/com/anytypeio/anytype/presentation/sets/SearchRelationViewModel.kt
Outdated
Show resolved
Hide resolved
presentation/src/main/java/com/anytypeio/anytype/presentation/sets/SearchRelationViewModel.kt
Outdated
Show resolved
Hide resolved
presentation/src/main/java/com/anytypeio/anytype/presentation/sets/ObjectSetViewModel.kt
Outdated
Show resolved
Hide resolved
… use getPropertiesForDataView for improved data handling
… method to improve clarity and filtering logic
…ewModel to clarify state emission logic
…s in TestObjectSetSetup
Description
What type of PR is this? (check all applicable)
Related Tickets & Documents
Mobile & Desktop Screenshots/Recordings
Added tests?
Added to documentation?
[optional] Are there any post-deployment tasks we need to perform?