Skip to content

Conversation

@konstantiniiv
Copy link
Collaborator

@konstantiniiv konstantiniiv commented Jan 6, 2026


  • I understand that contributing to this repository will require me to agree with the CLA

Description

What type of PR is this? (check all applicable)

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🤖 Build
  • 🔁 CI

Related Tickets & Documents

Mobile & Desktop Screenshots/Recordings

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help

Added to documentation?

  • 📜 README.md
  • 📓 tech-docs
  • 🙅 no documentation needed

[optional] Are there any post-deployment tasks we need to perform?

@konstantiniiv konstantiniiv marked this pull request as ready for review January 6, 2026 07:28
Copy link
Contributor

Copilot AI left a 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 SetDataViewProperties use case and integrated it into ObjectSetViewModel
  • Refactored SearchRelationViewModel to 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 = false on 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 set isVisible based 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.

@konstantiniiv konstantiniiv merged commit 5481e22 into main Jan 7, 2026
3 checks passed
@konstantiniiv konstantiniiv deleted the droid-4226-cannot-filter-by-done-property-in-custom-task-type-on branch January 7, 2026 12:42
@github-actions github-actions bot locked and limited conversation to collaborators Jan 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant