mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-2314 App | Tech | Propagate spaceId as required field for components — Part 1 (#1020)
This commit is contained in:
parent
d17d18470a
commit
3eaf3a961f
144 changed files with 1693 additions and 919 deletions
|
@ -48,7 +48,7 @@ class CreateBlockTesting : EditorTestSetup() {
|
|||
@get:Rule
|
||||
val coroutineTestRule = CoroutinesTestRule()
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
@Before
|
||||
override fun setup() {
|
||||
|
|
|
@ -49,7 +49,7 @@ class DeleteBlockTesting : EditorTestSetup() {
|
|||
@get:Rule
|
||||
val coroutineTestRule = CoroutinesTestRule()
|
||||
|
||||
private val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
private val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
@Before
|
||||
override fun setup() {
|
||||
|
|
|
@ -34,7 +34,7 @@ class DescriptionTesting : EditorTestSetup() {
|
|||
@get:Rule
|
||||
val animationsRule = DisableAnimationsRule()
|
||||
|
||||
private val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
private val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
private val title = MockBlockFactory.text(
|
||||
content = MockBlockContentFactory.StubTextContent(
|
||||
|
|
|
@ -80,7 +80,7 @@ class EditorIntegrationTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val blocks = listOf(
|
||||
BLOCK_H1,
|
||||
|
@ -155,7 +155,7 @@ class EditorIntegrationTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val document = listOf(
|
||||
Block(
|
||||
|
@ -201,7 +201,7 @@ class EditorIntegrationTesting : EditorTestSetup() {
|
|||
@Test
|
||||
fun shouldClearFocusAfterClickedOnHideKeyboard() {
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val document = listOf(
|
||||
Block(
|
||||
|
@ -245,7 +245,7 @@ class EditorIntegrationTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val text = "FooBar"
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class FeaturedRelationTesting : EditorTestSetup() {
|
|||
@get:Rule
|
||||
val animationsRule = DisableAnimationsRule()
|
||||
|
||||
private val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
private val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
private val title = MockBlockFactory.text(
|
||||
content = MockBlockContentFactory.StubTextContent(
|
||||
|
|
|
@ -37,7 +37,7 @@ class LayoutTesting : EditorTestSetup() {
|
|||
// @get:Rule
|
||||
// val coroutineTestRule = CoroutinesTestRule()
|
||||
|
||||
private val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
private val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
private val title = MockBlockFactory.text(
|
||||
content = MockBlockContentFactory.StubTextContent(
|
||||
|
|
|
@ -45,7 +45,7 @@ class ListBlockTesting : EditorTestSetup() {
|
|||
// @get:Rule
|
||||
// val coroutineTestRule = CoroutinesTestRule()
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
@Before
|
||||
override fun setup() {
|
||||
|
|
|
@ -35,7 +35,7 @@ class MarkupTesting : EditorTestSetup() {
|
|||
@get:Rule
|
||||
val coroutineTestRule = CoroutinesTestRule()
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
@Before
|
||||
override fun setup() {
|
||||
|
|
|
@ -42,7 +42,7 @@ class MentionUpdateTesting : EditorTestSetup() {
|
|||
@get:Rule
|
||||
val coroutineTestRule = CoroutinesTestRule()
|
||||
|
||||
private val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
private val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
@Before
|
||||
override fun setup() {
|
||||
|
|
|
@ -58,7 +58,7 @@ class MergeBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val style = Block.Content.Text.Style.P
|
||||
|
||||
|
@ -72,7 +72,7 @@ class MergeBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val style = Block.Content.Text.Style.H1
|
||||
|
||||
|
@ -86,7 +86,7 @@ class MergeBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val style = Block.Content.Text.Style.H2
|
||||
|
||||
|
@ -100,7 +100,7 @@ class MergeBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val style = Block.Content.Text.Style.H3
|
||||
|
||||
|
@ -114,7 +114,7 @@ class MergeBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val style = Block.Content.Text.Style.QUOTE
|
||||
|
||||
|
@ -128,7 +128,7 @@ class MergeBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val style = Block.Content.Text.Style.CHECKBOX
|
||||
|
||||
|
@ -142,7 +142,7 @@ class MergeBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val style = Block.Content.Text.Style.BULLET
|
||||
|
||||
|
@ -156,7 +156,7 @@ class MergeBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val style = Block.Content.Text.Style.NUMBERED
|
||||
|
||||
|
@ -170,7 +170,7 @@ class MergeBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val style = Block.Content.Text.Style.TOGGLE
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class ProfileTesting : EditorTestSetup() {
|
|||
@get:Rule
|
||||
val animationsRule = DisableAnimationsRule()
|
||||
|
||||
private val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
private val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
private val title = Block(
|
||||
id = MockDataFactory.randomUuid(),
|
||||
|
|
|
@ -51,7 +51,7 @@ class RelationBlockUITesting : EditorTestSetup() {
|
|||
// @get:Rule
|
||||
// val coroutineTestRule = CoroutinesTestRule()
|
||||
|
||||
private val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
private val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
private val defaultDetails = Block.Details(
|
||||
mapOf(
|
||||
|
|
|
@ -34,7 +34,7 @@ class ScrollAndMoveTesting : EditorTestSetup() {
|
|||
// @get:Rule
|
||||
// val coroutineTestRule = CoroutinesTestRule()
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
private val title = Block(
|
||||
id = MockDataFactory.randomUuid(),
|
||||
|
|
|
@ -40,7 +40,7 @@ class SlashTextWatcherTesting : EditorTestSetup() {
|
|||
@get:Rule
|
||||
val coroutineTestRule = CoroutinesTestRule()
|
||||
|
||||
private val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
private val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
private val defaultDetails = Block.Details(
|
||||
mapOf(
|
||||
|
|
|
@ -56,7 +56,7 @@ class SlashWidgetTesting : EditorTestSetup() {
|
|||
@get:Rule
|
||||
val coroutineTestRule = CoroutinesTestRule()
|
||||
|
||||
private val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
private val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
private val defaultDetails = Block.Details(
|
||||
mapOf(
|
||||
|
|
|
@ -54,7 +54,7 @@ class SplitBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val text = "FooBar"
|
||||
|
||||
|
@ -197,7 +197,7 @@ class SplitBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val text = "FooBar"
|
||||
|
||||
|
@ -338,7 +338,7 @@ class SplitBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val text = "FooBar"
|
||||
|
||||
|
@ -479,7 +479,7 @@ class SplitBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val text = "FooBar"
|
||||
|
||||
|
@ -620,7 +620,7 @@ class SplitBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val text = "FooBar"
|
||||
|
||||
|
@ -763,7 +763,7 @@ class SplitBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val text = "FooBar"
|
||||
|
||||
|
@ -906,7 +906,7 @@ class SplitBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val text = "FooBar"
|
||||
|
||||
|
@ -1049,7 +1049,7 @@ class SplitBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val text = "FooBar"
|
||||
|
||||
|
@ -1192,7 +1192,7 @@ class SplitBlockTesting : EditorTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
val text = "FooBar"
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class SplitTitleTesting : EditorTestSetup() {
|
|||
@get:Rule
|
||||
val coroutineTestRule = CoroutinesTestRule()
|
||||
|
||||
private val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
private val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
@Before
|
||||
override fun setup() {
|
||||
|
|
|
@ -38,7 +38,7 @@ class MentionWidgetTesting : EditorTestSetup() {
|
|||
@get:Rule
|
||||
val coroutineTestRule = CoroutinesTestRule()
|
||||
|
||||
private val args = bundleOf(EditorFragment.ID_KEY to root)
|
||||
private val args = bundleOf(EditorFragment.CTX_KEY to root)
|
||||
|
||||
private val defaultDetails = Block.Details(
|
||||
mapOf(
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.content.Context
|
|||
import com.anytypeio.anytype.BuildConfig
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.core_models.primitives.TypeKey
|
||||
import com.anytypeio.anytype.di.feature.AddDataViewRelationObjectValueModule
|
||||
import com.anytypeio.anytype.di.feature.AddDataViewRelationOptionValueModule
|
||||
import com.anytypeio.anytype.di.feature.AddFileRelationModule
|
||||
|
@ -108,6 +107,7 @@ import com.anytypeio.anytype.di.feature.widgets.SelectWidgetSourceModule
|
|||
import com.anytypeio.anytype.di.feature.widgets.SelectWidgetTypeModule
|
||||
import com.anytypeio.anytype.di.main.MainComponent
|
||||
import com.anytypeio.anytype.gallery_experience.viewmodel.GalleryInstallationViewModel
|
||||
import com.anytypeio.anytype.presentation.library.LibraryViewModel
|
||||
import com.anytypeio.anytype.presentation.multiplayer.RequestJoinSpaceViewModel
|
||||
import com.anytypeio.anytype.presentation.multiplayer.ShareSpaceViewModel
|
||||
import com.anytypeio.anytype.presentation.multiplayer.SpaceJoinRequestViewModel
|
||||
|
@ -832,9 +832,10 @@ class ComponentManager(
|
|||
.create(findComponentDependencies())
|
||||
}
|
||||
|
||||
val libraryComponent = ComponentWithParams { ctx: Context ->
|
||||
val libraryComponent = ComponentWithParams { (ctx, params) : Pair<Context, LibraryViewModel.Params> ->
|
||||
DaggerLibraryComponent.builder()
|
||||
.withContext(ctx)
|
||||
.withParams(params)
|
||||
.withDependencies(findComponentDependencies())
|
||||
.build()
|
||||
}
|
||||
|
@ -944,11 +945,11 @@ class ComponentManager(
|
|||
.build()
|
||||
}
|
||||
|
||||
val selectObjectTypeComponent = ComponentWithParams { excludedTypeKeys: List<TypeKey> ->
|
||||
val selectObjectTypeComponent = ComponentWithParams { params: SelectObjectTypeViewModel.Params ->
|
||||
DaggerSelectObjectTypeComponent
|
||||
.factory()
|
||||
.create(
|
||||
params = SelectObjectTypeViewModel.Params(excludedTypeKeys),
|
||||
params = params,
|
||||
dependencies = findComponentDependencies()
|
||||
)
|
||||
}
|
||||
|
|
|
@ -53,6 +53,9 @@ interface LibraryComponent {
|
|||
@BindsInstance
|
||||
fun withContext(context: Context): Builder
|
||||
|
||||
@BindsInstance
|
||||
fun withParams(params: LibraryViewModel.Params): Builder
|
||||
|
||||
fun build(): LibraryComponent
|
||||
}
|
||||
|
||||
|
|
|
@ -117,11 +117,13 @@ object SubscriptionsModule {
|
|||
dispatchers: AppCoroutineDispatchers,
|
||||
@Named(DEFAULT_APP_COROUTINE_SCOPE) scope: CoroutineScope,
|
||||
container: StorelessSubscriptionContainer,
|
||||
repo: AuthRepository
|
||||
repo: AuthRepository,
|
||||
logger: Logger
|
||||
) : UserPermissionProvider = DefaultUserPermissionProvider(
|
||||
dispatchers = dispatchers,
|
||||
scope = scope,
|
||||
container = container,
|
||||
repo = repo
|
||||
repo = repo,
|
||||
logger = logger
|
||||
)
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package com.anytypeio.anytype.navigation
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.navOptions
|
||||
|
@ -12,6 +11,7 @@ import com.anytypeio.anytype.presentation.widgets.collection.Subscription
|
|||
import com.anytypeio.anytype.ui.auth.account.DeletedAccountFragment
|
||||
import com.anytypeio.anytype.ui.editor.EditorFragment
|
||||
import com.anytypeio.anytype.ui.editor.EditorModalFragment
|
||||
import com.anytypeio.anytype.ui.library.LibraryFragment
|
||||
import com.anytypeio.anytype.ui.sets.ObjectSetFragment
|
||||
import com.anytypeio.anytype.ui.settings.RemoteFilesManageFragment
|
||||
import com.anytypeio.anytype.ui.templates.EditorTemplateFragment.Companion.TYPE_TEMPLATE_EDIT
|
||||
|
@ -32,12 +32,13 @@ class Navigator : AppNavigation {
|
|||
}
|
||||
}
|
||||
|
||||
override fun openDocument(id: String) {
|
||||
override fun openDocument(target: Id, space: Id) {
|
||||
navController?.navigate(
|
||||
R.id.objectNavigation,
|
||||
Bundle().apply {
|
||||
putString(EditorFragment.ID_KEY, id)
|
||||
}
|
||||
EditorFragment.args(
|
||||
ctx = target,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -73,10 +74,13 @@ class Navigator : AppNavigation {
|
|||
)
|
||||
}
|
||||
|
||||
override fun launchDocument(id: String) {
|
||||
override fun launchDocument(target: String, space: Id) {
|
||||
navController?.navigate(
|
||||
R.id.objectNavigation,
|
||||
bundleOf(EditorFragment.ID_KEY to id),
|
||||
EditorFragment.args(
|
||||
ctx = target,
|
||||
space = space
|
||||
),
|
||||
navOptions {
|
||||
launchSingleTop = true
|
||||
popUpTo(R.id.pageSearchFragment) {
|
||||
|
@ -86,17 +90,23 @@ class Navigator : AppNavigation {
|
|||
)
|
||||
}
|
||||
|
||||
override fun launchCollections(subscription: Subscription) {
|
||||
override fun launchCollections(subscription: Subscription, space: Id) {
|
||||
navController?.navigate(
|
||||
R.id.homeScreenWidgets,
|
||||
bundleOf(CollectionFragment.SUBSCRIPTION_KEY to subscription.id)
|
||||
CollectionFragment.args(
|
||||
subscription = subscription.id,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun launchObjectSet(id: Id) {
|
||||
override fun launchObjectSet(target: Id, space: Id) {
|
||||
navController?.navigate(
|
||||
R.id.dataViewNavigation,
|
||||
bundleOf(ObjectSetFragment.CONTEXT_ID_KEY to id),
|
||||
ObjectSetFragment.args(
|
||||
ctx = target,
|
||||
space = space
|
||||
),
|
||||
navOptions {
|
||||
launchSingleTop = true
|
||||
popUpTo(R.id.pageSearchFragment) {
|
||||
|
@ -106,20 +116,6 @@ class Navigator : AppNavigation {
|
|||
)
|
||||
}
|
||||
|
||||
override fun launchObjectFromSplash(id: Id) {
|
||||
navController?.navigate(
|
||||
R.id.action_splashScreen_to_objectScreen,
|
||||
bundleOf(EditorFragment.ID_KEY to id),
|
||||
)
|
||||
}
|
||||
|
||||
override fun launchObjectSetFromSplash(id: Id) {
|
||||
navController?.navigate(
|
||||
R.id.action_splashScreen_to_objectSetScreen,
|
||||
bundleOf(ObjectSetFragment.CONTEXT_ID_KEY to id),
|
||||
)
|
||||
}
|
||||
|
||||
override fun openKeychainScreen() {
|
||||
navController?.navigate(R.id.action_open_keychain)
|
||||
}
|
||||
|
@ -149,18 +145,25 @@ class Navigator : AppNavigation {
|
|||
override fun exitToDesktopAndOpenPage(pageId: String) {
|
||||
navController?.navigate(
|
||||
R.id.homeScreen,
|
||||
bundleOf(EditorFragment.ID_KEY to pageId),
|
||||
bundleOf(EditorFragment.CTX_KEY to pageId),
|
||||
navOptions {
|
||||
launchSingleTop = true
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun openObjectSet(target: String, isPopUpToDashboard: Boolean) {
|
||||
override fun openObjectSet(
|
||||
target: Id,
|
||||
space: Id,
|
||||
isPopUpToDashboard: Boolean
|
||||
) {
|
||||
if (isPopUpToDashboard) {
|
||||
navController?.navigate(
|
||||
R.id.dataViewNavigation,
|
||||
bundleOf(ObjectSetFragment.CONTEXT_ID_KEY to target),
|
||||
ObjectSetFragment.args(
|
||||
ctx = target,
|
||||
space = space
|
||||
),
|
||||
navOptions {
|
||||
popUpTo(R.id.main_navigation) { inclusive = true }
|
||||
}
|
||||
|
@ -168,7 +171,10 @@ class Navigator : AppNavigation {
|
|||
} else {
|
||||
navController?.navigate(
|
||||
R.id.dataViewNavigation,
|
||||
bundleOf(ObjectSetFragment.CONTEXT_ID_KEY to target)
|
||||
ObjectSetFragment.args(
|
||||
ctx = target,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -215,8 +221,11 @@ class Navigator : AppNavigation {
|
|||
})
|
||||
}
|
||||
|
||||
override fun openLibrary() {
|
||||
navController?.navigate(R.id.libraryFragment)
|
||||
override fun openLibrary(space: Id) {
|
||||
navController?.navigate(
|
||||
R.id.libraryFragment,
|
||||
LibraryFragment.args(space)
|
||||
)
|
||||
}
|
||||
|
||||
override fun openRemoteFilesManageScreen(subscription: Id) {
|
||||
|
|
|
@ -13,28 +13,29 @@ class NavigationRouter(
|
|||
when (command) {
|
||||
is AppNavigation.Command.ExitFromMigrationScreen -> navigation.exitFromMigrationScreen()
|
||||
is AppNavigation.Command.OpenSettings -> navigation.openSpaceSettings()
|
||||
is AppNavigation.Command.OpenObject -> navigation.openDocument(command.id)
|
||||
is AppNavigation.Command.OpenObject -> navigation.openDocument(
|
||||
target = command.target,
|
||||
space = command.space
|
||||
)
|
||||
is AppNavigation.Command.OpenModalTemplateSelect -> navigation.openModalTemplateSelect(
|
||||
template = command.template,
|
||||
templateTypeId = command.templateTypeId,
|
||||
templateTypeKey = command.templateTypeKey
|
||||
)
|
||||
is AppNavigation.Command.OpenSetOrCollection -> navigation.openObjectSet(
|
||||
command.target,
|
||||
command.isPopUpToDashboard
|
||||
target = command.target,
|
||||
space = command.space,
|
||||
isPopUpToDashboard = command.isPopUpToDashboard
|
||||
)
|
||||
is AppNavigation.Command.LaunchObjectSet -> navigation.launchObjectSet(command.target)
|
||||
is AppNavigation.Command.LaunchDocument -> navigation.launchDocument(command.id)
|
||||
is AppNavigation.Command.LaunchObjectFromSplash -> navigation.launchObjectFromSplash(
|
||||
command.target
|
||||
is AppNavigation.Command.LaunchObjectSet -> navigation.launchObjectSet(
|
||||
target = command.target,
|
||||
space = command.space
|
||||
)
|
||||
|
||||
is AppNavigation.Command.LaunchObjectSetFromSplash -> navigation.launchObjectSetFromSplash(
|
||||
command.target
|
||||
is AppNavigation.Command.LaunchDocument -> navigation.launchDocument(
|
||||
target = command.target,
|
||||
space = command.space
|
||||
)
|
||||
|
||||
is AppNavigation.Command.OpenUserSettingsScreen -> navigation.openUserSettingsScreen()
|
||||
|
||||
is AppNavigation.Command.Exit -> navigation.exit()
|
||||
is AppNavigation.Command.ExitToDesktop -> navigation.exitToDesktop()
|
||||
is AppNavigation.Command.OpenDebugSettingsScreen -> navigation.openDebugSettings()
|
||||
|
@ -52,7 +53,7 @@ class NavigationRouter(
|
|||
typeId = command.typeId
|
||||
)
|
||||
|
||||
is AppNavigation.Command.OpenLibrary -> navigation.openLibrary()
|
||||
is AppNavigation.Command.OpenLibrary -> navigation.openLibrary(command.space)
|
||||
is AppNavigation.Command.MigrationErrorScreen -> navigation.migrationErrorScreen()
|
||||
is AppNavigation.Command.OpenRemoteFilesManageScreen -> navigation.openRemoteFilesManageScreen(
|
||||
command.subscription
|
||||
|
|
|
@ -17,7 +17,6 @@ import com.anytypeio.anytype.core_utils.ui.BaseFragment
|
|||
import com.anytypeio.anytype.databinding.FragmentCreateObjectBinding
|
||||
import com.anytypeio.anytype.di.common.componentManager
|
||||
import com.anytypeio.anytype.presentation.objects.CreateObjectViewModel
|
||||
import com.anytypeio.anytype.presentation.objects.SupportedLayouts
|
||||
import com.anytypeio.anytype.ui.sets.ObjectSetFragment
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -49,7 +48,7 @@ class CreateObjectFragment : BaseFragment<FragmentCreateObjectBinding>(R.layout.
|
|||
} else {
|
||||
findNavController().navigate(
|
||||
R.id.objectNavigation,
|
||||
bundleOf(EditorFragment.ID_KEY to state.id),
|
||||
bundleOf(EditorFragment.CTX_KEY to state.id),
|
||||
navOptions
|
||||
)
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ import com.anytypeio.anytype.core_models.Key
|
|||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
import com.anytypeio.anytype.core_models.Url
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.core_ui.extensions.addTextFromSelectedStart
|
||||
import com.anytypeio.anytype.core_ui.extensions.color
|
||||
import com.anytypeio.anytype.core_ui.extensions.cursorYBottomCoordinate
|
||||
|
@ -186,7 +187,8 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
|
||||
private val keyboardDelayJobs = mutableListOf<Job>()
|
||||
|
||||
protected val ctx get() = arg<Id>(ID_KEY)
|
||||
protected val ctx get() = arg<Id>(CTX_KEY)
|
||||
protected val space get() = arg<Id>(SPACE_ID_KEY)
|
||||
|
||||
private val screen: Point by lazy { screen() }
|
||||
|
||||
|
@ -487,7 +489,7 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
}
|
||||
}
|
||||
}
|
||||
vm.onStart(id = extractDocumentId(), saveAsLastOpened = saveAsLastOpened())
|
||||
vm.onStart(id = extractDocumentId(), space = space, saveAsLastOpened = saveAsLastOpened())
|
||||
super.onStart()
|
||||
}
|
||||
|
||||
|
@ -616,7 +618,8 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
.longClicks(withHaptic = true)
|
||||
.onEach {
|
||||
val dialog = SelectObjectTypeFragment.new(
|
||||
flow = SelectObjectTypeFragment.FLOW_CREATE_OBJECT
|
||||
flow = SelectObjectTypeFragment.FLOW_CREATE_OBJECT,
|
||||
space = space
|
||||
).apply {
|
||||
onTypeSelected = {
|
||||
vm.onAddNewDocumentClicked(it)
|
||||
|
@ -1053,7 +1056,8 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
val dialog = SelectObjectTypeFragment.newInstance(
|
||||
excludedTypeKeys = command.excludedTypes,
|
||||
onTypeSelected = vm::onObjectTypeChanged,
|
||||
flow = SelectObjectTypeFragment.FLOW_CHANGE_TYPE
|
||||
flow = SelectObjectTypeFragment.FLOW_CHANGE_TYPE,
|
||||
space = space
|
||||
)
|
||||
dialog.show(childFragmentManager, null)
|
||||
}
|
||||
|
@ -1063,6 +1067,7 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
delay(DEFAULT_ANIM_DURATION)
|
||||
val fr = MoveToFragment.new(
|
||||
ctx = ctx,
|
||||
space = space,
|
||||
blocks = command.blocks,
|
||||
restorePosition = command.restorePosition,
|
||||
restoreBlock = command.restoreBlock
|
||||
|
@ -1078,7 +1083,10 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
middleString = R.string.snack_move_to
|
||||
) {
|
||||
if (command.isDataView) {
|
||||
vm.proceedWithOpeningDataViewObject(command.id)
|
||||
vm.proceedWithOpeningDataViewObject(
|
||||
target = command.id,
|
||||
space = SpaceId(command.space)
|
||||
)
|
||||
} else {
|
||||
vm.proceedWithOpeningObject(command.id)
|
||||
}
|
||||
|
@ -1953,7 +1961,7 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
|
||||
private fun extractDocumentId(): String {
|
||||
return requireArguments()
|
||||
.getString(ID_KEY)
|
||||
.getString(CTX_KEY)
|
||||
?: throw IllegalStateException("Document id missing")
|
||||
}
|
||||
|
||||
|
@ -2058,6 +2066,7 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
|
||||
override fun onMoveTo(
|
||||
target: Id,
|
||||
space: Id,
|
||||
blocks: List<Id>,
|
||||
text: String,
|
||||
icon: ObjectIcon,
|
||||
|
@ -2068,7 +2077,8 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
text = text,
|
||||
icon = icon,
|
||||
blocks = blocks,
|
||||
isDataView = isDataView
|
||||
isDataView = isDataView,
|
||||
space = space
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -2168,11 +2178,10 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
|
||||
companion object {
|
||||
|
||||
fun newInstance(id: String): EditorFragment = EditorFragment().apply {
|
||||
arguments = bundleOf(ID_KEY to id)
|
||||
}
|
||||
fun args(ctx: Id, space: Id) = bundleOf(CTX_KEY to ctx, SPACE_ID_KEY to space)
|
||||
|
||||
const val ID_KEY = "id"
|
||||
const val CTX_KEY = "args.editor.ctx-id"
|
||||
const val SPACE_ID_KEY = "args.editor.space-id"
|
||||
|
||||
const val DEFAULT_ANIM_DURATION = 150L
|
||||
const val DEFAULT_DELAY_BLOCK_ACTION_TOOLBAR = 100L
|
||||
|
|
|
@ -55,7 +55,11 @@ abstract class ObjectMenuBaseFragment :
|
|||
|
||||
private val actionAdapter by lazy {
|
||||
ObjectActionAdapter { action ->
|
||||
vm.onActionClicked(ctx, action)
|
||||
vm.onActionClicked(
|
||||
ctx = ctx,
|
||||
space = space,
|
||||
action = action
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,13 +78,13 @@ abstract class ObjectMenuBaseFragment :
|
|||
}
|
||||
|
||||
override fun onStart() {
|
||||
click(binding.objectDiagnostics) { vm.onDiagnosticsClicked(ctx) }
|
||||
click(binding.objectDiagnostics) { vm.onDiagnosticsClicked(ctx = ctx) }
|
||||
click(binding.optionHistory) { vm.onHistoryClicked() }
|
||||
click(binding.optionLayout) { vm.onLayoutClicked(ctx) }
|
||||
click(binding.optionIcon) { vm.onIconClicked(ctx) }
|
||||
click(binding.optionLayout) { vm.onLayoutClicked(ctx = ctx, space = space) }
|
||||
click(binding.optionIcon) { vm.onIconClicked(ctx = ctx, space = space) }
|
||||
click(binding.optionRelations) { vm.onRelationsClicked() }
|
||||
click(binding.optionCover) { vm.onCoverClicked(ctx) }
|
||||
click(binding.debugGoroutines) { vm.onDiagnosticsGoroutinesClicked(ctx) }
|
||||
click(binding.optionCover) { vm.onCoverClicked(ctx = ctx, space = space) }
|
||||
click(binding.debugGoroutines) { vm.onDiagnosticsGoroutinesClicked(ctx = ctx) }
|
||||
|
||||
proceed(vm.actions) { actionAdapter.submitList(it) }
|
||||
proceed(vm.toasts) { toast(it) }
|
||||
|
@ -249,9 +253,15 @@ abstract class ObjectMenuBaseFragment :
|
|||
anchor = binding.anchor
|
||||
) {
|
||||
if (command.isCollection) {
|
||||
vm.proceedWithOpeningCollection(command.id)
|
||||
vm.proceedWithOpeningCollection(
|
||||
target = command.id,
|
||||
space = command.space
|
||||
)
|
||||
} else {
|
||||
vm.proceedWithOpeningPage(command.id)
|
||||
vm.proceedWithOpeningPage(
|
||||
target = command.id,
|
||||
space = command.space
|
||||
)
|
||||
}
|
||||
}
|
||||
}, 300L)
|
||||
|
@ -260,22 +270,34 @@ abstract class ObjectMenuBaseFragment :
|
|||
|
||||
override fun onMoveTo(
|
||||
target: Id,
|
||||
space: Id,
|
||||
blocks: List<Id>,
|
||||
text: String,
|
||||
icon: ObjectIcon,
|
||||
isDataView: Boolean
|
||||
) {
|
||||
vm.onLinkedMyselfTo(myself = ctx, addTo = target, fromName)
|
||||
vm.onLinkedMyselfTo(
|
||||
myself = ctx,
|
||||
addTo = target,
|
||||
fromName = fromName,
|
||||
space = space
|
||||
)
|
||||
}
|
||||
|
||||
override fun backLink(id: Id, name: String, layout: ObjectType.Layout?, icon: ObjectIcon) {
|
||||
override fun backLink(
|
||||
id: Id,
|
||||
name: String,
|
||||
layout: ObjectType.Layout?,
|
||||
icon: ObjectIcon
|
||||
) {
|
||||
vm.onBackLinkOrAddToObjectAction(
|
||||
ctx = ctx,
|
||||
backLinkId = id,
|
||||
backLinkName = name,
|
||||
backLinkLayout = layout,
|
||||
backLinkIcon = icon,
|
||||
fromName = fromName.orEmpty()
|
||||
fromName = fromName.orEmpty(),
|
||||
space = space
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -89,23 +89,13 @@ class HomeScreenFragment : BaseComposeFragment() {
|
|||
runCatching { navigation().openPageSearch() }
|
||||
},
|
||||
onLibraryClicked = {
|
||||
runCatching { navigation().openLibrary() }
|
||||
vm.onLibraryClicked()
|
||||
},
|
||||
onCreateNewObjectClicked = throttledClick(
|
||||
onClick = { vm.onCreateNewObjectClicked() }
|
||||
),
|
||||
onCreateNewObjectLongClicked = throttledClick(
|
||||
onClick = {
|
||||
val dialog = SelectObjectTypeFragment.new(
|
||||
flow = SelectObjectTypeFragment.FLOW_CREATE_OBJECT
|
||||
).apply {
|
||||
onTypeSelected = {
|
||||
vm.onCreateNewObjectClicked(it)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
dialog.show(childFragmentManager, "TEST")
|
||||
}
|
||||
onClick = { vm.onCreateNewObjectLongClicked() }
|
||||
),
|
||||
onProfileClicked = throttledClick(
|
||||
onClick = {
|
||||
|
@ -278,15 +268,45 @@ class HomeScreenFragment : BaseComposeFragment() {
|
|||
Timber.e(e, "Error while opening space settings")
|
||||
}
|
||||
}
|
||||
is Command.OpenObjectCreateDialog -> {
|
||||
val dialog = SelectObjectTypeFragment.new(
|
||||
flow = SelectObjectTypeFragment.FLOW_CREATE_OBJECT,
|
||||
space = command.space.id
|
||||
).apply {
|
||||
onTypeSelected = {
|
||||
vm.onCreateNewObjectClicked(it)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
dialog.show(childFragmentManager, "object-create-dialog")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun proceed(destination: Navigation) {
|
||||
Timber.d("New destination: $destination")
|
||||
when (destination) {
|
||||
is Navigation.OpenObject -> navigation().openDocument(destination.ctx)
|
||||
is Navigation.OpenSet -> navigation().openObjectSet(destination.ctx)
|
||||
is Navigation.ExpandWidget -> navigation().launchCollections(destination.subscription)
|
||||
is Navigation.OpenObject -> runCatching {
|
||||
navigation().openDocument(
|
||||
target = destination.ctx,
|
||||
space = destination.space
|
||||
)
|
||||
}
|
||||
is Navigation.OpenSet -> runCatching {
|
||||
navigation().openObjectSet(
|
||||
target = destination.ctx,
|
||||
space = destination.space
|
||||
)
|
||||
}
|
||||
is Navigation.ExpandWidget -> runCatching {
|
||||
navigation().launchCollections(
|
||||
subscription = destination.subscription,
|
||||
space = destination.space
|
||||
)
|
||||
}
|
||||
is Navigation.OpenLibrary -> runCatching {
|
||||
navigation().openLibrary(destination.space)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,10 @@ import androidx.fragment.app.setFragmentResultListener
|
|||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.core_ui.extensions.simpleIcon
|
||||
import com.anytypeio.anytype.core_utils.ext.arg
|
||||
import com.anytypeio.anytype.core_utils.ext.safeNavigate
|
||||
import com.anytypeio.anytype.core_utils.ext.subscribe
|
||||
import com.anytypeio.anytype.core_utils.ext.toast
|
||||
|
@ -53,6 +56,8 @@ class LibraryFragment : BaseComposeFragment() {
|
|||
|
||||
private val vm by viewModels<LibraryViewModel> { factory }
|
||||
|
||||
private val space get() = arg<Id>(ARG_SPACE_ID_KEY)
|
||||
|
||||
@OptIn(ExperimentalAnimationApi::class)
|
||||
@FlowPreview
|
||||
@ExperimentalPagerApi
|
||||
|
@ -73,7 +78,8 @@ class LibraryFragment : BaseComposeFragment() {
|
|||
},
|
||||
onCreateObjectLongClicked = {
|
||||
val dialog = SelectObjectTypeFragment.new(
|
||||
flow = SelectObjectTypeFragment.FLOW_CREATE_OBJECT
|
||||
flow = SelectObjectTypeFragment.FLOW_CREATE_OBJECT,
|
||||
space = space
|
||||
).apply {
|
||||
onTypeSelected = {
|
||||
vm.onCreateObjectOfTypeClicked(it)
|
||||
|
@ -146,8 +152,9 @@ class LibraryFragment : BaseComposeFragment() {
|
|||
findNavController().safeNavigate(
|
||||
R.id.libraryFragment,
|
||||
R.id.objectNavigation,
|
||||
bundleOf(
|
||||
EditorFragment.ID_KEY to it.id
|
||||
EditorFragment.args(
|
||||
ctx = it.id,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -204,11 +211,25 @@ class LibraryFragment : BaseComposeFragment() {
|
|||
}
|
||||
|
||||
override fun injectDependencies() {
|
||||
componentManager().libraryComponent.get(requireContext()).inject(this)
|
||||
componentManager()
|
||||
.libraryComponent
|
||||
.get(
|
||||
Pair(
|
||||
requireContext(),
|
||||
LibraryViewModel.Params(
|
||||
space = SpaceId(space)
|
||||
)
|
||||
)
|
||||
)
|
||||
.inject(this)
|
||||
}
|
||||
|
||||
override fun releaseDependencies() {
|
||||
componentManager().libraryComponent.release()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val ARG_SPACE_ID_KEY = "arg.library.space-id"
|
||||
fun args(space: Id) = bundleOf(ARG_SPACE_ID_KEY to space)
|
||||
}
|
||||
}
|
|
@ -54,6 +54,7 @@ class MoveToFragment : BaseBottomSheetTextInputFragment<FragmentObjectSearchBind
|
|||
|
||||
private val blocks get() = arg<List<Id>>(ARG_BLOCKS)
|
||||
private val ctx get() = arg<Id>(ARG_CTX)
|
||||
private val space get() = arg<Id>(ARG_SPACE)
|
||||
private val restorePosition get() = argOrNull<Int>(ARG_RESTORE_POSITION)
|
||||
private val restoreBlock get() = argOrNull<Id>(ARG_RESTORE_BLOCK)
|
||||
private val title get() = argOrNull<String>(ARG_TITLE)
|
||||
|
@ -179,6 +180,7 @@ class MoveToFragment : BaseBottomSheetTextInputFragment<FragmentObjectSearchBind
|
|||
withParent<OnMoveToAction> {
|
||||
onMoveTo(
|
||||
target = command.view.id,
|
||||
space = space,
|
||||
text = command.view.name,
|
||||
icon = command.view.icon,
|
||||
blocks = blocks,
|
||||
|
@ -266,6 +268,7 @@ class MoveToFragment : BaseBottomSheetTextInputFragment<FragmentObjectSearchBind
|
|||
companion object {
|
||||
const val ARG_BLOCKS = "arg.move_to.blocks"
|
||||
const val ARG_CTX = "arg.move_to.ctx"
|
||||
const val ARG_SPACE = "arg.move_to.space"
|
||||
const val ARG_RESTORE_POSITION = "arg.move_to.position"
|
||||
const val ARG_RESTORE_BLOCK = "arg.move_to.restore_block"
|
||||
const val ARG_TITLE = "arg.move_to.title"
|
||||
|
@ -273,6 +276,7 @@ class MoveToFragment : BaseBottomSheetTextInputFragment<FragmentObjectSearchBind
|
|||
|
||||
fun new(
|
||||
ctx: Id,
|
||||
space: Id,
|
||||
blocks: List<Id>,
|
||||
restorePosition: Int?,
|
||||
restoreBlock: Id?,
|
||||
|
@ -280,6 +284,7 @@ class MoveToFragment : BaseBottomSheetTextInputFragment<FragmentObjectSearchBind
|
|||
) = MoveToFragment().apply {
|
||||
arguments = bundleOf(
|
||||
ARG_CTX to ctx,
|
||||
ARG_SPACE to space,
|
||||
ARG_BLOCKS to blocks,
|
||||
ARG_RESTORE_POSITION to restorePosition,
|
||||
ARG_RESTORE_BLOCK to restoreBlock,
|
||||
|
@ -290,7 +295,14 @@ class MoveToFragment : BaseBottomSheetTextInputFragment<FragmentObjectSearchBind
|
|||
}
|
||||
|
||||
interface OnMoveToAction {
|
||||
fun onMoveTo(target: Id, blocks: List<Id>, text: String, icon: ObjectIcon, isDataView: Boolean)
|
||||
fun onMoveTo(
|
||||
target: Id,
|
||||
space: Id,
|
||||
blocks: List<Id>,
|
||||
text: String,
|
||||
icon: ObjectIcon,
|
||||
isDataView: Boolean
|
||||
)
|
||||
fun onMoveToClose(blocks: List<Id>, restorePosition: Int?, restoreBlock: Id?)
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,11 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
|||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Key
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.ext.EMPTY_STRING_VALUE
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.core_models.primitives.TypeKey
|
||||
import com.anytypeio.anytype.core_utils.ext.arg
|
||||
import com.anytypeio.anytype.core_utils.ext.argOrNull
|
||||
|
@ -52,6 +54,8 @@ class SelectObjectTypeFragment : BaseBottomSheetComposeFragment() {
|
|||
|
||||
private val flow get() = arg<FlowType>(FLOW_TYPE_KEY)
|
||||
|
||||
private val space get() = arg<Id>(SPACE_ID_KEY)
|
||||
|
||||
private val vm by viewModels<SelectObjectTypeViewModel> { factory }
|
||||
|
||||
lateinit var onTypeSelected: (ObjectWrapper.Type) -> Unit
|
||||
|
@ -157,7 +161,7 @@ class SelectObjectTypeFragment : BaseBottomSheetComposeFragment() {
|
|||
findNavController().navigate(
|
||||
R.id.objectNavigation,
|
||||
bundleOf(
|
||||
EditorFragment.ID_KEY to nav.target
|
||||
EditorFragment.CTX_KEY to nav.target
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -208,7 +212,10 @@ class SelectObjectTypeFragment : BaseBottomSheetComposeFragment() {
|
|||
override fun injectDependencies() {
|
||||
componentManager()
|
||||
.selectObjectTypeComponent.get(
|
||||
params = excludedTypeKeys?.map { TypeKey(it) } ?: emptyList()
|
||||
params = SelectObjectTypeViewModel.Params(
|
||||
excludedTypeKeys = excludedTypeKeys?.map { TypeKey(it) } ?: emptyList(),
|
||||
space = SpaceId(space)
|
||||
)
|
||||
)
|
||||
.inject(this)
|
||||
}
|
||||
|
@ -218,7 +225,7 @@ class SelectObjectTypeFragment : BaseBottomSheetComposeFragment() {
|
|||
}
|
||||
|
||||
companion object {
|
||||
|
||||
const val SPACE_ID_KEY = "arg.select-object-type.space-id"
|
||||
const val EXCLUDED_TYPE_KEYS_ARG_KEY = "arg.select-object-type.excluded-type-keys"
|
||||
const val FLOW_TYPE_KEY = "arg.select-object-type.flow-type"
|
||||
const val DROP_DOWN_MENU_ACTION_DELAY = 100L
|
||||
|
@ -229,17 +236,22 @@ class SelectObjectTypeFragment : BaseBottomSheetComposeFragment() {
|
|||
fun newInstance(
|
||||
excludedTypeKeys: List<Key>,
|
||||
onTypeSelected: (ObjectWrapper.Type) -> Unit,
|
||||
flow: FlowType = FLOW_CHANGE_TYPE
|
||||
flow: FlowType = FLOW_CHANGE_TYPE,
|
||||
space: Id
|
||||
): SelectObjectTypeFragment = SelectObjectTypeFragment().apply {
|
||||
this.onTypeSelected = onTypeSelected
|
||||
arguments = bundleOf(
|
||||
EXCLUDED_TYPE_KEYS_ARG_KEY to excludedTypeKeys,
|
||||
FLOW_TYPE_KEY to flow
|
||||
EXCLUDED_TYPE_KEYS_ARG_KEY to excludedTypeKeys,
|
||||
FLOW_TYPE_KEY to flow,
|
||||
SPACE_ID_KEY to space
|
||||
)
|
||||
}
|
||||
|
||||
fun new(flow: FlowType = FLOW_CREATE_OBJECT) = SelectObjectTypeFragment().apply {
|
||||
arguments = bundleOf(FLOW_TYPE_KEY to flow)
|
||||
fun new(
|
||||
flow: FlowType = FLOW_CREATE_OBJECT,
|
||||
space: Id
|
||||
) = SelectObjectTypeFragment().apply {
|
||||
arguments = bundleOf(FLOW_TYPE_KEY to flow, SPACE_ID_KEY to space)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,12 +115,14 @@ abstract class RelationValueBaseFragment<T: ViewBinding> : BaseBottomSheetFragm
|
|||
ctx = ctx,
|
||||
id = o.id,
|
||||
layout = o.layout,
|
||||
profileLinkIdentity = o.profileLinkIdentity
|
||||
profileLinkIdentity = o.profileLinkIdentity,
|
||||
space = o.space
|
||||
)
|
||||
} else {
|
||||
vm.onNonExistentObjectClicked(
|
||||
ctx = ctx,
|
||||
target = o.id
|
||||
target = o.id,
|
||||
space = o.space
|
||||
)
|
||||
}
|
||||
},
|
||||
|
@ -132,7 +134,7 @@ abstract class RelationValueBaseFragment<T: ViewBinding> : BaseBottomSheetFragm
|
|||
objectId = obj
|
||||
)
|
||||
},
|
||||
onFileClicked = { o -> vm.onFileClicked(o.id) },
|
||||
onFileClicked = { o -> vm.onFileClicked(target = o.id, space = o.space) },
|
||||
onRemoveFileClicked = { file ->
|
||||
vm.onRemoveFileFromObjectClicked(
|
||||
ctx = ctx,
|
||||
|
@ -199,7 +201,10 @@ abstract class RelationValueBaseFragment<T: ViewBinding> : BaseBottomSheetFragm
|
|||
is AppNavigation.Command.OpenObject -> {
|
||||
findNavController().navigate(
|
||||
R.id.objectNavigation,
|
||||
bundleOf(EditorFragment.ID_KEY to command.id)
|
||||
EditorFragment.args(
|
||||
ctx = command.target,
|
||||
space = command.space
|
||||
)
|
||||
)
|
||||
}
|
||||
else -> toast("Unexpected nav command: $command")
|
||||
|
|
|
@ -77,7 +77,7 @@ class ObjectValueFragment : BaseBottomSheetComposeFragment() {
|
|||
is ObjectValueViewModel.Command.OpenObject -> {
|
||||
findNavController().navigate(
|
||||
R.id.objectNavigation,
|
||||
bundleOf(EditorFragment.ID_KEY to command.id)
|
||||
bundleOf(EditorFragment.CTX_KEY to command.id)
|
||||
)
|
||||
dismiss()
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ import com.anytypeio.anytype.core_ui.widgets.dv.ViewersWidget
|
|||
import com.anytypeio.anytype.core_ui.widgets.text.TextInputWidget
|
||||
import com.anytypeio.anytype.core_ui.widgets.toolbar.DataViewInfo
|
||||
import com.anytypeio.anytype.core_utils.OnSwipeListener
|
||||
import com.anytypeio.anytype.core_utils.ext.arg
|
||||
import com.anytypeio.anytype.core_utils.ext.argString
|
||||
import com.anytypeio.anytype.core_utils.ext.dimen
|
||||
import com.anytypeio.anytype.core_utils.ext.drawable
|
||||
|
@ -127,6 +128,7 @@ import com.anytypeio.anytype.ui.templates.EditorTemplateFragment.Companion.ARG_T
|
|||
import com.anytypeio.anytype.ui.templates.EditorTemplateFragment.Companion.ARG_TEMPLATE_ID
|
||||
import com.bumptech.glide.Glide
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.flow.filterNotNull
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
|
@ -223,7 +225,8 @@ open class ObjectSetFragment :
|
|||
)
|
||||
}
|
||||
|
||||
private val ctx: String get() = argString(CONTEXT_ID_KEY)
|
||||
private val ctx: Id get() = argString(CONTEXT_ID_KEY)
|
||||
private val space: Id get() = arg<String>(SPACE_ID_KEY)
|
||||
|
||||
@Inject
|
||||
lateinit var factory: ObjectSetViewModelFactory
|
||||
|
@ -319,7 +322,8 @@ open class ObjectSetFragment :
|
|||
.longClicks(withHaptic = true)
|
||||
.onEach {
|
||||
val dialog = SelectObjectTypeFragment.new(
|
||||
flow = SelectObjectTypeFragment.FLOW_CREATE_OBJECT
|
||||
flow = SelectObjectTypeFragment.FLOW_CREATE_OBJECT,
|
||||
space = space
|
||||
).apply {
|
||||
onTypeSelected = {
|
||||
vm.onAddNewDocumentClicked(it)
|
||||
|
@ -523,6 +527,13 @@ open class ObjectSetFragment :
|
|||
lifecycleScope.subscribe(vm.isCustomizeViewPanelVisible) { isCustomizeViewPanelVisible ->
|
||||
if (isCustomizeViewPanelVisible) showBottomPanel() else hideBottomPanel()
|
||||
}
|
||||
lifecycleScope.subscribe(vm.permission.filterNotNull()) { permission ->
|
||||
if (permission.isOwnerOrEditor()) {
|
||||
binding.topToolbar.ivThreeDots.visible()
|
||||
} else {
|
||||
binding.topToolbar.ivThreeDots.invisible()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setStatus(status: SyncStatusView?) {
|
||||
|
@ -606,6 +617,11 @@ open class ObjectSetFragment :
|
|||
dataViewHeader.visible()
|
||||
viewerTitle.isEnabled = true
|
||||
setupNewButtons(state.isCreateObjectAllowed)
|
||||
if (state.isEditingViewAllowed) {
|
||||
customizeViewButton.visible()
|
||||
} else {
|
||||
customizeViewButton.invisible()
|
||||
}
|
||||
customizeViewButton.isEnabled = true
|
||||
setCurrentViewerName(state.viewer?.title)
|
||||
setViewer(viewer = state.viewer)
|
||||
|
@ -729,6 +745,9 @@ open class ObjectSetFragment :
|
|||
|
||||
private fun bindHeader(header: SetOrCollectionHeaderState.Default) {
|
||||
setupHeaderMargins(header)
|
||||
|
||||
title.isEnabled = !header.isReadOnlyMode
|
||||
|
||||
if (title.text.toString() != header.title.text) {
|
||||
title.pauseTextWatchers {
|
||||
title.setText(header.title.text)
|
||||
|
@ -1206,7 +1225,7 @@ open class ObjectSetFragment :
|
|||
bindHeader(header)
|
||||
}
|
||||
is SetOrCollectionHeaderState.None -> {
|
||||
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1245,7 +1264,7 @@ open class ObjectSetFragment :
|
|||
binding.bottomToolbar.bind(icon)
|
||||
}
|
||||
|
||||
vm.onStart(ctx)
|
||||
vm.onStart(ctx = ctx, space = space)
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
|
@ -1374,10 +1393,16 @@ open class ObjectSetFragment :
|
|||
|
||||
companion object {
|
||||
const val CONTEXT_ID_KEY = "arg.object_set.context"
|
||||
const val SPACE_ID_KEY = "arg.object_set.space-id"
|
||||
val EMPTY_TAG = null
|
||||
const val BOTTOM_PANEL_ANIM_DURATION = 150L
|
||||
const val DEFAULT_ANIM_DURATION = 300L
|
||||
const val DRAWABLE_ALPHA_FULL = 255
|
||||
const val DRAWABLE_ALPHA_ZERO = 0
|
||||
|
||||
fun args(ctx: Id, space: Id) = bundleOf(
|
||||
CONTEXT_ID_KEY to ctx,
|
||||
SPACE_ID_KEY to space
|
||||
)
|
||||
}
|
||||
}
|
|
@ -17,9 +17,9 @@ import com.anytypeio.anytype.di.common.componentManager
|
|||
import com.anytypeio.anytype.presentation.sets.ObjectSetRecordViewModel
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetRecordViewModel.Command
|
||||
import com.anytypeio.anytype.ui.editor.EditorFragment
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
class SetObjectSetRecordNameFragment : SetObjectCreateRecordFragmentBase<FragmentSetObjectSetRecordNameBinding>() {
|
||||
|
||||
|
@ -46,7 +46,7 @@ class SetObjectSetRecordNameFragment : SetObjectCreateRecordFragmentBase<Fragmen
|
|||
is Command.OpenObject -> {
|
||||
findNavController().navigate(
|
||||
R.id.objectNavigation,
|
||||
bundleOf(EditorFragment.ID_KEY to command.ctx)
|
||||
bundleOf(EditorFragment.CTX_KEY to command.ctx)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,10 +71,19 @@ class RemoteFilesManageFragment : BaseBottomSheetComposeFragment() {
|
|||
|
||||
private fun execute(command: CollectionViewModel.Command) {
|
||||
when (command) {
|
||||
is CollectionViewModel.Command.LaunchDocument -> launchDocument(command.id)
|
||||
is CollectionViewModel.Command.LaunchObjectSet -> launchObjectSet(command.target)
|
||||
is CollectionViewModel.Command.LaunchDocument -> launchDocument(
|
||||
target = command.target,
|
||||
space = command.space
|
||||
)
|
||||
is CollectionViewModel.Command.LaunchObjectSet -> launchObjectSet(
|
||||
target = command.target,
|
||||
space = command.space
|
||||
)
|
||||
is CollectionViewModel.Command.ConfirmRemoveFromBin -> confirmRemoveFromBin(command)
|
||||
is CollectionViewModel.Command.OpenCollection -> navigation.launchCollections(command.subscription)
|
||||
is CollectionViewModel.Command.OpenCollection -> navigation.launchCollections(
|
||||
subscription = command.subscription,
|
||||
space = command.space
|
||||
)
|
||||
is CollectionViewModel.Command.ToDesktop -> navigation.exitToDesktop()
|
||||
is CollectionViewModel.Command.ToSearch -> navigation.openPageSearch()
|
||||
is CollectionViewModel.Command.Exit -> exit()
|
||||
|
@ -94,12 +103,15 @@ class RemoteFilesManageFragment : BaseBottomSheetComposeFragment() {
|
|||
navigation.exit()
|
||||
}
|
||||
|
||||
private fun launchObjectSet(target: Id) {
|
||||
navigation.launchObjectSet(target)
|
||||
private fun launchObjectSet(target: Id, space: Id) {
|
||||
navigation.launchObjectSet(
|
||||
target = target,
|
||||
space = space
|
||||
)
|
||||
}
|
||||
|
||||
private fun launchDocument(id: Id) {
|
||||
navigation.launchDocument(id)
|
||||
private fun launchDocument(target: Id, space: Id) {
|
||||
navigation.launchDocument(target = target, space = space)
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
|
|
|
@ -24,7 +24,6 @@ import com.anytypeio.anytype.presentation.home.OpenObjectNavigation
|
|||
import com.anytypeio.anytype.presentation.sharing.AddToAnytypeViewModel
|
||||
import com.anytypeio.anytype.ui.editor.EditorFragment
|
||||
import com.anytypeio.anytype.ui.settings.typography
|
||||
import java.lang.IllegalStateException
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
|
@ -120,7 +119,7 @@ class SharingFragment : BaseBottomSheetComposeFragment() {
|
|||
findNavController().navigate(
|
||||
R.id.objectNavigation,
|
||||
bundleOf(
|
||||
EditorFragment.ID_KEY to nav.target
|
||||
EditorFragment.CTX_KEY to nav.target
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>(R.layout.fragment_spl
|
|||
findNavController().navigate(R.id.action_splashScreen_to_widgets)
|
||||
findNavController().navigate(
|
||||
R.id.objectNavigation,
|
||||
bundleOf(EditorFragment.ID_KEY to command.id),
|
||||
bundleOf(EditorFragment.CTX_KEY to command.id),
|
||||
)
|
||||
}
|
||||
is SplashViewModel.Command.NavigateToObjectSet -> {
|
||||
|
|
|
@ -126,7 +126,7 @@ class EditorTemplateFragment : EditorFragment() {
|
|||
): EditorTemplateFragment =
|
||||
EditorTemplateFragment().apply {
|
||||
arguments = bundleOf(
|
||||
ID_KEY to id,
|
||||
CTX_KEY to id,
|
||||
ARG_TARGET_TYPE_ID to targetTypeId,
|
||||
ARG_TARGET_TYPE_KEY to targetTypeKey,
|
||||
ARG_TEMPLATE_TYPE to type
|
||||
|
|
|
@ -7,10 +7,12 @@ import android.view.ViewGroup
|
|||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.compose.ui.platform.ViewCompositionStrategy
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_utils.ext.arg
|
||||
import com.anytypeio.anytype.core_utils.ext.argString
|
||||
import com.anytypeio.anytype.core_utils.ui.BaseComposeFragment
|
||||
import com.anytypeio.anytype.core_utils.ui.proceed
|
||||
|
@ -32,6 +34,8 @@ class CollectionFragment : BaseComposeFragment() {
|
|||
|
||||
private val navigation get() = navigation()
|
||||
|
||||
private val space get() = arg<Id>(SPACE_ID_KEY)
|
||||
|
||||
private val subscription: Subscription by lazy {
|
||||
SubscriptionMapper().map(
|
||||
argString(
|
||||
|
@ -56,7 +60,8 @@ class CollectionFragment : BaseComposeFragment() {
|
|||
vm = vm,
|
||||
onCreateObjectLongClicked = {
|
||||
val dialog = SelectObjectTypeFragment.new(
|
||||
flow = SelectObjectTypeFragment.FLOW_CREATE_OBJECT
|
||||
flow = SelectObjectTypeFragment.FLOW_CREATE_OBJECT,
|
||||
space = space
|
||||
).apply {
|
||||
onTypeSelected = {
|
||||
vm.onAddClicked(it)
|
||||
|
@ -78,11 +83,20 @@ class CollectionFragment : BaseComposeFragment() {
|
|||
|
||||
private fun execute(command: Command) {
|
||||
when (command) {
|
||||
is Command.LaunchDocument -> launchDocument(command.id)
|
||||
is Command.LaunchObjectSet -> launchObjectSet(command.target)
|
||||
is Command.LaunchDocument -> launchDocument(
|
||||
target = command.target,
|
||||
space = command.space
|
||||
)
|
||||
is Command.LaunchObjectSet -> launchObjectSet(
|
||||
target = command.target,
|
||||
space = command.space
|
||||
)
|
||||
is Command.Exit -> exit()
|
||||
is Command.ConfirmRemoveFromBin -> confirmRemoveFromBin(command)
|
||||
is Command.OpenCollection -> navigation.launchCollections(command.subscription)
|
||||
is Command.OpenCollection -> navigation.launchCollections(
|
||||
subscription = command.subscription,
|
||||
space = space
|
||||
)
|
||||
is Command.ToDesktop -> navigation.exitToDesktop()
|
||||
is Command.ToSearch -> navigation.openPageSearch()
|
||||
is Command.SelectSpace -> {
|
||||
|
@ -104,12 +118,18 @@ class CollectionFragment : BaseComposeFragment() {
|
|||
navigation.exit()
|
||||
}
|
||||
|
||||
private fun launchObjectSet(target: Id) {
|
||||
navigation.launchObjectSet(target)
|
||||
private fun launchObjectSet(target: Id, space: Id) {
|
||||
navigation.launchObjectSet(
|
||||
target = target,
|
||||
space = space
|
||||
)
|
||||
}
|
||||
|
||||
private fun launchDocument(id: Id) {
|
||||
navigation.launchDocument(id)
|
||||
private fun launchDocument(target: Id, space: Id) {
|
||||
navigation.launchDocument(
|
||||
target = target,
|
||||
space = space
|
||||
)
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
|
@ -127,5 +147,10 @@ class CollectionFragment : BaseComposeFragment() {
|
|||
|
||||
companion object {
|
||||
const val SUBSCRIPTION_KEY: String = "arg.collection.subscription"
|
||||
const val SPACE_ID_KEY = "arg.collection.space-id"
|
||||
fun args(subscription: Id, space: Id) = bundleOf(
|
||||
SUBSCRIPTION_KEY to subscription,
|
||||
SPACE_ID_KEY to space
|
||||
)
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ import android.view.Gravity
|
|||
import android.view.View
|
||||
import android.widget.PopupMenu
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.core_ui.R
|
||||
import com.anytypeio.anytype.presentation.editor.editor.ObjectTypeMenuItem
|
||||
|
||||
|
@ -12,7 +13,7 @@ class ObjectTypePopupMenu(
|
|||
context: Context,
|
||||
anchor: View,
|
||||
onChangeTypeClicked: () -> Unit,
|
||||
onOpenSetClicked: (Id) -> Unit,
|
||||
onOpenSetClicked: (Id, SpaceId) -> Unit,
|
||||
onCreateSetClicked: (Id) -> Unit,
|
||||
items: List<ObjectTypeMenuItem>
|
||||
) : PopupMenu(context, anchor, Gravity.BOTTOM, 0, R.style.DefaultPopupMenuStyle) {
|
||||
|
@ -49,7 +50,9 @@ class ObjectTypePopupMenu(
|
|||
index,
|
||||
res.getString(R.string.menu_type_open_set, objectTypeMenuItem.typeName)
|
||||
).setOnMenuItemClickListener {
|
||||
onOpenSetClicked(objectTypeMenuItem.set)
|
||||
onOpenSetClicked(
|
||||
objectTypeMenuItem.set, SpaceId(objectTypeMenuItem.space)
|
||||
)
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,7 +202,8 @@ fun PreviewObjectItem() {
|
|||
type = "Type",
|
||||
typeName = "Type Name",
|
||||
description = "Description",
|
||||
icon = ObjectIcon.Basic.Emoji("\uD83D\uDCA1")
|
||||
icon = ObjectIcon.Basic.Emoji("\uD83D\uDCA1"),
|
||||
space = "space-1"
|
||||
),
|
||||
isSelected = true,
|
||||
number = 1,
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.anytypeio.anytype.core_models.multiplayer.SpaceMemberPermissions
|
|||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
||||
import com.anytypeio.anytype.domain.debugging.Logger
|
||||
import com.anytypeio.anytype.domain.library.StoreSearchParams
|
||||
import com.anytypeio.anytype.domain.library.StorelessSubscriptionContainer
|
||||
import javax.inject.Inject
|
||||
|
@ -48,7 +49,8 @@ class DefaultUserPermissionProvider @Inject constructor(
|
|||
private val container: StorelessSubscriptionContainer,
|
||||
private val repo: AuthRepository,
|
||||
private val dispatchers: AppCoroutineDispatchers,
|
||||
private val scope: CoroutineScope
|
||||
private val scope: CoroutineScope,
|
||||
private val logger: Logger
|
||||
) : UserPermissionProvider {
|
||||
|
||||
private val members = MutableStateFlow<List<ObjectWrapper.SpaceMember>>(emptyList())
|
||||
|
|
|
@ -72,6 +72,9 @@ class CreateObject @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* DROID-2341 TODO provide custom space to params?
|
||||
*/
|
||||
data class Param(
|
||||
val type: TypeKey? = null,
|
||||
val template: Id? = null,
|
||||
|
|
|
@ -125,6 +125,7 @@ interface SpaceManager {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated("Do not use.")
|
||||
suspend fun SpaceManager.getSpaceWithTechSpace(): List<Id> {
|
||||
val config = getConfig()
|
||||
return if (config != null) {
|
||||
|
@ -132,4 +133,13 @@ suspend fun SpaceManager.getSpaceWithTechSpace(): List<Id> {
|
|||
} else {
|
||||
listOf(get())
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun SpaceManager.getSpaceWithTechSpace(space: Id): List<Id> {
|
||||
val config = getConfig(SpaceId(space))
|
||||
return if (config != null) {
|
||||
listOf(config.space, config.techSpace)
|
||||
} else {
|
||||
listOf(get())
|
||||
}
|
||||
}
|
|
@ -1035,7 +1035,6 @@ class Middleware @Inject constructor(
|
|||
val response = service.objectCreateSet(request)
|
||||
|
||||
if (BuildConfig.DEBUG) logResponse(response)
|
||||
|
||||
return Response.Set.Create(
|
||||
targetId = response.objectId,
|
||||
payload = response.event.toPayload(),
|
||||
|
|
|
@ -21,7 +21,7 @@ sealed class Action {
|
|||
data class SetUnsplashImage(val img: Id) : Action()
|
||||
object SearchOnPage: Action()
|
||||
object UndoRedo : Action()
|
||||
data class OpenObject(val id: Id) : Action()
|
||||
data class OpenCollection(val id: Id) : Action()
|
||||
data class Duplicate(val id: Id) : Action()
|
||||
data class OpenObject(val target: Id, val space: Id) : Action()
|
||||
data class OpenCollection(val target: Id, val space: Id) : Action()
|
||||
data class Duplicate(val target: Id, val space: Id) : Action()
|
||||
}
|
|
@ -99,7 +99,6 @@ import com.anytypeio.anytype.domain.templates.ApplyTemplate
|
|||
import com.anytypeio.anytype.domain.unsplash.DownloadUnsplashImage
|
||||
import com.anytypeio.anytype.domain.workspace.InterceptFileLimitEvents
|
||||
import com.anytypeio.anytype.domain.workspace.SpaceManager
|
||||
import com.anytypeio.anytype.domain.workspace.getSpaceWithTechSpace
|
||||
import com.anytypeio.anytype.presentation.BuildConfig
|
||||
import com.anytypeio.anytype.presentation.common.Action
|
||||
import com.anytypeio.anytype.presentation.common.Delegator
|
||||
|
@ -197,7 +196,6 @@ import com.anytypeio.anytype.presentation.editor.selection.updateTableBlockSelec
|
|||
import com.anytypeio.anytype.presentation.editor.selection.updateTableBlockTab
|
||||
import com.anytypeio.anytype.presentation.editor.template.SelectTemplateViewState
|
||||
import com.anytypeio.anytype.presentation.editor.toggle.ToggleStateHolder
|
||||
import com.anytypeio.anytype.presentation.extension.getProperObjectName
|
||||
import com.anytypeio.anytype.presentation.extension.getUrlForFileBlock
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsBlockActionEvent
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsBlockAlignEvent
|
||||
|
@ -378,9 +376,16 @@ class EditorViewModel(
|
|||
|
||||
/**
|
||||
* Currently opened document id.
|
||||
* TODO move to vm params
|
||||
*/
|
||||
var context: String = EMPTY_CONTEXT
|
||||
|
||||
/**
|
||||
* Space in which this document exists.
|
||||
* TODO move to vm params
|
||||
*/
|
||||
lateinit var space: String
|
||||
|
||||
/**
|
||||
* Current document
|
||||
*/
|
||||
|
@ -420,11 +425,18 @@ class EditorViewModel(
|
|||
is Action.SetUnsplashImage -> {
|
||||
proceedWithSettingUnsplashImage(action)
|
||||
}
|
||||
is Action.Duplicate -> proceedWithOpeningObject(action.id)
|
||||
is Action.Duplicate -> proceedWithOpeningObject(
|
||||
target = action.target
|
||||
)
|
||||
Action.SearchOnPage -> onEnterSearchModeClicked()
|
||||
Action.UndoRedo -> onUndoRedoActionClicked()
|
||||
is Action.OpenObject -> proceedWithOpeningObject(action.id)
|
||||
is Action.OpenCollection -> proceedWithOpeningDataViewObject(action.id)
|
||||
is Action.OpenObject -> proceedWithOpeningObject(
|
||||
target = action.target
|
||||
)
|
||||
is Action.OpenCollection -> proceedWithOpeningDataViewObject(
|
||||
target = action.target,
|
||||
space = SpaceId(action.space)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -492,8 +504,7 @@ class EditorViewModel(
|
|||
downloadUnsplashImage(
|
||||
DownloadUnsplashImage.Params(
|
||||
picture = action.img,
|
||||
// TODO re-fact to use space id from arguments or target space id of this object
|
||||
space = SpaceId(spaceManager.get())
|
||||
space = SpaceId(space)
|
||||
)
|
||||
).process(
|
||||
failure = {
|
||||
|
@ -988,10 +999,11 @@ class EditorViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun onStart(id: Id, saveAsLastOpened: Boolean = true) {
|
||||
fun onStart(id: Id, space: Id, saveAsLastOpened: Boolean = true) {
|
||||
Timber.d("onStart, id:[$id]")
|
||||
|
||||
context = id
|
||||
this.context = id
|
||||
this.space = space
|
||||
|
||||
stateData.postValue(ViewState.Loading)
|
||||
|
||||
|
@ -1014,7 +1026,7 @@ class EditorViewModel(
|
|||
.build(InterceptThreadStatus.Params(context))
|
||||
.collect { status ->
|
||||
val statusView = status.toView(
|
||||
networkId = spaceManager.getConfig()?.network,
|
||||
networkId = spaceManager.getConfig(space = SpaceId(space))?.network,
|
||||
networkMode = networkMode
|
||||
)
|
||||
syncStatus.value = statusView
|
||||
|
@ -1035,7 +1047,7 @@ class EditorViewModel(
|
|||
val params = OpenPage.Params(
|
||||
obj = id,
|
||||
saveAsLastOpened = saveAsLastOpened,
|
||||
space = SpaceId(spaceManager.get())
|
||||
space = SpaceId(space)
|
||||
)
|
||||
openPage.async(params).fold(
|
||||
onSuccess = { result ->
|
||||
|
@ -1500,7 +1512,7 @@ class EditorViewModel(
|
|||
handleEndlineEnterPressedEventForListItem(content, id)
|
||||
} else {
|
||||
proceedWithCreatingNewTextBlock(
|
||||
id = id,
|
||||
target = id,
|
||||
style = Content.Text.Style.P
|
||||
)
|
||||
}
|
||||
|
@ -1702,7 +1714,7 @@ class EditorViewModel(
|
|||
}
|
||||
|
||||
private fun proceedWithCreatingNewTextBlock(
|
||||
id: String,
|
||||
target: String,
|
||||
style: Content.Text.Style,
|
||||
position: Position = Position.BOTTOM
|
||||
) {
|
||||
|
@ -1710,7 +1722,7 @@ class EditorViewModel(
|
|||
orchestrator.proxies.intents.send(
|
||||
Intent.CRUD.Create(
|
||||
context = context,
|
||||
target = id,
|
||||
target = target,
|
||||
position = position,
|
||||
prototype = Prototype.Text(style = style)
|
||||
)
|
||||
|
@ -2261,7 +2273,7 @@ class EditorViewModel(
|
|||
}
|
||||
} else {
|
||||
proceedWithCreatingNewTextBlock(
|
||||
id = target.id,
|
||||
target = target.id,
|
||||
style = style,
|
||||
position = Position.BOTTOM
|
||||
)
|
||||
|
@ -3121,7 +3133,19 @@ class EditorViewModel(
|
|||
|
||||
private fun proceedWithOpeningDataViewBlock(dv: Content.DataView) {
|
||||
if (dv.targetObjectId.isNotEmpty()) {
|
||||
proceedWithOpeningDataViewObject(dv.targetObjectId)
|
||||
val targetSpace = orchestrator.stores.details.current().let { details ->
|
||||
val detail = details.details[dv.targetObjectId]
|
||||
if (detail != null && detail.map.isNotEmpty()) {
|
||||
val wrapper = ObjectWrapper.Basic(detail.map)
|
||||
wrapper.spaceId ?: space
|
||||
} else {
|
||||
space
|
||||
}
|
||||
}
|
||||
proceedWithOpeningDataViewObject(
|
||||
target = dv.targetObjectId,
|
||||
space = SpaceId(targetSpace)
|
||||
)
|
||||
viewModelScope.sendAnalyticsOpenAsObject(
|
||||
analytics = analytics,
|
||||
type = EventsDictionary.Type.dataView
|
||||
|
@ -3160,7 +3184,13 @@ class EditorViewModel(
|
|||
}
|
||||
}
|
||||
ObjectType.Layout.SET, ObjectType.Layout.COLLECTION -> {
|
||||
proceedWithOpeningDataViewObject(target = target)
|
||||
val space = wrapper.spaceId
|
||||
if (space != null) {
|
||||
proceedWithOpeningDataViewObject(
|
||||
target = target,
|
||||
space = SpaceId(checkNotNull(wrapper.spaceId))
|
||||
)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
sendToast("Cannot open object with layout: ${wrapper.layout}")
|
||||
|
@ -3209,7 +3239,7 @@ class EditorViewModel(
|
|||
typeId = TypeId(objectTypeView.id),
|
||||
typeKey = TypeKey(objectTypeView.key),
|
||||
template = objectTypeView.defaultTemplate,
|
||||
space = spaceManager.get()
|
||||
space = space
|
||||
)
|
||||
createBlockLinkWithObject.async(
|
||||
params = params
|
||||
|
@ -4025,7 +4055,7 @@ class EditorViewModel(
|
|||
type = relation.type,
|
||||
filters = ObjectSearchConstants.setsByObjectTypeFilters(
|
||||
types = listOf(relation.type),
|
||||
space = spaceManager.get()
|
||||
space = space
|
||||
)
|
||||
)
|
||||
findObjectSetForType(params).process(
|
||||
|
@ -4041,7 +4071,12 @@ class EditorViewModel(
|
|||
Command.OpenObjectTypeMenu(listOf(ObjectTypeMenuItem.ChangeType))
|
||||
|
||||
is FindObjectSetForType.Response.Success ->
|
||||
Command.OpenObjectTypeMenu(clicked.items(set = response.obj.id))
|
||||
Command.OpenObjectTypeMenu(
|
||||
clicked.items(
|
||||
set = response.obj.id,
|
||||
space = requireNotNull(response.obj.spaceId)
|
||||
)
|
||||
)
|
||||
}
|
||||
commands.postValue(EventWrapper(command))
|
||||
}
|
||||
|
@ -4235,7 +4270,7 @@ class EditorViewModel(
|
|||
|
||||
private fun addNewBlockAtTheEnd() {
|
||||
proceedWithCreatingNewTextBlock(
|
||||
id = "",
|
||||
target = "",
|
||||
position = Position.INNER,
|
||||
style = Content.Text.Style.P
|
||||
)
|
||||
|
@ -4246,10 +4281,14 @@ class EditorViewModel(
|
|||
closePage.async(context).fold(
|
||||
onFailure = {
|
||||
Timber.e(it, "Error while closing object")
|
||||
navigate(EventWrapper(AppNavigation.Command.OpenObject(target)))
|
||||
navigate(EventWrapper(
|
||||
AppNavigation.Command.OpenObject(target = target, space = space))
|
||||
)
|
||||
},
|
||||
onSuccess = {
|
||||
navigate(EventWrapper(AppNavigation.Command.OpenObject(target)))
|
||||
navigate(EventWrapper(
|
||||
AppNavigation.Command.OpenObject(target = target, space = space))
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -4270,10 +4309,24 @@ class EditorViewModel(
|
|||
private fun proceedWithOpeningObject(obj: ObjectWrapper.Basic) {
|
||||
when (val navigation = obj.navigation()) {
|
||||
is OpenObjectNavigation.OpenDataView -> {
|
||||
navigate(EventWrapper(AppNavigation.Command.OpenSetOrCollection(navigation.target)))
|
||||
navigate(
|
||||
EventWrapper(
|
||||
AppNavigation.Command.OpenSetOrCollection(
|
||||
target = navigation.target,
|
||||
space = navigation.space
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
is OpenObjectNavigation.OpenEditor -> {
|
||||
navigate(EventWrapper(AppNavigation.Command.OpenObject(navigation.target)))
|
||||
navigate(
|
||||
EventWrapper(
|
||||
AppNavigation.Command.OpenObject(
|
||||
target = navigation.target,
|
||||
space = navigation.space
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
is OpenObjectNavigation.UnexpectedLayoutError -> {
|
||||
sendToast("Unexpected layout: ${navigation.layout}")
|
||||
|
@ -4281,7 +4334,11 @@ class EditorViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun proceedWithOpeningDataViewObject(target: Id, isPopUpToDashboard: Boolean = false) {
|
||||
fun proceedWithOpeningDataViewObject(
|
||||
target: Id,
|
||||
space: SpaceId,
|
||||
isPopUpToDashboard: Boolean = false
|
||||
) {
|
||||
viewModelScope.launch {
|
||||
closePage.async(context).fold(
|
||||
onFailure = {
|
||||
|
@ -4289,7 +4346,8 @@ class EditorViewModel(
|
|||
navigate(
|
||||
EventWrapper(
|
||||
AppNavigation.Command.OpenSetOrCollection(
|
||||
target,
|
||||
target = target,
|
||||
space = space.id,
|
||||
isPopUpToDashboard
|
||||
)
|
||||
)
|
||||
|
@ -4299,7 +4357,8 @@ class EditorViewModel(
|
|||
navigate(
|
||||
EventWrapper(
|
||||
AppNavigation.Command.OpenSetOrCollection(
|
||||
target,
|
||||
target = target,
|
||||
space = space.id,
|
||||
isPopUpToDashboard
|
||||
)
|
||||
)
|
||||
|
@ -4453,7 +4512,11 @@ class EditorViewModel(
|
|||
objectToSet.async(params).fold(
|
||||
onFailure = { error -> Timber.e(error, "Error convert object to set") },
|
||||
onSuccess = {
|
||||
proceedWithOpeningDataViewObject(target = context, isPopUpToDashboard = true)
|
||||
proceedWithOpeningDataViewObject(
|
||||
target = context,
|
||||
space = SpaceId(space),
|
||||
isPopUpToDashboard = true
|
||||
)
|
||||
viewModelScope.sendAnalyticsObjectTypeSelectOrChangeEvent(
|
||||
analytics = analytics,
|
||||
startTime = startTime,
|
||||
|
@ -4471,7 +4534,11 @@ class EditorViewModel(
|
|||
objectToCollection.async(params).fold(
|
||||
onFailure = { error -> Timber.e(error, "Error convert object to collection") },
|
||||
onSuccess = {
|
||||
proceedWithOpeningDataViewObject(target = context, isPopUpToDashboard = true)
|
||||
proceedWithOpeningDataViewObject(
|
||||
target = context,
|
||||
space = SpaceId(space),
|
||||
isPopUpToDashboard = true
|
||||
)
|
||||
viewModelScope.sendAnalyticsObjectTypeSelectOrChangeEvent(
|
||||
analytics = analytics,
|
||||
startTime = startTime,
|
||||
|
@ -4964,7 +5031,7 @@ class EditorViewModel(
|
|||
sorts = sorts,
|
||||
filters = ObjectSearchConstants.filterTypes(
|
||||
spaces = buildList {
|
||||
add(spaceManager.get())
|
||||
add(space)
|
||||
},
|
||||
recommendedLayouts = SupportedLayouts.editorLayouts
|
||||
),
|
||||
|
@ -5347,6 +5414,7 @@ class EditorViewModel(
|
|||
|
||||
fun proceedWithMoveToAction(
|
||||
target: Id,
|
||||
space: Id,
|
||||
text: String,
|
||||
icon: ObjectIcon,
|
||||
blocks: List<Id>,
|
||||
|
@ -5373,6 +5441,7 @@ class EditorViewModel(
|
|||
dispatch(
|
||||
Command.OpenObjectSnackbar(
|
||||
id = target,
|
||||
space = space,
|
||||
fromText = "${blocks.size} block${if (blocks.size > 1) "s" else ""} ",
|
||||
toText = text,
|
||||
icon = icon,
|
||||
|
@ -5527,7 +5596,7 @@ class EditorViewModel(
|
|||
val page = blocks.first { it.id == context }
|
||||
val next = page.children.getOrElse(0) { "" }
|
||||
proceedWithCreatingNewTextBlock(
|
||||
id = next,
|
||||
target = next,
|
||||
style = Content.Text.Style.P,
|
||||
position = Position.TOP
|
||||
)
|
||||
|
@ -5652,7 +5721,7 @@ class EditorViewModel(
|
|||
val target = currentSelection().first()
|
||||
clearSelections()
|
||||
proceedWithCreatingNewTextBlock(
|
||||
id = target,
|
||||
target = target,
|
||||
style = Content.Text.Style.P
|
||||
)
|
||||
}
|
||||
|
@ -5951,7 +6020,11 @@ class EditorViewModel(
|
|||
limit = ObjectSearchViewModel.SEARCH_LIMIT,
|
||||
filters = ObjectSearchConstants.getFilterLinkTo(
|
||||
ignore = context,
|
||||
spaces = spaceManager.getSpaceWithTechSpace(),
|
||||
spaces = buildList {
|
||||
add(space)
|
||||
val config = spaceManager.getConfig(SpaceId(space))
|
||||
if (config != null) add(config.techSpace)
|
||||
},
|
||||
),
|
||||
sorts = ObjectSearchConstants.sortLinkTo,
|
||||
fulltext = fullText,
|
||||
|
@ -6061,7 +6134,7 @@ class EditorViewModel(
|
|||
sorts = emptyList(),
|
||||
filters = ObjectSearchConstants.filterTypes(
|
||||
spaces = buildList {
|
||||
add(spaceManager.get())
|
||||
add(space)
|
||||
},
|
||||
recommendedLayouts = SupportedLayouts.createObjectLayouts
|
||||
),
|
||||
|
@ -6168,11 +6241,16 @@ class EditorViewModel(
|
|||
createObjectSet(
|
||||
CreateObjectSet.Params(
|
||||
type = type,
|
||||
space = spaceManager.get()
|
||||
space = space
|
||||
)
|
||||
).process(
|
||||
failure = { Timber.e(it, "Error while creating a set of type: $type") },
|
||||
success = { response -> proceedWithOpeningDataViewObject(response.target) }
|
||||
success = { response ->
|
||||
proceedWithOpeningDataViewObject(
|
||||
target = response.target,
|
||||
space = SpaceId(space)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ sealed class Command {
|
|||
|
||||
data class OpenObjectSnackbar(
|
||||
val id: Id,
|
||||
val space: Id,
|
||||
val fromText: String,
|
||||
val toText: String,
|
||||
val icon: ObjectIcon,
|
||||
|
|
|
@ -5,11 +5,14 @@ import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType
|
|||
|
||||
sealed class ObjectTypeMenuItem {
|
||||
object ChangeType: ObjectTypeMenuItem()
|
||||
data class OpenSet(val set: Id, val typeName: String) : ObjectTypeMenuItem()
|
||||
data class OpenSet(val set: Id, val space: Id, val typeName: String) : ObjectTypeMenuItem()
|
||||
data class CreateSet(val type: Id, val typeName: String) : ObjectTypeMenuItem()
|
||||
}
|
||||
|
||||
fun ListenerType.Relation.ObjectType.items(set: Id? = null): List<ObjectTypeMenuItem> {
|
||||
fun ListenerType.Relation.ObjectType.items(
|
||||
set: Id? = null,
|
||||
space: Id
|
||||
): List<ObjectTypeMenuItem> {
|
||||
val relation = this
|
||||
return if (set.isNullOrBlank()) {
|
||||
listOf(
|
||||
|
@ -24,6 +27,7 @@ fun ListenerType.Relation.ObjectType.items(set: Id? = null): List<ObjectTypeMenu
|
|||
ObjectTypeMenuItem.ChangeType,
|
||||
ObjectTypeMenuItem.OpenSet(
|
||||
set = set,
|
||||
space = space,
|
||||
typeName = relation.relation.name
|
||||
)
|
||||
)
|
||||
|
|
|
@ -757,7 +757,14 @@ class HomeScreenViewModel(
|
|||
bundled = source
|
||||
)
|
||||
// TODO switch to bundled widgets id
|
||||
navigate(Navigation.ExpandWidget(Subscription.Favorites))
|
||||
viewModelScope.launch {
|
||||
navigation(
|
||||
Navigation.ExpandWidget(
|
||||
subscription = Subscription.Favorites,
|
||||
space = spaceManager.get()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
is Widget.Source.Bundled.Sets -> {
|
||||
viewModelScope.sendSelectHomeTabEvent(
|
||||
|
@ -765,7 +772,14 @@ class HomeScreenViewModel(
|
|||
bundled = source
|
||||
)
|
||||
// TODO switch to bundled widgets id
|
||||
navigate(Navigation.ExpandWidget(Subscription.Sets))
|
||||
viewModelScope.launch {
|
||||
navigation(
|
||||
Navigation.ExpandWidget(
|
||||
subscription = Subscription.Sets,
|
||||
space = spaceManager.get()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
is Widget.Source.Bundled.Recent -> {
|
||||
|
@ -774,7 +788,14 @@ class HomeScreenViewModel(
|
|||
bundled = source
|
||||
)
|
||||
// TODO switch to bundled widgets id
|
||||
navigate(Navigation.ExpandWidget(Subscription.Recent))
|
||||
viewModelScope.launch {
|
||||
navigation(
|
||||
Navigation.ExpandWidget(
|
||||
subscription = Subscription.Recent,
|
||||
space = spaceManager.get()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
is Widget.Source.Bundled.RecentLocal -> {
|
||||
|
@ -783,7 +804,14 @@ class HomeScreenViewModel(
|
|||
bundled = source
|
||||
)
|
||||
// TODO switch to bundled widgets id
|
||||
navigate(Navigation.ExpandWidget(Subscription.RecentLocal))
|
||||
viewModelScope.launch {
|
||||
navigation(
|
||||
Navigation.ExpandWidget(
|
||||
subscription = Subscription.RecentLocal,
|
||||
space = spaceManager.get()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
is Widget.Source.Bundled.Collections -> {
|
||||
|
@ -792,7 +820,14 @@ class HomeScreenViewModel(
|
|||
bundled = source
|
||||
)
|
||||
// TODO switch to bundled widgets id
|
||||
navigate(Navigation.ExpandWidget(Subscription.Collections))
|
||||
viewModelScope.launch {
|
||||
navigation(
|
||||
Navigation.ExpandWidget(
|
||||
subscription = Subscription.Collections,
|
||||
space = spaceManager.get()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
is Widget.Source.Default -> {
|
||||
|
@ -830,18 +865,42 @@ class HomeScreenViewModel(
|
|||
}
|
||||
|
||||
fun onBundledWidgetClicked(widget: Id) {
|
||||
when (widget) {
|
||||
Subscriptions.SUBSCRIPTION_SETS -> {
|
||||
navigate(Navigation.ExpandWidget(Subscription.Sets))
|
||||
}
|
||||
Subscriptions.SUBSCRIPTION_RECENT -> {
|
||||
navigate(Navigation.ExpandWidget(Subscription.Recent))
|
||||
}
|
||||
Subscriptions.SUBSCRIPTION_ARCHIVED -> {
|
||||
navigate(Navigation.ExpandWidget(Subscription.Bin))
|
||||
}
|
||||
Subscriptions.SUBSCRIPTION_FAVORITES -> {
|
||||
navigate(Navigation.ExpandWidget(Subscription.Favorites))
|
||||
viewModelScope.launch {
|
||||
// TODO DROID-2341 get space from widget views for better consistency
|
||||
val space = spaceManager.get()
|
||||
when (widget) {
|
||||
Subscriptions.SUBSCRIPTION_SETS -> {
|
||||
navigation(
|
||||
Navigation.ExpandWidget(
|
||||
subscription = Subscription.Sets,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
}
|
||||
Subscriptions.SUBSCRIPTION_RECENT -> {
|
||||
navigation(
|
||||
Navigation.ExpandWidget(
|
||||
subscription = Subscription.Recent,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
}
|
||||
Subscriptions.SUBSCRIPTION_ARCHIVED -> {
|
||||
navigation(
|
||||
Navigation.ExpandWidget(
|
||||
subscription = Subscription.Bin,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
}
|
||||
Subscriptions.SUBSCRIPTION_FAVORITES -> {
|
||||
navigation(
|
||||
Navigation.ExpandWidget(
|
||||
subscription = Subscription.Favorites,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1103,10 +1162,20 @@ class HomeScreenViewModel(
|
|||
private fun proceedWithOpeningObject(obj: ObjectWrapper.Basic) {
|
||||
when(val navigation = obj.navigation()) {
|
||||
is OpenObjectNavigation.OpenDataView -> {
|
||||
navigate(Navigation.OpenSet(navigation.target))
|
||||
navigate(
|
||||
Navigation.OpenSet(
|
||||
ctx = navigation.target,
|
||||
space = navigation.target
|
||||
)
|
||||
)
|
||||
}
|
||||
is OpenObjectNavigation.OpenEditor -> {
|
||||
navigate(Navigation.OpenObject(navigation.target))
|
||||
navigate(
|
||||
Navigation.OpenObject(
|
||||
ctx = navigation.target,
|
||||
space = navigation.space
|
||||
)
|
||||
)
|
||||
}
|
||||
is OpenObjectNavigation.UnexpectedLayoutError -> {
|
||||
sendToast("Unexpected layout: ${navigation.layout}")
|
||||
|
@ -1149,6 +1218,15 @@ class HomeScreenViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun onCreateNewObjectLongClicked() {
|
||||
viewModelScope.launch {
|
||||
val space = spaceManager.get()
|
||||
if (space.isNotEmpty()) {
|
||||
commands.emit(Command.OpenObjectCreateDialog(SpaceId(space)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onMove(views: List<WidgetView>, from: Int, to: Int) {
|
||||
viewModelScope.launch {
|
||||
val config = spaceManager.getConfig()
|
||||
|
@ -1421,10 +1499,20 @@ class HomeScreenViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun onLibraryClicked() {
|
||||
viewModelScope.launch {
|
||||
val space = spaceManager.get()
|
||||
navigation(
|
||||
Navigation.OpenLibrary(space)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
sealed class Navigation {
|
||||
data class OpenObject(val ctx: Id) : Navigation()
|
||||
data class OpenSet(val ctx: Id) : Navigation()
|
||||
data class ExpandWidget(val subscription: Subscription) : Navigation()
|
||||
data class OpenObject(val ctx: Id, val space: Id) : Navigation()
|
||||
data class OpenSet(val ctx: Id, val space: Id) : Navigation()
|
||||
data class ExpandWidget(val subscription: Subscription, val space: Id) : Navigation()
|
||||
data class OpenLibrary(val space: Id) : Navigation()
|
||||
}
|
||||
|
||||
class Factory @Inject constructor(
|
||||
|
@ -1541,6 +1629,8 @@ sealed class Command {
|
|||
|
||||
data class OpenSpaceSettings(val spaceId: SpaceId) : Command()
|
||||
|
||||
data class OpenObjectCreateDialog(val space: SpaceId) : Command()
|
||||
|
||||
data class SelectWidgetType(
|
||||
val ctx: Id,
|
||||
val source: Id,
|
||||
|
@ -1598,8 +1688,8 @@ typealias Widgets = List<Widget>?
|
|||
typealias Containers = List<WidgetContainer>?
|
||||
|
||||
sealed class OpenObjectNavigation {
|
||||
data class OpenEditor(val target: Id) : OpenObjectNavigation()
|
||||
data class OpenDataView(val target: Id): OpenObjectNavigation()
|
||||
data class OpenEditor(val target: Id, val space: Id) : OpenObjectNavigation()
|
||||
data class OpenDataView(val target: Id, val space: Id): OpenObjectNavigation()
|
||||
data class UnexpectedLayoutError(val layout: ObjectType.Layout?): OpenObjectNavigation()
|
||||
}
|
||||
|
||||
|
@ -1610,22 +1700,37 @@ fun ObjectWrapper.Basic.navigation() : OpenObjectNavigation {
|
|||
ObjectType.Layout.TODO,
|
||||
ObjectType.Layout.BOOKMARK,
|
||||
ObjectType.Layout.PARTICIPANT -> {
|
||||
OpenObjectNavigation.OpenEditor(id)
|
||||
OpenObjectNavigation.OpenEditor(
|
||||
target = id,
|
||||
space = requireNotNull(spaceId)
|
||||
)
|
||||
}
|
||||
in SupportedLayouts.fileLayouts -> {
|
||||
OpenObjectNavigation.OpenEditor(id)
|
||||
OpenObjectNavigation.OpenEditor(
|
||||
target = id,
|
||||
space = requireNotNull(spaceId)
|
||||
)
|
||||
}
|
||||
ObjectType.Layout.PROFILE -> {
|
||||
val identityLink = getValue<Id>(Relations.IDENTITY_PROFILE_LINK)
|
||||
if (identityLink.isNullOrEmpty()) {
|
||||
OpenObjectNavigation.OpenEditor(id)
|
||||
OpenObjectNavigation.OpenEditor(
|
||||
target = id,
|
||||
space = requireNotNull(spaceId)
|
||||
)
|
||||
} else {
|
||||
OpenObjectNavigation.OpenEditor(identityLink)
|
||||
OpenObjectNavigation.OpenEditor(
|
||||
target = identityLink,
|
||||
space = requireNotNull(spaceId)
|
||||
)
|
||||
}
|
||||
}
|
||||
ObjectType.Layout.SET,
|
||||
ObjectType.Layout.COLLECTION -> {
|
||||
OpenObjectNavigation.OpenDataView(id)
|
||||
OpenObjectNavigation.OpenDataView(
|
||||
target = id,
|
||||
space = requireNotNull(spaceId)
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
OpenObjectNavigation.UnexpectedLayoutError(layout)
|
||||
|
|
|
@ -11,10 +11,9 @@ import com.anytypeio.anytype.analytics.base.EventsDictionary.libraryView
|
|||
import com.anytypeio.anytype.analytics.base.sendEvent
|
||||
import com.anytypeio.anytype.analytics.props.Props
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Key
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.primitives.TypeKey
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.core_utils.ext.allUniqueBy
|
||||
import com.anytypeio.anytype.core_utils.ext.orNull
|
||||
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
||||
|
@ -58,6 +57,7 @@ import kotlinx.coroutines.launch
|
|||
import timber.log.Timber
|
||||
|
||||
class LibraryViewModel(
|
||||
private val params: Params,
|
||||
private val myTypesDelegate: MyTypesDelegate,
|
||||
private val libraryTypesDelegate: LibraryTypesDelegate,
|
||||
private val myRelationsDelegate: MyRelationsDelegate,
|
||||
|
@ -482,6 +482,7 @@ class LibraryViewModel(
|
|||
}
|
||||
|
||||
class Factory @Inject constructor(
|
||||
private val params: Params,
|
||||
private val myTypesDelegate: MyTypesDelegate,
|
||||
private val libraryTypesDelegate: LibraryTypesDelegate,
|
||||
private val myRelationsDelegate: MyRelationsDelegate,
|
||||
|
@ -501,17 +502,18 @@ class LibraryViewModel(
|
|||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
return LibraryViewModel(
|
||||
myTypesDelegate,
|
||||
libraryTypesDelegate,
|
||||
myRelationsDelegate,
|
||||
libraryRelationsDelegate,
|
||||
addObjectToWorkspace,
|
||||
removeObjectsFromWorkspace,
|
||||
resourceManager,
|
||||
setObjectDetails,
|
||||
createObject,
|
||||
analytics,
|
||||
spaceManager,
|
||||
params = params,
|
||||
myTypesDelegate = myTypesDelegate,
|
||||
libraryTypesDelegate = libraryTypesDelegate,
|
||||
myRelationsDelegate = myRelationsDelegate,
|
||||
libraryRelationsDelegate = libraryRelationsDelegate,
|
||||
addObjectToWorkspace = addObjectToWorkspace,
|
||||
removeObjectsFromWorkspace = removeObjectsFromWorkspace,
|
||||
resourceManager = resourceManager,
|
||||
setObjectDetails = setObjectDetails,
|
||||
createObject = createObject,
|
||||
analytics = analytics,
|
||||
spaceManager = spaceManager,
|
||||
storelessSubscriptionContainer = storelessSubscriptionContainer,
|
||||
appCoroutineDispatchers = appCoroutineDispatchers,
|
||||
urlBuilder = urlBuilder,
|
||||
|
@ -520,6 +522,8 @@ class LibraryViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
class Params(val space: SpaceId)
|
||||
|
||||
sealed class Navigation {
|
||||
class OpenTypeCreation(
|
||||
val name: String = ""
|
||||
|
|
|
@ -10,8 +10,12 @@ interface AppNavigation {
|
|||
|
||||
fun openSpaceSettings()
|
||||
|
||||
fun openObjectSet(target: String, isPopUpToDashboard: Boolean = false)
|
||||
fun openDocument(id: String)
|
||||
fun openObjectSet(
|
||||
target: Id,
|
||||
space: Id,
|
||||
isPopUpToDashboard: Boolean = false
|
||||
)
|
||||
fun openDocument(target: Id, space: Id)
|
||||
fun openModalTemplateSelect(
|
||||
template: Id,
|
||||
templateTypeId: Id,
|
||||
|
@ -23,11 +27,9 @@ interface AppNavigation {
|
|||
templateTypeKey: Key
|
||||
)
|
||||
|
||||
fun launchDocument(id: String)
|
||||
fun launchCollections(subscription: Subscription)
|
||||
fun launchObjectFromSplash(id: Id)
|
||||
fun launchObjectSetFromSplash(id: Id)
|
||||
fun launchObjectSet(id: Id)
|
||||
fun launchDocument(target: String, space: Id)
|
||||
fun launchCollections(subscription: Subscription, space: Id)
|
||||
fun launchObjectSet(target: Id, space: Id)
|
||||
|
||||
fun openKeychainScreen()
|
||||
fun openUserSettingsScreen()
|
||||
|
@ -42,7 +44,7 @@ interface AppNavigation {
|
|||
|
||||
fun deletedAccountScreen(deadline: Long)
|
||||
|
||||
fun openLibrary()
|
||||
fun openLibrary(space: Id)
|
||||
|
||||
fun logout()
|
||||
|
||||
|
@ -57,11 +59,8 @@ interface AppNavigation {
|
|||
|
||||
object ExitFromMigrationScreen : Command()
|
||||
|
||||
data class OpenObject(val id: String) : Command()
|
||||
|
||||
data class LaunchDocument(val id: String) : Command()
|
||||
data class LaunchObjectFromSplash(val target: Id) : Command()
|
||||
data class LaunchObjectSetFromSplash(val target: Id) : Command()
|
||||
data class OpenObject(val target: Id, val space: Id) : Command()
|
||||
data class LaunchDocument(val target: Id, val space: Id) : Command()
|
||||
data class OpenModalTemplateSelect(
|
||||
val template: Id,
|
||||
val templateTypeId: Id,
|
||||
|
@ -76,10 +75,13 @@ interface AppNavigation {
|
|||
data class ExitToDesktopAndOpenPage(val pageId: String) : Command()
|
||||
object OpenPageSearch : Command()
|
||||
|
||||
data class OpenSetOrCollection(val target: String, val isPopUpToDashboard: Boolean = false) :
|
||||
Command()
|
||||
data class OpenSetOrCollection(
|
||||
val target: Id,
|
||||
val space: Id,
|
||||
val isPopUpToDashboard: Boolean = false
|
||||
) : Command()
|
||||
|
||||
data class LaunchObjectSet(val target: Id) : Command()
|
||||
data class LaunchObjectSet(val target: Id, val space: Id) : Command()
|
||||
|
||||
object OpenUpdateAppScreen : Command()
|
||||
|
||||
|
@ -87,7 +89,7 @@ interface AppNavigation {
|
|||
|
||||
data class OpenTemplates(val typeId: Id) : Command()
|
||||
|
||||
object OpenLibrary: Command()
|
||||
data class OpenLibrary(val space: Id): Command()
|
||||
|
||||
data class OpenRemoteFilesManageScreen(val subscription: Id) : Command()
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ interface DefaultSearchItem
|
|||
|
||||
data class DefaultObjectView(
|
||||
val id: Id,
|
||||
val space: Id,
|
||||
val name: String,
|
||||
val type: String? = null,
|
||||
val typeName: String? = null,
|
||||
|
|
|
@ -23,4 +23,7 @@ open class NavigationViewModel<Navigation> : BaseViewModel() {
|
|||
fun navigate(destination: Navigation) = viewModelScope.launch {
|
||||
_navigation.emit(destination)
|
||||
}
|
||||
suspend fun navigation(destination: Navigation) {
|
||||
_navigation.emit(destination)
|
||||
}
|
||||
}
|
|
@ -8,13 +8,13 @@ import com.anytypeio.anytype.core_models.ObjectTypeUniqueKeys
|
|||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.Relations.SOURCE_OBJECT
|
||||
import com.anytypeio.anytype.core_models.ext.DateParser
|
||||
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
|
||||
import com.anytypeio.anytype.core_utils.ext.readableFileSize
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.presentation.library.LibraryView
|
||||
import com.anytypeio.anytype.presentation.linking.LinkToItemView
|
||||
import com.anytypeio.anytype.presentation.navigation.DefaultObjectView
|
||||
import com.anytypeio.anytype.core_models.ext.DateParser
|
||||
import com.anytypeio.anytype.presentation.relations.RelationValueView
|
||||
import com.anytypeio.anytype.presentation.sets.filter.CreateFilterView
|
||||
import com.anytypeio.anytype.presentation.spaces.SpaceGradientProvider
|
||||
|
@ -43,7 +43,8 @@ fun List<ObjectWrapper.Basic>.toView(
|
|||
obj = obj,
|
||||
layout = layout,
|
||||
builder = urlBuilder
|
||||
)
|
||||
),
|
||||
space = requireNotNull(obj.spaceId)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -85,7 +86,8 @@ fun ObjectWrapper.Basic.toView(
|
|||
),
|
||||
lastModifiedDate = DateParser.parseInMillis(obj.lastModifiedDate) ?: 0L,
|
||||
lastOpenedDate = DateParser.parseInMillis(obj.lastOpenedDate) ?: 0L,
|
||||
isFavorite = obj.isFavorite ?: false
|
||||
isFavorite = obj.isFavorite ?: false,
|
||||
space = requireNotNull(obj.spaceId)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -234,6 +236,7 @@ fun List<ObjectWrapper.Basic>.toRelationObjectValueView(
|
|||
if (obj.isDeleted == null || obj.isDeleted == false) {
|
||||
RelationValueView.Object.Default(
|
||||
id = obj.id,
|
||||
space = requireNotNull(obj.spaceId),
|
||||
name = obj.getProperName(),
|
||||
typeName = getProperTypeName(
|
||||
id = typeUrl,
|
||||
|
@ -253,6 +256,7 @@ fun List<ObjectWrapper.Basic>.toRelationObjectValueView(
|
|||
} else {
|
||||
RelationValueView.Object.NonExistent(
|
||||
id = obj.id,
|
||||
space = requireNotNull(obj.spaceId),
|
||||
isSelected = false,
|
||||
removable = false
|
||||
)
|
||||
|
@ -271,6 +275,7 @@ fun List<ObjectWrapper.Basic>.toRelationFileValueView(
|
|||
if (obj.id !in ids) {
|
||||
RelationValueView.File(
|
||||
id = obj.id,
|
||||
space = requireNotNull(obj.spaceId),
|
||||
name = obj.getProperName(),
|
||||
ext = obj.getProperFileExt(),
|
||||
mime = obj.getProperFileMime(),
|
||||
|
@ -308,7 +313,8 @@ fun ObjectWrapper.Basic.mapFileObjectToView(): CollectionView.ObjectView {
|
|||
name = getProperName(),
|
||||
description = sizeInBytes?.toLong()?.readableFileSize().orEmpty(),
|
||||
layout = layout,
|
||||
icon = fileIcon
|
||||
icon = fileIcon,
|
||||
space = requireNotNull(spaceId)
|
||||
)
|
||||
return CollectionView.ObjectView(defaultObjectView)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import com.anytypeio.anytype.core_models.EMPTY_QUERY
|
|||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Key
|
||||
import com.anytypeio.anytype.core_models.Marketplace
|
||||
import com.anytypeio.anytype.core_models.Name
|
||||
import com.anytypeio.anytype.core_models.ObjectOrigin
|
||||
import com.anytypeio.anytype.core_models.ObjectTypeUniqueKeys
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
|
@ -72,28 +71,24 @@ class SelectObjectTypeViewModel(
|
|||
|
||||
private val query = MutableSharedFlow<String>()
|
||||
|
||||
lateinit var space: Id
|
||||
|
||||
private val defaultObjectTypePipeline = MutableSharedFlow<TypeKey>(1)
|
||||
|
||||
private val pinned = MutableStateFlow<List<TypeId>>(emptyList())
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
space = spaceManager.get()
|
||||
getPinnedObjectTypes.flow(
|
||||
GetPinnedObjectTypes.Params(SpaceId(space))
|
||||
GetPinnedObjectTypes.Params(params.space)
|
||||
).collect { pinned.value = it }
|
||||
}
|
||||
viewModelScope.launch {
|
||||
space = spaceManager.get()
|
||||
query.onStart { emit(EMPTY_QUERY) }.flatMapLatest { query ->
|
||||
val types = getObjectTypes.stream(
|
||||
GetObjectTypes.Params(
|
||||
sorts = ObjectSearchConstants.defaultObjectTypeSearchSorts(),
|
||||
filters = ObjectSearchConstants.filterTypes(
|
||||
spaces = buildList {
|
||||
add(space)
|
||||
add(params.space.id)
|
||||
if (query.isNotEmpty()) {
|
||||
add(Marketplace.MARKETPLACE_SPACE_ID)
|
||||
}
|
||||
|
@ -123,7 +118,7 @@ class SelectObjectTypeViewModel(
|
|||
.sortedBy { obj -> pinnedObjectTypesIds.indexOf(obj.id) }
|
||||
|
||||
val (allUserTypes, allLibraryTypes) = allTypes.partition { type ->
|
||||
type.getValue<Id>(Relations.SPACE_ID) == space
|
||||
type.getValue<Id>(Relations.SPACE_ID) == params.space.id
|
||||
}
|
||||
val filteredLibraryTypes = allLibraryTypes.filter { type ->
|
||||
allUserTypes.none { it.uniqueKey == type.uniqueKey }
|
||||
|
@ -293,7 +288,7 @@ class SelectObjectTypeViewModel(
|
|||
viewModelScope.launch {
|
||||
setPinnedObjectTypes.async(
|
||||
SetPinnedObjectTypes.Params(
|
||||
space = SpaceId(id = space),
|
||||
space = params.space,
|
||||
types = pinned
|
||||
)
|
||||
).fold(
|
||||
|
@ -311,7 +306,7 @@ class SelectObjectTypeViewModel(
|
|||
viewModelScope.launch {
|
||||
setDefaultObjectType.async(
|
||||
SetDefaultObjectType.Params(
|
||||
space = SpaceId(space),
|
||||
space = params.space,
|
||||
type = TypeId(typeView.id)
|
||||
)
|
||||
).fold(
|
||||
|
@ -330,7 +325,7 @@ class SelectObjectTypeViewModel(
|
|||
if (typeView.isFromLibrary) {
|
||||
val params = AddObjectToSpace.Params(
|
||||
obj = typeView.id,
|
||||
space = space
|
||||
space = params.space.id
|
||||
)
|
||||
addObjectToSpace.async(params = params).fold(
|
||||
onSuccess = { result ->
|
||||
|
@ -385,7 +380,7 @@ class SelectObjectTypeViewModel(
|
|||
val startTime = System.currentTimeMillis()
|
||||
createBookmarkObject(
|
||||
CreateBookmarkObject.Params(
|
||||
space = space,
|
||||
space = params.space.id,
|
||||
url = url,
|
||||
details = mapOf(
|
||||
Relations.ORIGIN to ObjectOrigin.CLIPBOARD.code.toDouble()
|
||||
|
@ -400,7 +395,12 @@ class SelectObjectTypeViewModel(
|
|||
// route = EventsDictionary.Routes.sharingExtension,
|
||||
// startTime = startTime
|
||||
// )
|
||||
navigation.emit(OpenObjectNavigation.OpenEditor(obj))
|
||||
navigation.emit(
|
||||
OpenObjectNavigation.OpenEditor(
|
||||
target = obj,
|
||||
space = params.space.id
|
||||
)
|
||||
)
|
||||
},
|
||||
failure = {
|
||||
Timber.d(it, "Error while creating bookmark")
|
||||
|
@ -422,21 +422,26 @@ class SelectObjectTypeViewModel(
|
|||
createPrefilledNote.async(
|
||||
CreatePrefilledNote.Params(
|
||||
text = text,
|
||||
space = space,
|
||||
space = params.space.id,
|
||||
details = mapOf(
|
||||
Relations.ORIGIN to ObjectOrigin.CLIPBOARD.code.toDouble()
|
||||
),
|
||||
customType = defaultObjectType ?: TypeKey(ObjectTypeUniqueKeys.NOTE)
|
||||
)
|
||||
).fold(
|
||||
onSuccess = { result ->
|
||||
onSuccess = { obj ->
|
||||
sendAnalyticsObjectCreateEvent(
|
||||
analytics = analytics,
|
||||
objType = defaultObjectType?.key ?: ObjectTypeUniqueKeys.NOTE,
|
||||
route = EventsDictionary.Routes.sharingExtension,
|
||||
startTime = startTime
|
||||
)
|
||||
navigation.emit(OpenObjectNavigation.OpenEditor(result))
|
||||
navigation.emit(
|
||||
OpenObjectNavigation.OpenEditor(
|
||||
target = obj,
|
||||
space = params.space.id
|
||||
)
|
||||
)
|
||||
},
|
||||
onFailure = {
|
||||
Timber.d(it, "Error while creating note")
|
||||
|
@ -482,6 +487,7 @@ class SelectObjectTypeViewModel(
|
|||
}
|
||||
|
||||
data class Params(
|
||||
val space: SpaceId,
|
||||
val excludedTypeKeys: List<TypeKey>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ class ObjectMenuViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
override fun onIconClicked(ctx: Id) {
|
||||
override fun onIconClicked(ctx: Id, space: Id) {
|
||||
viewModelScope.launch {
|
||||
if (objectRestrictions.contains(ObjectRestriction.DETAILS)) {
|
||||
_toasts.emit(NOT_ALLOWED)
|
||||
|
@ -191,7 +191,7 @@ class ObjectMenuViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
override fun onCoverClicked(ctx: Id) {
|
||||
override fun onCoverClicked(ctx: Id, space: Id) {
|
||||
viewModelScope.launch {
|
||||
if (objectRestrictions.contains(ObjectRestriction.DETAILS)) {
|
||||
_toasts.emit(NOT_ALLOWED)
|
||||
|
@ -209,7 +209,7 @@ class ObjectMenuViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
override fun onLayoutClicked(ctx: Id) {
|
||||
override fun onLayoutClicked(ctx: Id, space: Id) {
|
||||
viewModelScope.launch {
|
||||
if (objectRestrictions.contains(ObjectRestriction.LAYOUT_CHANGE)) {
|
||||
_toasts.emit(NOT_ALLOWED)
|
||||
|
@ -237,13 +237,17 @@ class ObjectMenuViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
override fun onActionClicked(ctx: Id, action: ObjectAction) {
|
||||
override fun onActionClicked(ctx: Id, space: Id, action: ObjectAction) {
|
||||
when (action) {
|
||||
ObjectAction.DELETE -> {
|
||||
proceedWithUpdatingArchivedStatus(ctx = ctx, isArchived = true)
|
||||
}
|
||||
ObjectAction.DUPLICATE -> {
|
||||
proceedWithDuplication(ctx = ctx, details = storage.details.current().details)
|
||||
proceedWithDuplication(
|
||||
ctx = ctx,
|
||||
space = space,
|
||||
details = storage.details.current().details
|
||||
)
|
||||
}
|
||||
ObjectAction.RESTORE -> {
|
||||
proceedWithUpdatingArchivedStatus(ctx = ctx, isArchived = false)
|
||||
|
|
|
@ -78,9 +78,9 @@ abstract class ObjectMenuViewModelBase(
|
|||
)
|
||||
val options: Flow<ObjectMenuOptionsProvider.Options> = _options
|
||||
|
||||
abstract fun onIconClicked(ctx: Id)
|
||||
abstract fun onCoverClicked(ctx: Id)
|
||||
abstract fun onLayoutClicked(ctx: Id)
|
||||
abstract fun onIconClicked(ctx: Id, space: Id)
|
||||
abstract fun onCoverClicked(ctx: Id, space: Id)
|
||||
abstract fun onLayoutClicked(ctx: Id, space: Id)
|
||||
abstract fun onRelationsClicked()
|
||||
|
||||
fun onHistoryClicked() {
|
||||
|
@ -111,7 +111,7 @@ abstract class ObjectMenuViewModelBase(
|
|||
}
|
||||
}
|
||||
|
||||
abstract fun onActionClicked(ctx: Id, action: ObjectAction)
|
||||
abstract fun onActionClicked(ctx: Id, space: Id, action: ObjectAction)
|
||||
|
||||
abstract fun buildActions(
|
||||
ctx: Id,
|
||||
|
@ -188,6 +188,7 @@ abstract class ObjectMenuViewModelBase(
|
|||
|
||||
fun onBackLinkOrAddToObjectAction(
|
||||
ctx: Id,
|
||||
space: Id,
|
||||
backLinkId: Id,
|
||||
backLinkName: String,
|
||||
backLinkLayout: ObjectType.Layout?,
|
||||
|
@ -206,12 +207,16 @@ abstract class ObjectMenuViewModelBase(
|
|||
ObjectType.Layout.TODO,
|
||||
ObjectType.Layout.NOTE -> {
|
||||
onLinkedMyselfTo(
|
||||
myself = ctx, addTo = backLinkId, fromName = fromName
|
||||
myself = ctx,
|
||||
addTo = backLinkId,
|
||||
fromName = fromName,
|
||||
space = space
|
||||
)
|
||||
}
|
||||
ObjectType.Layout.COLLECTION -> {
|
||||
proceedWithAddObjectToCollection(
|
||||
ctx = ctx,
|
||||
space = space,
|
||||
collection = backLinkId,
|
||||
collectionName = backLinkName,
|
||||
collectionIcon = backLinkIcon,
|
||||
|
@ -224,6 +229,7 @@ abstract class ObjectMenuViewModelBase(
|
|||
|
||||
private fun proceedWithAddObjectToCollection(
|
||||
ctx: Id,
|
||||
space: Id,
|
||||
collection: Id,
|
||||
collectionName: String,
|
||||
collectionIcon: ObjectIcon,
|
||||
|
@ -249,7 +255,8 @@ abstract class ObjectMenuViewModelBase(
|
|||
currentObjectName = fromName,
|
||||
targetObjectName = collectionName,
|
||||
icon = collectionIcon,
|
||||
isCollection = true
|
||||
isCollection = true,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
},
|
||||
|
@ -258,7 +265,12 @@ abstract class ObjectMenuViewModelBase(
|
|||
}
|
||||
}
|
||||
|
||||
fun onLinkedMyselfTo(myself: Id, addTo: Id, fromName: String?) {
|
||||
fun onLinkedMyselfTo(
|
||||
myself: Id,
|
||||
addTo: Id,
|
||||
fromName: String?,
|
||||
space: Id
|
||||
) {
|
||||
Timber.d("onLinkedMyselfTo, myself:[$myself], addTo:[$addTo], fromName:[$fromName]")
|
||||
jobs += viewModelScope.launch {
|
||||
val startTime = System.currentTimeMillis()
|
||||
|
@ -267,8 +279,7 @@ abstract class ObjectMenuViewModelBase(
|
|||
objectToLink = myself,
|
||||
objectToPlaceLink = addTo,
|
||||
saveAsLastOpened = true,
|
||||
// TODO resolve space from screen args or from object details
|
||||
spaceId = SpaceId(spaceManager.get())
|
||||
spaceId = SpaceId(space)
|
||||
)
|
||||
).fold(
|
||||
onSuccess = { obj ->
|
||||
|
@ -281,7 +292,8 @@ abstract class ObjectMenuViewModelBase(
|
|||
id = addTo,
|
||||
currentObjectName = fromName,
|
||||
targetObjectName = obj.getProperName(),
|
||||
icon = ObjectIcon.from(obj, obj.layout, urlBuilder)
|
||||
icon = ObjectIcon.from(obj, obj.layout, urlBuilder),
|
||||
space = requireNotNull(obj.spaceId)
|
||||
)
|
||||
)
|
||||
},
|
||||
|
@ -296,21 +308,28 @@ abstract class ObjectMenuViewModelBase(
|
|||
jobs += viewModelScope.launch { commands.emit(Command.OpenLinkToChooser) }
|
||||
}
|
||||
|
||||
fun proceedWithOpeningPage(id: Id) {
|
||||
Timber.d("proceedWithOpeningPage, id:[$id]")
|
||||
fun proceedWithOpeningPage(target: Id, space: Id) {
|
||||
Timber.d("proceedWithOpeningPage, id:[$target]")
|
||||
viewModelScope.launch {
|
||||
delegator.delegate(Action.OpenObject(id))
|
||||
delegator.delegate(
|
||||
Action.OpenObject(target = target, space = space)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun proceedWithOpeningCollection(id: Id) {
|
||||
Timber.d("proceedWithOpeningCollection, id:[$id]")
|
||||
fun proceedWithOpeningCollection(target: Id, space: Id) {
|
||||
Timber.d("proceedWithOpeningCollection, id:[$target]")
|
||||
viewModelScope.launch {
|
||||
delegator.delegate(Action.OpenCollection(id))
|
||||
delegator.delegate(
|
||||
Action.OpenCollection(
|
||||
target = target,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun proceedWithDuplication(ctx: Id, details: Map<Id, Block.Fields>?) {
|
||||
fun proceedWithDuplication(ctx: Id, space: Id, details: Map<Id, Block.Fields>?) {
|
||||
Timber.d("proceedWithDuplication, ctx:[$ctx]")
|
||||
val startTime = System.currentTimeMillis()
|
||||
viewModelScope.launch {
|
||||
|
@ -319,9 +338,14 @@ abstract class ObjectMenuViewModelBase(
|
|||
Timber.e(it, "Duplication error")
|
||||
_toasts.emit(SOMETHING_WENT_WRONG_MSG)
|
||||
},
|
||||
success = {
|
||||
success = { id ->
|
||||
_toasts.emit("Your object is duplicated")
|
||||
delegator.delegate(Action.Duplicate(it))
|
||||
delegator.delegate(
|
||||
Action.Duplicate(
|
||||
target = id,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
sendAnalyticsDuplicateEvent(
|
||||
analytics = analytics,
|
||||
startTime = startTime,
|
||||
|
@ -406,6 +430,7 @@ abstract class ObjectMenuViewModelBase(
|
|||
data class ShareDebugGoroutines(val path: String) : Command()
|
||||
data class OpenSnackbar(
|
||||
val id: Id,
|
||||
val space: Id,
|
||||
val currentObjectName: String?,
|
||||
val targetObjectName: String?,
|
||||
val icon: ObjectIcon,
|
||||
|
|
|
@ -100,7 +100,7 @@ class ObjectSetMenuViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
override fun onIconClicked(ctx: Id) {
|
||||
override fun onIconClicked(ctx: Id, space: Id) {
|
||||
val dataViewState = objectState.value.dataViewState() ?: return
|
||||
viewModelScope.launch {
|
||||
if (dataViewState.objectRestrictions.contains(ObjectRestriction.DETAILS)) {
|
||||
|
@ -111,7 +111,7 @@ class ObjectSetMenuViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
override fun onCoverClicked(ctx: Id) {
|
||||
override fun onCoverClicked(ctx: Id, space: Id) {
|
||||
val dataViewState = objectState.value.dataViewState() ?: return
|
||||
viewModelScope.launch {
|
||||
if (dataViewState.objectRestrictions.contains(ObjectRestriction.DETAILS)) {
|
||||
|
@ -122,7 +122,7 @@ class ObjectSetMenuViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
override fun onLayoutClicked(ctx: Id) {
|
||||
override fun onLayoutClicked(ctx: Id, space: Id) {
|
||||
val dataViewState = objectState.value.dataViewState() ?: return
|
||||
viewModelScope.launch {
|
||||
if (dataViewState.objectRestrictions.contains(ObjectRestriction.LAYOUT_CHANGE)) {
|
||||
|
@ -168,7 +168,7 @@ class ObjectSetMenuViewModel(
|
|||
add(ObjectAction.LINK_TO)
|
||||
}
|
||||
|
||||
override fun onActionClicked(ctx: Id, action: ObjectAction) {
|
||||
override fun onActionClicked(ctx: Id, space: Id, action: ObjectAction) {
|
||||
when (action) {
|
||||
ObjectAction.DELETE -> {
|
||||
proceedWithUpdatingArchivedStatus(ctx = ctx, isArchived = true)
|
||||
|
@ -186,7 +186,11 @@ class ObjectSetMenuViewModel(
|
|||
proceedWithLinkTo()
|
||||
}
|
||||
ObjectAction.DUPLICATE -> {
|
||||
proceedWithDuplication(ctx = ctx, details = objectState.value.dataViewState()?.details)
|
||||
proceedWithDuplication(
|
||||
ctx = ctx,
|
||||
space = space,
|
||||
details = objectState.value.dataViewState()?.details
|
||||
)
|
||||
}
|
||||
ObjectAction.CREATE_WIDGET -> {
|
||||
val details = objectState.value.dataViewState()?.details?.get(ctx)
|
||||
|
|
|
@ -40,9 +40,11 @@ sealed class RelationValueView {
|
|||
sealed class Object : RelationValueView(), Selectable {
|
||||
|
||||
abstract val id: Id
|
||||
abstract val space: Id
|
||||
|
||||
data class Default(
|
||||
override val id: Id,
|
||||
override val space: Id,
|
||||
val name: String,
|
||||
val typeName: String?,
|
||||
val type: String?,
|
||||
|
@ -56,6 +58,7 @@ sealed class RelationValueView {
|
|||
|
||||
data class NonExistent(
|
||||
override val id: Id,
|
||||
override val space: Id,
|
||||
override val isSelected: Boolean? = null,
|
||||
val removable: Boolean
|
||||
) : Object(), Selectable
|
||||
|
@ -63,6 +66,7 @@ sealed class RelationValueView {
|
|||
|
||||
data class File(
|
||||
val id: Id,
|
||||
val space: Id,
|
||||
val name: String,
|
||||
val mime: String,
|
||||
val ext: String,
|
||||
|
|
|
@ -165,7 +165,18 @@ open class ObjectSearchViewModel(
|
|||
ObjectType.Layout.IMAGE,
|
||||
ObjectType.Layout.BOOKMARK,
|
||||
ObjectType.Layout.PARTICIPANT -> {
|
||||
navigate(EventWrapper(AppNavigation.Command.LaunchDocument(id = target)))
|
||||
val obj = objects
|
||||
.value
|
||||
.getOrNull()
|
||||
?.find { obj -> obj.id == view.id }
|
||||
navigate(
|
||||
EventWrapper(
|
||||
AppNavigation.Command.LaunchDocument(
|
||||
target = target,
|
||||
space = requireNotNull(obj?.spaceId)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
ObjectType.Layout.PROFILE -> {
|
||||
val obj = objects
|
||||
|
@ -174,13 +185,38 @@ open class ObjectSearchViewModel(
|
|||
?.find { obj -> obj.id == view.id }
|
||||
val identity = obj?.getValue<Id>(Relations.IDENTITY_PROFILE_LINK)
|
||||
if (identity != null) {
|
||||
navigate(EventWrapper(AppNavigation.Command.LaunchDocument(id = identity)))
|
||||
navigate(
|
||||
EventWrapper(
|
||||
AppNavigation.Command.LaunchDocument(
|
||||
target = identity,
|
||||
space = requireNotNull(obj.spaceId)
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
navigate(EventWrapper(AppNavigation.Command.LaunchDocument(id = target)))
|
||||
navigate(
|
||||
EventWrapper(
|
||||
AppNavigation.Command.LaunchDocument(
|
||||
target = target,
|
||||
space = requireNotNull(obj?.spaceId)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
ObjectType.Layout.SET, ObjectType.Layout.COLLECTION -> {
|
||||
navigate(EventWrapper(AppNavigation.Command.LaunchObjectSet(target = target)))
|
||||
val obj = objects
|
||||
.value
|
||||
.getOrNull()
|
||||
?.find { obj -> obj.id == view.id }
|
||||
navigate(
|
||||
EventWrapper(
|
||||
AppNavigation.Command.LaunchObjectSet(
|
||||
target = target,
|
||||
space = requireNotNull(obj?.spaceId)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
Timber.e("Unexpected layout: ${view.layout}")
|
||||
|
|
|
@ -14,8 +14,15 @@ sealed class DataViewViewState {
|
|||
sealed class Set : DataViewViewState() {
|
||||
object NoQuery : Set()
|
||||
object NoView : Set()
|
||||
data class NoItems(val title: String, val isCreateObjectAllowed: Boolean) : Set()
|
||||
data class Default(val viewer: Viewer?, val isCreateObjectAllowed: Boolean) : Set()
|
||||
data class NoItems(
|
||||
val title: String,
|
||||
val isCreateObjectAllowed: Boolean
|
||||
) : Set()
|
||||
data class Default(
|
||||
val viewer: Viewer?,
|
||||
val isCreateObjectAllowed: Boolean,
|
||||
val isEditingViewAllowed: Boolean = true
|
||||
) : Set()
|
||||
}
|
||||
|
||||
object Init: DataViewViewState()
|
||||
|
@ -26,7 +33,8 @@ sealed class SetOrCollectionHeaderState {
|
|||
object None : SetOrCollectionHeaderState()
|
||||
data class Default(
|
||||
val title: BlockView.Title.Basic,
|
||||
val description: Description
|
||||
val description: Description,
|
||||
val isReadOnlyMode: Boolean = false
|
||||
) : SetOrCollectionHeaderState()
|
||||
|
||||
sealed class Description {
|
||||
|
|
|
@ -16,12 +16,17 @@ import com.anytypeio.anytype.core_models.Event.Command.DataView.UpdateView.DVVie
|
|||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.PermittedConditions
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.RelationFormat
|
||||
import com.anytypeio.anytype.core_models.RelationLink
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.Struct
|
||||
import com.anytypeio.anytype.core_models.ext.DAYS_IN_MONTH
|
||||
import com.anytypeio.anytype.core_models.ext.DAYS_IN_WEEK
|
||||
import com.anytypeio.anytype.core_models.ext.DateParser
|
||||
import com.anytypeio.anytype.core_models.ext.EMPTY_STRING_VALUE
|
||||
import com.anytypeio.anytype.core_models.ext.SECONDS_IN_DAY
|
||||
import com.anytypeio.anytype.core_models.ext.mapToObjectWrapperType
|
||||
import com.anytypeio.anytype.core_models.ext.title
|
||||
import com.anytypeio.anytype.core_models.primitives.TypeId
|
||||
|
@ -46,11 +51,6 @@ import com.anytypeio.anytype.presentation.relations.isSystemKey
|
|||
import com.anytypeio.anytype.presentation.relations.linksFeaturedRelation
|
||||
import com.anytypeio.anytype.presentation.relations.title
|
||||
import com.anytypeio.anytype.presentation.relations.view
|
||||
import com.anytypeio.anytype.core_models.PermittedConditions
|
||||
import com.anytypeio.anytype.core_models.ext.DAYS_IN_MONTH
|
||||
import com.anytypeio.anytype.core_models.ext.DAYS_IN_WEEK
|
||||
import com.anytypeio.anytype.core_models.ext.EMPTY_STRING_VALUE
|
||||
import com.anytypeio.anytype.core_models.ext.SECONDS_IN_DAY
|
||||
import com.anytypeio.anytype.presentation.sets.model.ObjectView
|
||||
import com.anytypeio.anytype.presentation.sets.model.SimpleRelationView
|
||||
import com.anytypeio.anytype.presentation.sets.model.Viewer
|
||||
|
@ -91,7 +91,8 @@ fun ObjectState.DataView.featuredRelations(
|
|||
fun ObjectState.DataView.header(
|
||||
ctx: Id,
|
||||
urlBuilder: UrlBuilder,
|
||||
coverImageHashProvider: CoverImageHashProvider
|
||||
coverImageHashProvider: CoverImageHashProvider,
|
||||
isReadOnlyMode: Boolean = false
|
||||
): SetOrCollectionHeaderState {
|
||||
val title = blocks.title()
|
||||
return if (title != null) {
|
||||
|
@ -105,7 +106,7 @@ fun ObjectState.DataView.header(
|
|||
title = title,
|
||||
urlBuilder = urlBuilder,
|
||||
details = details,
|
||||
coverImageHashProvider = coverImageHashProvider
|
||||
coverImageHashProvider = coverImageHashProvider,
|
||||
),
|
||||
description = if (featured.contains(Relations.DESCRIPTION)) {
|
||||
SetOrCollectionHeaderState.Description.Default(
|
||||
|
@ -113,7 +114,8 @@ fun ObjectState.DataView.header(
|
|||
)
|
||||
} else {
|
||||
SetOrCollectionHeaderState.Description.None
|
||||
}
|
||||
},
|
||||
isReadOnlyMode = isReadOnlyMode
|
||||
)
|
||||
} else {
|
||||
return SetOrCollectionHeaderState.None
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.anytypeio.anytype.core_models.ObjectWrapper
|
|||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.RelationFormat
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.multiplayer.SpaceMemberPermissions
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.core_models.primitives.TypeId
|
||||
import com.anytypeio.anytype.core_models.primitives.TypeKey
|
||||
|
@ -127,6 +128,7 @@ import kotlinx.coroutines.flow.flatMapLatest
|
|||
import kotlinx.coroutines.flow.flowOn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.mapLatest
|
||||
import kotlinx.coroutines.flow.mapNotNull
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withTimeout
|
||||
|
@ -176,6 +178,8 @@ class ObjectSetViewModel(
|
|||
|
||||
val icon = MutableStateFlow<ProfileIconView>(ProfileIconView.Loading)
|
||||
|
||||
val permission = MutableStateFlow<SpaceMemberPermissions?>(SpaceMemberPermissions.NO_PERMISSIONS)
|
||||
|
||||
val status = MutableStateFlow<SyncStatusView?>(null)
|
||||
val error = MutableStateFlow<String?>(null)
|
||||
|
||||
|
@ -220,6 +224,7 @@ class ObjectSetViewModel(
|
|||
val isLoading = MutableStateFlow(false)
|
||||
|
||||
private var context: Id = ""
|
||||
private var space = MutableStateFlow("")
|
||||
|
||||
private val selectedTypeFlow: MutableStateFlow<ObjectWrapper.Type?> = MutableStateFlow(null)
|
||||
|
||||
|
@ -230,7 +235,10 @@ class ObjectSetViewModel(
|
|||
stateReducer.state
|
||||
.filterIsInstance<ObjectState.DataView>()
|
||||
.distinctUntilChanged()
|
||||
.collectLatest { state ->
|
||||
.combine(permission) { state, permission ->
|
||||
state to permission
|
||||
}
|
||||
.collectLatest { (state, permission) ->
|
||||
featured.value = state.featuredRelations(
|
||||
ctx = context,
|
||||
urlBuilder = urlBuilder,
|
||||
|
@ -239,7 +247,8 @@ class ObjectSetViewModel(
|
|||
_header.value = state.header(
|
||||
ctx = context,
|
||||
urlBuilder = urlBuilder,
|
||||
coverImageHashProvider = coverImageHashProvider
|
||||
coverImageHashProvider = coverImageHashProvider,
|
||||
isReadOnlyMode = permission == SpaceMemberPermissions.NO_PERMISSIONS || permission == SpaceMemberPermissions.READER
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -299,11 +308,18 @@ class ObjectSetViewModel(
|
|||
is Action.SetUnsplashImage -> {
|
||||
proceedWithSettingUnsplashImage(action)
|
||||
}
|
||||
is Action.OpenObject -> proceedWithOpeningObject(action.id)
|
||||
is Action.OpenCollection -> proceedWithOpeningObjectCollection(action.id)
|
||||
is Action.OpenObject -> proceedWithOpeningObject(
|
||||
target = action.target,
|
||||
space = action.space
|
||||
)
|
||||
is Action.OpenCollection -> proceedWithOpeningObjectCollection(
|
||||
target = action.target,
|
||||
space = action.space
|
||||
)
|
||||
is Action.Duplicate -> proceedWithNavigation(
|
||||
target = action.id,
|
||||
layout = ObjectType.Layout.SET
|
||||
target = action.target,
|
||||
layout = ObjectType.Layout.SET,
|
||||
space = action.space
|
||||
)
|
||||
else -> {}
|
||||
}
|
||||
|
@ -347,8 +363,9 @@ class ObjectSetViewModel(
|
|||
|
||||
private fun proceedWithObservingProfileIcon() {
|
||||
viewModelScope.launch {
|
||||
spaceManager
|
||||
.observe()
|
||||
space
|
||||
.filter { it.isNotEmpty() }
|
||||
.mapNotNull { spaceManager.getConfig(SpaceId(it)) }
|
||||
.flatMapLatest { config ->
|
||||
storelessSubscriptionContainer.subscribe(
|
||||
StoreSearchByIdsParams(
|
||||
|
@ -356,6 +373,7 @@ class ObjectSetViewModel(
|
|||
targets = listOf(config.profile),
|
||||
keys = listOf(
|
||||
Relations.ID,
|
||||
Relations.SPACE_ID,
|
||||
Relations.NAME,
|
||||
Relations.ICON_EMOJI,
|
||||
Relations.ICON_IMAGE,
|
||||
|
@ -380,7 +398,7 @@ class ObjectSetViewModel(
|
|||
DownloadUnsplashImage.Params(
|
||||
picture = action.img,
|
||||
// TODO re-fact to use space id from arguments or target space id of this object
|
||||
space = SpaceId(spaceManager.get())
|
||||
space = SpaceId(space.value)
|
||||
)
|
||||
).process(
|
||||
failure = {
|
||||
|
@ -402,9 +420,10 @@ class ObjectSetViewModel(
|
|||
)
|
||||
}
|
||||
|
||||
fun onStart(ctx: Id) {
|
||||
fun onStart(ctx: Id, space: Id) {
|
||||
Timber.d("onStart, ctx:[$ctx]")
|
||||
context = ctx
|
||||
this.context = ctx
|
||||
this.space.value = space
|
||||
subscribeToEvents(ctx = ctx)
|
||||
subscribeToThreadStatus(ctx = ctx)
|
||||
proceedWithOpeningCurrentObject(ctx = ctx)
|
||||
|
@ -425,7 +444,7 @@ class ObjectSetViewModel(
|
|||
.build(InterceptThreadStatus.Params(ctx))
|
||||
.collect {
|
||||
val statusView = it.toView(
|
||||
networkId = spaceManager.getConfig()?.network,
|
||||
networkId = spaceManager.getConfig(SpaceId(space.value))?.network,
|
||||
networkMode = networkMode
|
||||
)
|
||||
status.value = statusView
|
||||
|
@ -438,24 +457,30 @@ class ObjectSetViewModel(
|
|||
Timber.d("subscribeToObjectState, ctx:[$context]")
|
||||
viewModelScope.launch {
|
||||
combine(
|
||||
space.filter { it.isNotEmpty() },
|
||||
stateReducer.state,
|
||||
paginator.offset,
|
||||
session.currentViewerId,
|
||||
) { state, offset, view ->
|
||||
Triple(state, offset, view)
|
||||
}.flatMapLatest { (state, offset, view) ->
|
||||
when (state) {
|
||||
) { space, state, offset, view ->
|
||||
Query(
|
||||
space = space,
|
||||
state = state,
|
||||
offset = offset,
|
||||
currentViewerId = view
|
||||
)
|
||||
}.flatMapLatest { query ->
|
||||
when (query.state) {
|
||||
is ObjectState.DataView.Collection -> {
|
||||
Timber.d("subscribeToObjectState, NEW COLLECTION STATE")
|
||||
if (state.isInitialized) {
|
||||
if (query.state.isInitialized) {
|
||||
dataViewSubscription.startObjectCollectionSubscription(
|
||||
collection = context,
|
||||
state = state,
|
||||
currentViewerId = view,
|
||||
offset = offset,
|
||||
state = query.state,
|
||||
currentViewerId = query.currentViewerId,
|
||||
offset = query.offset,
|
||||
context = context,
|
||||
spaces = spaceManager.getSpaceWithTechSpace(),
|
||||
dataViewRelationLinks = state.dataViewContent.relationLinks
|
||||
spaces = spaceManager.getSpaceWithTechSpace(space = query.space),
|
||||
dataViewRelationLinks = query.state.dataViewContent.relationLinks
|
||||
)
|
||||
} else {
|
||||
emptyFlow()
|
||||
|
@ -464,14 +489,14 @@ class ObjectSetViewModel(
|
|||
|
||||
is ObjectState.DataView.Set -> {
|
||||
Timber.d("subscribeToObjectState, NEW SET STATE")
|
||||
if (state.isInitialized) {
|
||||
if (query.state.isInitialized) {
|
||||
dataViewSubscription.startObjectSetSubscription(
|
||||
state = state,
|
||||
currentViewerId = view,
|
||||
offset = offset,
|
||||
state = query.state,
|
||||
currentViewerId = query.currentViewerId,
|
||||
offset = query.offset,
|
||||
context = context,
|
||||
spaces = spaceManager.getSpaceWithTechSpace(),
|
||||
dataViewRelationLinks = state.dataViewContent.relationLinks
|
||||
dataViewRelationLinks = query.state.dataViewContent.relationLinks
|
||||
)
|
||||
} else {
|
||||
emptyFlow()
|
||||
|
@ -479,7 +504,7 @@ class ObjectSetViewModel(
|
|||
}
|
||||
|
||||
else -> {
|
||||
Timber.d("subscribeToObjectState, NEW STATE, $state")
|
||||
Timber.d("subscribeToObjectState, NEW STATE, ${query.state}")
|
||||
emptyFlow()
|
||||
}
|
||||
}
|
||||
|
@ -551,9 +576,10 @@ class ObjectSetViewModel(
|
|||
combine(
|
||||
database.index,
|
||||
stateReducer.state,
|
||||
session.currentViewerId
|
||||
) { dataViewState, objectState, currentViewId ->
|
||||
processViewState(dataViewState, objectState, currentViewId)
|
||||
session.currentViewerId,
|
||||
permission
|
||||
) { dataViewState, objectState, currentViewId, permission ->
|
||||
processViewState(dataViewState, objectState, currentViewId, permission)
|
||||
}.distinctUntilChanged().collect { viewState ->
|
||||
Timber.d("subscribeToDataViewViewer, newViewerState:[$viewState]")
|
||||
_currentViewer.value = viewState
|
||||
|
@ -564,7 +590,8 @@ class ObjectSetViewModel(
|
|||
private suspend fun processViewState(
|
||||
dataViewState: DataViewState,
|
||||
objectState: ObjectState,
|
||||
currentViewId: String?
|
||||
currentViewId: String?,
|
||||
permission: SpaceMemberPermissions?
|
||||
): DataViewViewState {
|
||||
return when (objectState) {
|
||||
is ObjectState.DataView.Collection -> processCollectionState(
|
||||
|
@ -575,7 +602,8 @@ class ObjectSetViewModel(
|
|||
is ObjectState.DataView.Set -> processSetState(
|
||||
dataViewState = dataViewState,
|
||||
objectState = objectState,
|
||||
currentViewId = currentViewId
|
||||
currentViewId = currentViewId,
|
||||
permission = permission
|
||||
)
|
||||
ObjectState.Init -> DataViewViewState.Init
|
||||
ObjectState.ErrorLayout -> DataViewViewState.Error(msg = "Wrong layout, couldn't open object")
|
||||
|
@ -636,6 +664,7 @@ class ObjectSetViewModel(
|
|||
dataViewState: DataViewState,
|
||||
objectState: ObjectState.DataView.Set,
|
||||
currentViewId: String?,
|
||||
permission: SpaceMemberPermissions?
|
||||
): DataViewViewState {
|
||||
if (!objectState.isInitialized) return DataViewViewState.Init
|
||||
|
||||
|
@ -688,7 +717,9 @@ class ObjectSetViewModel(
|
|||
)
|
||||
DataViewViewState.Set.Default(
|
||||
viewer = render,
|
||||
isCreateObjectAllowed = objectState.isCreateObjectAllowed(defType)
|
||||
isCreateObjectAllowed = objectState.isCreateObjectAllowed(defType),
|
||||
// && (permission?.isOwnerOrEditor() == true),
|
||||
isEditingViewAllowed = permission?.isOwnerOrEditor() == true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -921,6 +952,7 @@ class ObjectSetViewModel(
|
|||
proceedWithNavigation(
|
||||
target = target,
|
||||
layout = obj.layout,
|
||||
space = requireNotNull(obj.spaceId),
|
||||
identityProfileLink = obj.getSingleValue(Relations.IDENTITY_PROFILE_LINK)
|
||||
)
|
||||
}
|
||||
|
@ -938,6 +970,7 @@ class ObjectSetViewModel(
|
|||
proceedWithNavigation(
|
||||
target = target,
|
||||
layout = obj.layout,
|
||||
space = requireNotNull(obj.spaceId),
|
||||
identityProfileLink = obj.getSingleValue(Relations.IDENTITY_PROFILE_LINK)
|
||||
)
|
||||
} else {
|
||||
|
@ -1176,7 +1209,8 @@ class ObjectSetViewModel(
|
|||
if (obj.layout == ObjectType.Layout.NOTE) {
|
||||
proceedWithOpeningObject(
|
||||
target = response.objectId,
|
||||
layout = obj.layout
|
||||
layout = obj.layout,
|
||||
space = requireNotNull(obj.spaceId)
|
||||
)
|
||||
} else {
|
||||
dispatch(
|
||||
|
@ -1340,7 +1374,11 @@ class ObjectSetViewModel(
|
|||
|
||||
//region NAVIGATION
|
||||
|
||||
private suspend fun proceedWithOpeningObject(target: Id, layout: ObjectType.Layout? = null) {
|
||||
private suspend fun proceedWithOpeningObject(
|
||||
target: Id,
|
||||
space: Id,
|
||||
layout: ObjectType.Layout? = null
|
||||
) {
|
||||
Timber.d("proceedWithOpeningObject, target:[$target], layout:[$layout]")
|
||||
if (target == context) {
|
||||
toast("You are already here")
|
||||
|
@ -1348,11 +1386,10 @@ class ObjectSetViewModel(
|
|||
return
|
||||
}
|
||||
isCustomizeViewPanelVisible.value = false
|
||||
val navigateCommand = when (layout) {
|
||||
ObjectType.Layout.SET,
|
||||
ObjectType.Layout.COLLECTION -> AppNavigation.Command.OpenSetOrCollection(target = target)
|
||||
else -> AppNavigation.Command.OpenObject(id = target)
|
||||
}
|
||||
val navigateCommand = AppNavigation.Command.OpenObject(
|
||||
target = target,
|
||||
space = space
|
||||
)
|
||||
closeBlock.async(context).fold(
|
||||
onSuccess = { navigate(EventWrapper(navigateCommand)) },
|
||||
onFailure = {
|
||||
|
@ -1380,7 +1417,10 @@ class ObjectSetViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun proceedWithOpeningObjectCollection(target: Id) {
|
||||
private suspend fun proceedWithOpeningObjectCollection(
|
||||
target: Id,
|
||||
space: Id
|
||||
) {
|
||||
if (target == context) {
|
||||
toast("You are already here")
|
||||
Timber.d("proceedWithOpeningObject, target == context")
|
||||
|
@ -1390,11 +1430,25 @@ class ObjectSetViewModel(
|
|||
jobs += viewModelScope.launch {
|
||||
closeBlock.async(context).fold(
|
||||
onSuccess = {
|
||||
navigate(EventWrapper(AppNavigation.Command.OpenSetOrCollection(target = target)))
|
||||
navigate(
|
||||
EventWrapper(
|
||||
AppNavigation.Command.OpenSetOrCollection(
|
||||
target = target,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
onFailure = {
|
||||
Timber.e(it, "Error while closing object set: $context")
|
||||
navigate(EventWrapper(AppNavigation.Command.OpenSetOrCollection(target = target)))
|
||||
navigate(
|
||||
EventWrapper(
|
||||
AppNavigation.Command.OpenSetOrCollection(
|
||||
target = target,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -1402,6 +1456,7 @@ class ObjectSetViewModel(
|
|||
|
||||
private suspend fun proceedWithNavigation(
|
||||
target: Id,
|
||||
space: Id,
|
||||
layout: ObjectType.Layout?,
|
||||
identityProfileLink: Id? = null
|
||||
) {
|
||||
|
@ -1420,16 +1475,36 @@ class ObjectSetViewModel(
|
|||
ObjectType.Layout.AUDIO,
|
||||
ObjectType.Layout.PDF,
|
||||
ObjectType.Layout.BOOKMARK,
|
||||
ObjectType.Layout.PARTICIPANT -> proceedWithOpeningObject(target)
|
||||
ObjectType.Layout.PROFILE -> proceedWithOpeningObject(identityProfileLink ?: target)
|
||||
ObjectType.Layout.PARTICIPANT -> proceedWithOpeningObject(
|
||||
target = target,
|
||||
space = space
|
||||
)
|
||||
ObjectType.Layout.PROFILE -> proceedWithOpeningObject(
|
||||
target = identityProfileLink ?: target,
|
||||
space = space
|
||||
)
|
||||
ObjectType.Layout.SET, ObjectType.Layout.COLLECTION -> {
|
||||
closeBlock.async(context).fold(
|
||||
onSuccess = {
|
||||
navigate(EventWrapper(AppNavigation.Command.OpenSetOrCollection(target)))
|
||||
navigate(
|
||||
EventWrapper(
|
||||
AppNavigation.Command.OpenSetOrCollection(
|
||||
target = target,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
onFailure = {
|
||||
Timber.e(it, "Error while closing object set: $context")
|
||||
navigate(EventWrapper(AppNavigation.Command.OpenSetOrCollection(target)))
|
||||
navigate(
|
||||
EventWrapper(
|
||||
AppNavigation.Command.OpenSetOrCollection(
|
||||
target = target,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -1480,7 +1555,8 @@ class ObjectSetViewModel(
|
|||
onSuccess = { result ->
|
||||
proceedWithOpeningObject(
|
||||
target = result.objectId,
|
||||
layout = result.obj.layout
|
||||
layout = result.obj.layout,
|
||||
space = requireNotNull(result.obj.spaceId)
|
||||
)
|
||||
sendAnalyticsObjectCreateEvent(
|
||||
analytics = analytics,
|
||||
|
@ -1951,7 +2027,7 @@ class ObjectSetViewModel(
|
|||
|
||||
private suspend fun fetchAndProcessObjectTypes(selectedType: Id, widgetState: TypeTemplatesWidgetUI.Data) {
|
||||
val filters = ObjectSearchConstants.filterTypes(
|
||||
spaces = listOf(spaceManager.get()),
|
||||
spaces = listOf(space.value),
|
||||
recommendedLayouts = SupportedLayouts.createObjectLayouts
|
||||
)
|
||||
val params = GetObjectTypes.Params(
|
||||
|
@ -2666,4 +2742,17 @@ class ObjectSetViewModel(
|
|||
const val DELAY_BEFORE_CREATING_TEMPLATE = 200L
|
||||
private const val SUBSCRIPTION_TEMPLATES_ID = "-SUBSCRIPTION_TEMPLATES_ID"
|
||||
}
|
||||
|
||||
// TODO will be used in the next pr
|
||||
data class Params(
|
||||
val ctx: Id,
|
||||
val space: SpaceId
|
||||
)
|
||||
|
||||
data class Query(
|
||||
val space: Id,
|
||||
val state: ObjectState,
|
||||
val offset: Long,
|
||||
val currentViewerId: Id?
|
||||
)
|
||||
}
|
|
@ -175,6 +175,7 @@ abstract class RelationValueBaseViewModel(
|
|||
items.add(
|
||||
RelationValueView.Object.NonExistent(
|
||||
id = id,
|
||||
space = requireNotNull(wrapper.spaceId),
|
||||
removable = isRemovable
|
||||
)
|
||||
)
|
||||
|
@ -182,6 +183,7 @@ abstract class RelationValueBaseViewModel(
|
|||
items.add(
|
||||
RelationValueView.Object.Default(
|
||||
id = id,
|
||||
space = requireNotNull(wrapper.spaceId),
|
||||
name = wrapper.getProperName(),
|
||||
typeName = objectType?.name,
|
||||
type = type,
|
||||
|
@ -222,7 +224,8 @@ abstract class RelationValueBaseViewModel(
|
|||
mime = wrapper.fileMimeType.orEmpty(),
|
||||
ext = wrapper.fileExt.orEmpty(),
|
||||
image = wrapper.iconImage,
|
||||
removable = isRemovable
|
||||
removable = isRemovable,
|
||||
space = requireNotNull(wrapper.spaceId)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -470,6 +473,7 @@ abstract class RelationValueBaseViewModel(
|
|||
fun onObjectClicked(
|
||||
ctx: Id,
|
||||
id: Id,
|
||||
space: Id,
|
||||
layout: ObjectType.Layout?,
|
||||
profileLinkIdentity: Id? = null
|
||||
) {
|
||||
|
@ -483,19 +487,32 @@ abstract class RelationValueBaseViewModel(
|
|||
ObjectType.Layout.BOOKMARK,
|
||||
ObjectType.Layout.PARTICIPANT -> {
|
||||
viewModelScope.launch {
|
||||
navigation.emit(AppNavigation.Command.OpenObject(id))
|
||||
navigation.emit(
|
||||
AppNavigation.Command.OpenObject(
|
||||
target = id,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
ObjectType.Layout.PROFILE -> {
|
||||
viewModelScope.launch {
|
||||
navigation.emit(
|
||||
AppNavigation.Command.OpenObject(profileLinkIdentity ?: id)
|
||||
AppNavigation.Command.OpenObject(
|
||||
target = profileLinkIdentity ?: id,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
ObjectType.Layout.SET, ObjectType.Layout.COLLECTION -> {
|
||||
viewModelScope.launch {
|
||||
navigation.emit(AppNavigation.Command.OpenSetOrCollection(id))
|
||||
navigation.emit(
|
||||
AppNavigation.Command.OpenSetOrCollection(
|
||||
target = id,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
else -> Timber.d("Unexpected layout: $layout").also {
|
||||
|
@ -507,16 +524,26 @@ abstract class RelationValueBaseViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun onNonExistentObjectClicked(ctx: Id, target: Id) {
|
||||
fun onNonExistentObjectClicked(ctx: Id, target: Id, space: Id) {
|
||||
// TODO consider closing object before navigation
|
||||
viewModelScope.launch {
|
||||
navigation.emit(AppNavigation.Command.OpenObject(target))
|
||||
navigation.emit(
|
||||
AppNavigation.Command.OpenObject(
|
||||
target = target,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun onFileClicked(id: Id) {
|
||||
fun onFileClicked(target: Id, space: Id) {
|
||||
viewModelScope.launch {
|
||||
navigation.emit(AppNavigation.Command.OpenObject(id))
|
||||
navigation.emit(
|
||||
AppNavigation.Command.OpenObject(
|
||||
target = target,
|
||||
space = space
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -155,7 +155,12 @@ class AddToAnytypeViewModel(
|
|||
1 -> {
|
||||
// No need to create a wrapper object, opening file object directly instead
|
||||
if (targetSpaceId == spaceManager.get()) {
|
||||
navigation.emit(OpenObjectNavigation.OpenEditor(files.first()))
|
||||
navigation.emit(
|
||||
OpenObjectNavigation.OpenEditor(
|
||||
target = files.first(),
|
||||
space = targetSpaceId
|
||||
)
|
||||
)
|
||||
} else {
|
||||
with(commands) {
|
||||
emit(Command.ObjectAddToSpaceToast(targetSpaceView.obj.name))
|
||||
|
@ -184,7 +189,12 @@ class AddToAnytypeViewModel(
|
|||
startTime = startTime
|
||||
)
|
||||
if (targetSpaceId == spaceManager.get()) {
|
||||
navigation.emit(OpenObjectNavigation.OpenEditor(result))
|
||||
navigation.emit(
|
||||
OpenObjectNavigation.OpenEditor(
|
||||
target = result,
|
||||
space = targetSpaceId
|
||||
)
|
||||
)
|
||||
} else {
|
||||
with(commands) {
|
||||
emit(Command.ObjectAddToSpaceToast(targetSpaceView.obj.name))
|
||||
|
@ -227,7 +237,12 @@ class AddToAnytypeViewModel(
|
|||
startTime = startTime
|
||||
)
|
||||
if (targetSpaceId == spaceManager.get()) {
|
||||
navigation.emit(OpenObjectNavigation.OpenEditor(obj))
|
||||
navigation.emit(
|
||||
OpenObjectNavigation.OpenEditor(
|
||||
target = obj,
|
||||
space = targetSpaceId
|
||||
)
|
||||
)
|
||||
} else {
|
||||
with(commands) {
|
||||
emit(Command.ObjectAddToSpaceToast(targetSpaceView.obj.name))
|
||||
|
@ -269,7 +284,12 @@ class AddToAnytypeViewModel(
|
|||
startTime = startTime
|
||||
)
|
||||
if (targetSpaceId == spaceManager.get()) {
|
||||
navigation.emit(OpenObjectNavigation.OpenEditor(result))
|
||||
navigation.emit(
|
||||
OpenObjectNavigation.OpenEditor(
|
||||
target = result,
|
||||
space = targetSpaceId
|
||||
)
|
||||
)
|
||||
} else {
|
||||
with(commands) {
|
||||
emit(Command.ObjectAddToSpaceToast(targetSpaceView.obj.name))
|
||||
|
|
|
@ -426,10 +426,20 @@ class CollectionViewModel(
|
|||
ObjectType.Layout.FILE,
|
||||
ObjectType.Layout.IMAGE,
|
||||
ObjectType.Layout.BOOKMARK -> {
|
||||
commands.emit(Command.LaunchDocument(id = target))
|
||||
commands.emit(
|
||||
Command.LaunchDocument(
|
||||
target = target,
|
||||
space = view.space
|
||||
)
|
||||
)
|
||||
}
|
||||
ObjectType.Layout.SET, ObjectType.Layout.COLLECTION -> {
|
||||
commands.emit(Command.LaunchObjectSet(target = target))
|
||||
commands.emit(
|
||||
Command.LaunchObjectSet(
|
||||
target = target,
|
||||
space = view.space
|
||||
)
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
Timber.e("Unexpected layout: ${view.layout}")
|
||||
|
@ -849,10 +859,20 @@ class CollectionViewModel(
|
|||
private suspend fun proceedWithOpeningObject(obj: ObjectWrapper.Basic) {
|
||||
when (val navigation = obj.navigation()) {
|
||||
is OpenObjectNavigation.OpenDataView -> {
|
||||
commands.emit(Command.LaunchObjectSet(navigation.target))
|
||||
commands.emit(
|
||||
Command.LaunchObjectSet(
|
||||
target = navigation.target,
|
||||
space = navigation.space
|
||||
)
|
||||
)
|
||||
}
|
||||
is OpenObjectNavigation.OpenEditor -> {
|
||||
commands.emit(Command.LaunchDocument(navigation.target))
|
||||
commands.emit(
|
||||
Command.LaunchDocument(
|
||||
target = navigation.target,
|
||||
space = navigation.space
|
||||
)
|
||||
)
|
||||
}
|
||||
is OpenObjectNavigation.UnexpectedLayoutError -> {
|
||||
toasts.emit("Unexpected layout: ${navigation.layout}")
|
||||
|
@ -944,9 +964,9 @@ class CollectionViewModel(
|
|||
|
||||
sealed class Command {
|
||||
data class ConfirmRemoveFromBin(val count: Int) : Command()
|
||||
data class LaunchDocument(val id: Id) : Command()
|
||||
data class OpenCollection(val subscription: Subscription) : Command()
|
||||
data class LaunchObjectSet(val target: Id) : Command()
|
||||
data class LaunchDocument(val target: Id, val space: Id) : Command()
|
||||
data class OpenCollection(val subscription: Subscription, val space: Id) : Command()
|
||||
data class LaunchObjectSet(val target: Id, val space: Id) : Command()
|
||||
|
||||
object ToDesktop : Command()
|
||||
object ToSearch : Command()
|
||||
|
|
|
@ -48,7 +48,7 @@ class CollectionAddRelationTest : ObjectSetViewModelTestSetup() {
|
|||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
objectCollection = MockCollection(context = root)
|
||||
objectCollection = MockCollection(context = root, space = defaultSpace)
|
||||
viewModel = givenViewModel()
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ class CollectionAddRelationTest : ObjectSetViewModelTestSetup() {
|
|||
@Test
|
||||
fun `should add new relation to data view`() = runTest {
|
||||
// SETUP
|
||||
stubSpaceManager(objectCollection.spaceId)
|
||||
stubSpaceManager(space = objectCollection.spaceId)
|
||||
stubStoreOfRelations(objectCollection)
|
||||
stubSubscriptionResults(
|
||||
subscription = objectCollection.subscriptionId,
|
||||
|
@ -94,7 +94,7 @@ class CollectionAddRelationTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val relationId4 = "rel-newRelationKey"
|
||||
val relationKey4 = "newRelationKey"
|
||||
|
@ -294,4 +294,8 @@ class CollectionAddRelationTest : ObjectSetViewModelTestSetup() {
|
|||
expectNoEvents()
|
||||
}
|
||||
}
|
||||
|
||||
private fun proceedWithStartingViewModel() {
|
||||
viewModel.onStart(ctx = root, space = defaultSpace)
|
||||
}
|
||||
}
|
|
@ -54,7 +54,7 @@ class CollectionCreateAndAddObjectTest: ObjectSetViewModelTestSetup() {
|
|||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
mockObjectCollection = MockCollection(context = root)
|
||||
mockObjectCollection = MockCollection(context = root, space = defaultSpace)
|
||||
repo = mock(verboseLogging = true)
|
||||
dispatchers = AppCoroutineDispatchers(
|
||||
io = rule.dispatcher,
|
||||
|
@ -160,7 +160,7 @@ class CollectionCreateAndAddObjectTest: ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
// ASSERT DATA VIEW STATE
|
||||
viewModel.currentViewer.test {
|
||||
|
@ -191,4 +191,8 @@ class CollectionCreateAndAddObjectTest: ObjectSetViewModelTestSetup() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun proceedWithStartingViewModel() {
|
||||
viewModel.onStart(ctx = root, space = defaultSpace)
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@ class CollectionDataViewUpdateTest : ObjectSetViewModelTestSetup() {
|
|||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
viewModel = givenViewModel()
|
||||
objectCollection = MockCollection(context = root)
|
||||
objectCollection = MockCollection(context = root, space = defaultSpace)
|
||||
stubGetDefaultPageType()
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ class CollectionDataViewUpdateTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
// ASSERT COLLECTION OBJECT STATE
|
||||
stateReducer.state.test {
|
||||
|
@ -122,4 +122,8 @@ class CollectionDataViewUpdateTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun proceedWithStartingViewModel() {
|
||||
viewModel.onStart(ctx = root, space = defaultSpace)
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ import com.anytypeio.anytype.core_models.DVFilter
|
|||
import com.anytypeio.anytype.core_models.DVSort
|
||||
import com.anytypeio.anytype.core_models.DVSortType
|
||||
import com.anytypeio.anytype.core_models.DVViewerType
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectOrder
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
|
@ -22,7 +23,10 @@ import com.anytypeio.anytype.presentation.sets.subscription.DefaultDataViewSubsc
|
|||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import net.bytebuddy.utility.RandomString
|
||||
|
||||
class MockCollection(context: String) {
|
||||
class MockCollection(
|
||||
context: Id,
|
||||
space: Id
|
||||
) {
|
||||
val root = context
|
||||
val title = StubTitle(id = "title-${RandomString.make()}", text = "title-name-${RandomString.make()}")
|
||||
val header = StubHeader(id = "header-${RandomString.make()}", children = listOf(title.id))
|
||||
|
@ -231,7 +235,7 @@ class MockCollection(context: String) {
|
|||
isCollection = true,
|
||||
objectOrder = emptyList()
|
||||
)
|
||||
val spaceId = "space-${RandomString.make()}"
|
||||
val spaceId = space
|
||||
|
||||
val subscriptionId = DefaultDataViewSubscription.getSubscriptionId(context)
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.anytypeio.anytype.presentation.collections
|
|||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.DVFilter
|
||||
import com.anytypeio.anytype.core_models.DVViewerType
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.ObjectTypeIds
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
|
@ -21,10 +22,12 @@ import com.anytypeio.anytype.presentation.sets.subscription.DefaultDataViewSubsc
|
|||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import net.bytebuddy.utility.RandomString
|
||||
|
||||
class MockSet(context: String,
|
||||
val setOfValue: String = "setOf-${RandomString.make()}",
|
||||
val setOfKey: String = "setOfKey-${RandomString.make()}"
|
||||
) {
|
||||
class MockSet(
|
||||
context: String,
|
||||
val space: Id,
|
||||
val setOfValue: String = "setOf-${RandomString.make()}",
|
||||
val setOfKey: String = "setOfKey-${RandomString.make()}"
|
||||
) {
|
||||
|
||||
val root = context
|
||||
val title =
|
||||
|
@ -36,7 +39,7 @@ class MockSet(context: String,
|
|||
children = listOf(title.id),
|
||||
fields = Block.Fields(mapOf(Relations.ICON_EMOJI to emoji))
|
||||
)
|
||||
val spaceId = "space-${RandomString.make()}"
|
||||
val spaceId = space
|
||||
val subscriptionId = DefaultDataViewSubscription.getSubscriptionId(context)
|
||||
val setOf get() = setOfValue
|
||||
|
||||
|
@ -174,8 +177,16 @@ class MockSet(context: String,
|
|||
)
|
||||
|
||||
// RECORDS
|
||||
val obj1 = StubObject(id = "object-${RandomString.make()}", name = "object1-name-${RandomString.make()}")
|
||||
val obj2 = StubObject(id = "object-${RandomString.make()}", name = "object2-name-${RandomString.make()}")
|
||||
val obj1 = StubObject(
|
||||
id = "object-${RandomString.make()}",
|
||||
name = "object1-name-${RandomString.make()}",
|
||||
space = spaceId
|
||||
)
|
||||
val obj2 = StubObject(
|
||||
id = "object-${RandomString.make()}",
|
||||
name = "object2-name-${RandomString.make()}",
|
||||
space = spaceId
|
||||
)
|
||||
|
||||
// SET OBJECT DETAILS
|
||||
val details = Block.Details(
|
||||
|
@ -183,6 +194,7 @@ class MockSet(context: String,
|
|||
root to Block.Fields(
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.SPACE_ID to spaceId,
|
||||
Relations.LAYOUT to ObjectType.Layout.SET.code.toDouble(),
|
||||
Relations.SET_OF to listOf(setOf)
|
||||
)
|
||||
|
@ -190,6 +202,7 @@ class MockSet(context: String,
|
|||
setOf to Block.Fields(
|
||||
map = mapOf(
|
||||
Relations.ID to setOf,
|
||||
Relations.SPACE_ID to spaceId,
|
||||
Relations.UNIQUE_KEY to setOfKey,
|
||||
Relations.TYPE to ObjectTypeIds.OBJECT_TYPE,
|
||||
Relations.RECOMMENDED_LAYOUT to ObjectType.Layout.BASIC.code.toDouble(),
|
||||
|
@ -204,6 +217,7 @@ class MockSet(context: String,
|
|||
root to Block.Fields(
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.SPACE_ID to spaceId,
|
||||
Relations.LAYOUT to ObjectType.Layout.SET.code.toDouble(),
|
||||
Relations.SET_OF to listOf<String>()
|
||||
)
|
||||
|
@ -216,6 +230,7 @@ class MockSet(context: String,
|
|||
root to Block.Fields(
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.SPACE_ID to spaceId,
|
||||
Relations.LAYOUT to ObjectType.Layout.SET.code.toDouble(),
|
||||
Relations.SET_OF to relationObject3.id
|
||||
)
|
||||
|
@ -223,6 +238,7 @@ class MockSet(context: String,
|
|||
relationObject3.id to Block.Fields(
|
||||
mapOf(
|
||||
Relations.ID to relationObject3.id,
|
||||
Relations.SPACE_ID to spaceId,
|
||||
Relations.RELATION_KEY to relationObject3.key,
|
||||
Relations.LAYOUT to ObjectType.Layout.RELATION.code.toDouble()
|
||||
)
|
||||
|
@ -235,6 +251,7 @@ class MockSet(context: String,
|
|||
root to Block.Fields(
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.SPACE_ID to spaceId,
|
||||
Relations.LAYOUT to ObjectType.Layout.SET.code.toDouble(),
|
||||
Relations.SET_OF to relationSetBy.id
|
||||
)
|
||||
|
@ -242,6 +259,7 @@ class MockSet(context: String,
|
|||
relationSetBy.id to Block.Fields(
|
||||
mapOf(
|
||||
Relations.ID to relationSetBy.id,
|
||||
Relations.SPACE_ID to spaceId,
|
||||
Relations.RELATION_KEY to relationSetBy.key,
|
||||
Relations.UNIQUE_KEY to relationSetBy.uniqueKey,
|
||||
Relations.LAYOUT to ObjectType.Layout.RELATION.code.toDouble(),
|
||||
|
|
|
@ -4,9 +4,7 @@ import app.cash.turbine.testIn
|
|||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.ObjectTypeIds
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.StubRelationObject
|
||||
import com.anytypeio.anytype.core_models.primitives.TypeKey
|
||||
import com.anytypeio.anytype.domain.base.Resultat
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.CreateDataViewObject
|
||||
|
@ -54,6 +52,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
|
||||
mockObjectSet = MockSet(
|
||||
context = root,
|
||||
space = defaultSpace,
|
||||
setOfValue = setOfId,
|
||||
setOfKey = setOfKey
|
||||
)
|
||||
|
@ -82,6 +81,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
objectType = TypeKey(setOfKey),
|
||||
struct = mapOf(
|
||||
Relations.ID to newObjectId,
|
||||
Relations.SPACE_ID to defaultSpace,
|
||||
Relations.UNIQUE_KEY to setOfKey,
|
||||
Relations.LAYOUT to ObjectType.Layout.NOTE.code.toDouble(),
|
||||
)
|
||||
|
@ -97,7 +97,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
doReturn(Resultat.success(Unit)).`when`(closeBlock).async(mockObjectSet.root)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
advanceUntilIdle()
|
||||
|
||||
|
@ -128,6 +128,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
|
||||
mockObjectSet = MockSet(
|
||||
context = root,
|
||||
space = defaultSpace,
|
||||
setOfValue = setOfId,
|
||||
setOfKey = setOfKey
|
||||
)
|
||||
|
@ -165,7 +166,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
doReturn(Resultat.success(Unit)).`when`(closeBlock).async(mockObjectSet.root)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
val commandFlow = viewModel.commands.testIn(backgroundScope)
|
||||
|
||||
advanceUntilIdle()
|
||||
|
@ -194,7 +195,11 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
|
||||
val relationKey = "relationKey-${RandomString.make()}"
|
||||
val relationUniqueKeys = "relationUniqueKeys-${RandomString.make()}"
|
||||
mockObjectSet = MockSet(context = root, setOfValue = setByRelationValue)
|
||||
mockObjectSet = MockSet(
|
||||
context = root,
|
||||
space = defaultSpace,
|
||||
setOfValue = setByRelationValue
|
||||
)
|
||||
val setByRelationMap = mapOf(
|
||||
Relations.ID to setByRelationValue,
|
||||
Relations.LAYOUT to ObjectType.Layout.RELATION.code.toDouble(),
|
||||
|
@ -251,7 +256,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
doReturn(Resultat.success(Unit)).`when`(closeBlock).async(mockObjectSet.root)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
advanceUntilIdle()
|
||||
|
||||
|
@ -276,7 +281,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
@Test
|
||||
fun `Should create new Object and not close Set when clicking on New button in Collection`() = runTest {
|
||||
|
||||
val objectCollection = MockCollection(context = root)
|
||||
val objectCollection = MockCollection(context = root, space = defaultSpace)
|
||||
|
||||
// SETUP
|
||||
stubSpaceManager(objectCollection.spaceId)
|
||||
|
@ -332,7 +337,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
doReturn(Resultat.success(Unit)).`when`(closeBlock).async(objectCollection.root)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
advanceUntilIdle()
|
||||
|
||||
|
@ -353,4 +358,8 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
|
||||
verifyNoInteractions(closeBlock)
|
||||
}
|
||||
|
||||
private fun proceedWithStartingViewModel() {
|
||||
viewModel.onStart(ctx = root, space = defaultSpace)
|
||||
}
|
||||
}
|
|
@ -40,7 +40,7 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
viewModel = givenViewModel()
|
||||
mockObjectCollection = MockCollection(context = root)
|
||||
mockObjectCollection = MockCollection(context = root, space = defaultSpace)
|
||||
stubGetDefaultPageType()
|
||||
stubNetworkMode()
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val headerFlow = viewModel.header.testIn(backgroundScope)
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
|
@ -97,7 +97,7 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
val stateFlow = stateReducer.state.testIn(backgroundScope)
|
||||
|
@ -137,7 +137,7 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
val stateFlow = stateReducer.state.testIn(backgroundScope)
|
||||
|
@ -176,7 +176,7 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
val stateFlow = stateReducer.state.testIn(backgroundScope)
|
||||
|
@ -222,7 +222,7 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
val stateFlow = stateReducer.state.testIn(backgroundScope)
|
||||
|
@ -276,7 +276,7 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
val stateFlow = stateReducer.state.testIn(backgroundScope)
|
||||
|
@ -331,7 +331,7 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
val stateFlow = stateReducer.state.testIn(backgroundScope)
|
||||
|
@ -387,7 +387,7 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
val stateFlow = stateReducer.state.testIn(backgroundScope)
|
||||
|
@ -442,7 +442,7 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
val stateFlow = stateReducer.state.testIn(backgroundScope)
|
||||
|
@ -498,7 +498,7 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
stubTemplatesForTemplatesContainer()
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
val stateFlow = stateReducer.state.testIn(backgroundScope)
|
||||
|
@ -572,7 +572,7 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
val stateFlow = stateReducer.state.testIn(backgroundScope)
|
||||
|
@ -639,7 +639,7 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
val stateFlow = stateReducer.state.testIn(backgroundScope)
|
||||
|
@ -708,7 +708,7 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
val stateFlow = stateReducer.state.testIn(backgroundScope)
|
||||
|
@ -773,7 +773,7 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
val stateFlow = stateReducer.state.testIn(backgroundScope)
|
||||
|
@ -787,4 +787,8 @@ class ObjectStateCollectionViewTest : ObjectSetViewModelTestSetup() {
|
|||
assertIs<DataViewViewState.Collection.NoItems>(item)
|
||||
assertTrue(item.isCreateObjectAllowed)
|
||||
}
|
||||
|
||||
private fun proceedWithStartingViewModel() {
|
||||
viewModel.onStart(ctx = root, space = defaultSpace)
|
||||
}
|
||||
}
|
|
@ -40,7 +40,7 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() {
|
|||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
viewModel = givenViewModel()
|
||||
mockObjectSet = MockSet(context = root)
|
||||
mockObjectSet = MockSet(context = root, space = defaultSpace)
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -71,7 +71,7 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
// ASSERT COLLECTION OBJECT STATE
|
||||
stateReducer.state.test {
|
||||
|
@ -106,7 +106,7 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
// ASSERT SET OBJECT STATE
|
||||
stateReducer.state.test {
|
||||
|
@ -135,7 +135,7 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
val stateFlow = stateReducer.state.testIn(backgroundScope)
|
||||
|
@ -160,7 +160,7 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
val stateFlow = stateReducer.state.testIn(backgroundScope)
|
||||
|
@ -194,7 +194,7 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
val stateFlow = stateReducer.state.testIn(backgroundScope)
|
||||
|
@ -227,7 +227,7 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
// ASSERT STATES
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
|
@ -304,7 +304,7 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
// ASSERT STATES
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
|
@ -385,7 +385,7 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
// ASSERT STATES
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
|
@ -405,7 +405,7 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() {
|
|||
fun `displaying set with templates present when opening object set of pages with templates`() = runTest {
|
||||
// SETUP
|
||||
|
||||
mockObjectSet = MockSet(context = root, setOfValue = ObjectTypeIds.PAGE)
|
||||
mockObjectSet = MockSet(context = root, setOfValue = ObjectTypeIds.PAGE, space = defaultSpace)
|
||||
val pageTypeMap = mapOf(
|
||||
Relations.ID to ObjectTypeIds.PAGE,
|
||||
Relations.TYPE to ObjectTypeIds.OBJECT_TYPE,
|
||||
|
@ -434,7 +434,7 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
proceedWithStartingViewModel()
|
||||
|
||||
// ASSERT STATES
|
||||
val viewerFlow = viewModel.currentViewer.testIn(backgroundScope)
|
||||
|
@ -449,4 +449,8 @@ class ObjectStateSetViewTest : ObjectSetViewModelTestSetup() {
|
|||
assertIs<DataViewViewState.Set.NoItems>(item)
|
||||
assertTrue(item.isCreateObjectAllowed)
|
||||
}
|
||||
|
||||
private fun proceedWithStartingViewModel() {
|
||||
viewModel.onStart(ctx = root, space = defaultSpace)
|
||||
}
|
||||
}
|
|
@ -152,7 +152,7 @@ class BlockReadModeTest : EditorViewModelTest() {
|
|||
stubOpenPage()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -210,7 +210,7 @@ class BlockReadModeTest : EditorViewModelTest() {
|
|||
stubOpenPage()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -244,7 +244,7 @@ class BlockReadModeTest : EditorViewModelTest() {
|
|||
stubOpenPage()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -304,7 +304,7 @@ class BlockReadModeTest : EditorViewModelTest() {
|
|||
stubOpenPage()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -341,7 +341,7 @@ class BlockReadModeTest : EditorViewModelTest() {
|
|||
stubOpenPage()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ class DataViewBlockTargetObjectSetTest : EditorPresentationTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
assertEquals(
|
||||
expected = state,
|
||||
|
@ -158,7 +158,7 @@ class DataViewBlockTargetObjectSetTest : EditorPresentationTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
assertEquals(
|
||||
expected = state,
|
||||
|
@ -221,7 +221,7 @@ class DataViewBlockTargetObjectSetTest : EditorPresentationTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
assertEquals(
|
||||
expected = state,
|
||||
|
@ -284,7 +284,7 @@ class DataViewBlockTargetObjectSetTest : EditorPresentationTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
assertEquals(
|
||||
expected = state,
|
||||
|
@ -346,7 +346,7 @@ class DataViewBlockTargetObjectSetTest : EditorPresentationTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
assertEquals(
|
||||
expected = state,
|
||||
|
@ -400,7 +400,7 @@ class DataViewBlockTargetObjectSetTest : EditorPresentationTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
assertEquals(
|
||||
expected = state,
|
||||
|
@ -477,7 +477,7 @@ class DataViewBlockTargetObjectSetTest : EditorPresentationTestSetup() {
|
|||
)
|
||||
|
||||
// TESTING
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(DELAY)
|
||||
|
||||
|
|
|
@ -394,7 +394,7 @@ open class EditorViewModelTest {
|
|||
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes()
|
||||
|
||||
val spaceId = MockDataFactory.randomString()
|
||||
val defaultSpace = MockDataFactory.randomString()
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
|
@ -404,7 +404,7 @@ open class EditorViewModelTest {
|
|||
spaceManager.stub {
|
||||
onBlocking {
|
||||
get()
|
||||
} doReturn spaceId
|
||||
} doReturn defaultSpace
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,14 +425,14 @@ open class EditorViewModelTest {
|
|||
val param = OpenPage.Params(
|
||||
obj = root,
|
||||
saveAsLastOpened = true,
|
||||
space = SpaceId(spaceId)
|
||||
space = SpaceId(defaultSpace)
|
||||
)
|
||||
|
||||
stubInterceptEvents()
|
||||
givenViewModel()
|
||||
stubOpenPage(context = root)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
runBlockingTest { verify(openPage, times(1)).async(param) }
|
||||
}
|
||||
|
@ -471,7 +471,7 @@ open class EditorViewModelTest {
|
|||
|
||||
givenViewModel(builder)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val expected = ViewState.Success(
|
||||
blocks = listOf(
|
||||
|
@ -506,7 +506,7 @@ open class EditorViewModelTest {
|
|||
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
verifyNoInteractions(closePage)
|
||||
|
||||
|
@ -546,7 +546,7 @@ open class EditorViewModelTest {
|
|||
stubInterceptEvents()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val testObserver = vm.navigation.test()
|
||||
|
||||
|
@ -569,7 +569,7 @@ open class EditorViewModelTest {
|
|||
stubOpenPage(context = pageId)
|
||||
stubUpdateText()
|
||||
|
||||
vm.onStart(pageId)
|
||||
vm.onStart(id = pageId, space = defaultSpace)
|
||||
|
||||
val blockView = BlockView.Text.Paragraph(id = blockId, text = text)
|
||||
vm.onTextBlockTextChanged(blockView)
|
||||
|
@ -595,7 +595,7 @@ open class EditorViewModelTest {
|
|||
stubOpenPage(context = pageId)
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(pageId)
|
||||
vm.onStart(id = pageId, space = defaultSpace)
|
||||
|
||||
vm.onTextBlockTextChanged(
|
||||
BlockView.Text.Paragraph(
|
||||
|
@ -693,7 +693,7 @@ open class EditorViewModelTest {
|
|||
|
||||
stubOpenPage()
|
||||
givenViewModel(builder)
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(200)
|
||||
|
||||
|
@ -770,7 +770,7 @@ open class EditorViewModelTest {
|
|||
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onBlockFocusChanged(id = paragraph.id, hasFocus = true)
|
||||
|
||||
|
@ -831,7 +831,7 @@ open class EditorViewModelTest {
|
|||
stubOpenPage()
|
||||
givenViewModel(builder)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -875,7 +875,7 @@ open class EditorViewModelTest {
|
|||
|
||||
val testObserver = vm.state.test()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
testObserver.assertValue(ViewState.Loading)
|
||||
}
|
||||
|
@ -934,7 +934,7 @@ open class EditorViewModelTest {
|
|||
|
||||
givenViewModel(builder)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -1084,7 +1084,7 @@ open class EditorViewModelTest {
|
|||
stubOpenPage()
|
||||
givenViewModel(builder)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -1231,7 +1231,7 @@ open class EditorViewModelTest {
|
|||
stubOpenPage()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -1313,7 +1313,7 @@ open class EditorViewModelTest {
|
|||
|
||||
val testObserver = vm.state.test()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
testObserver.assertValue(ViewState.Loading)
|
||||
|
||||
|
@ -1410,7 +1410,7 @@ open class EditorViewModelTest {
|
|||
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -1501,7 +1501,7 @@ open class EditorViewModelTest {
|
|||
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -1563,7 +1563,7 @@ open class EditorViewModelTest {
|
|||
stubOpenPage()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(1001)
|
||||
|
||||
|
@ -1636,7 +1636,7 @@ open class EditorViewModelTest {
|
|||
|
||||
givenViewModel(builder)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(500)
|
||||
|
||||
|
@ -1730,7 +1730,7 @@ open class EditorViewModelTest {
|
|||
)
|
||||
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(1001)
|
||||
|
||||
|
@ -1798,7 +1798,7 @@ open class EditorViewModelTest {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -1875,7 +1875,7 @@ open class EditorViewModelTest {
|
|||
givenViewModel(builder)
|
||||
stubUnlinkBlocks(root)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(pageOpenedDelay)
|
||||
|
||||
|
@ -1993,7 +1993,7 @@ open class EditorViewModelTest {
|
|||
givenViewModel()
|
||||
stubUnlinkBlocks(root)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -2051,7 +2051,7 @@ open class EditorViewModelTest {
|
|||
stubObserveEvents(events)
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -2109,7 +2109,7 @@ open class EditorViewModelTest {
|
|||
stubCreateBlock(root)
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -2164,7 +2164,7 @@ open class EditorViewModelTest {
|
|||
|
||||
stubUpdateTextColor(root)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -2236,7 +2236,7 @@ open class EditorViewModelTest {
|
|||
stubCreateBlock(root)
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -2301,7 +2301,7 @@ open class EditorViewModelTest {
|
|||
stubUpdateTextStyle()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -2371,7 +2371,7 @@ open class EditorViewModelTest {
|
|||
stubUpdateText()
|
||||
stubSplitBlocks(root)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -2473,7 +2473,7 @@ open class EditorViewModelTest {
|
|||
stubUpdateText()
|
||||
stubSplitBlocks(root)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -2573,7 +2573,7 @@ open class EditorViewModelTest {
|
|||
|
||||
givenSharedFile()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -2630,7 +2630,7 @@ open class EditorViewModelTest {
|
|||
|
||||
stubDownloadFile()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -2700,7 +2700,7 @@ open class EditorViewModelTest {
|
|||
)
|
||||
}
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -2765,7 +2765,7 @@ open class EditorViewModelTest {
|
|||
)
|
||||
}
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -2819,7 +2819,7 @@ open class EditorViewModelTest {
|
|||
stubClosePage()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(300)
|
||||
|
||||
|
@ -2871,7 +2871,7 @@ open class EditorViewModelTest {
|
|||
givenViewModel()
|
||||
stubReplaceBlock(root)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -2940,7 +2940,7 @@ open class EditorViewModelTest {
|
|||
stubReplaceBlock(root)
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -3014,7 +3014,7 @@ open class EditorViewModelTest {
|
|||
stubUpdateText()
|
||||
stubReplaceBlock(root)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -3072,7 +3072,7 @@ open class EditorViewModelTest {
|
|||
stubOpenPage()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -3167,7 +3167,7 @@ open class EditorViewModelTest {
|
|||
stubOpenPage()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -3338,7 +3338,7 @@ open class EditorViewModelTest {
|
|||
stubOpenPage()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -3438,7 +3438,7 @@ open class EditorViewModelTest {
|
|||
givenViewModel()
|
||||
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
|
||||
val expected = listOf(
|
||||
|
@ -3513,7 +3513,7 @@ open class EditorViewModelTest {
|
|||
givenViewModel()
|
||||
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
|
||||
val expected = listOf(
|
||||
|
@ -3583,7 +3583,7 @@ open class EditorViewModelTest {
|
|||
givenViewModel()
|
||||
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
|
||||
val expected = listOf(
|
||||
|
@ -3687,7 +3687,7 @@ open class EditorViewModelTest {
|
|||
async(
|
||||
OpenPage.Params(
|
||||
obj = context,
|
||||
space = SpaceId(spaceId),
|
||||
space = SpaceId(defaultSpace),
|
||||
saveAsLastOpened = true
|
||||
)
|
||||
)
|
||||
|
@ -3968,7 +3968,7 @@ open class EditorViewModelTest {
|
|||
stubOpenPage()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -4071,7 +4071,7 @@ open class EditorViewModelTest {
|
|||
stubOpenPage()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -4178,7 +4178,7 @@ open class EditorViewModelTest {
|
|||
stubOpenPage()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
@ -4319,7 +4319,7 @@ open class EditorViewModelTest {
|
|||
stubOpenPage()
|
||||
givenViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
coroutineTestRule.advanceTime(100)
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class EditorBackButtonTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(document = doc)
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = child.id,
|
||||
hasFocus = true
|
||||
|
@ -251,7 +251,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = child2.id,
|
||||
hasFocus = true
|
||||
|
@ -384,7 +384,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = child2.id,
|
||||
hasFocus = true
|
||||
|
@ -488,7 +488,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = paragraph.id,
|
||||
hasFocus = true
|
||||
|
@ -587,7 +587,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = paragraph.id,
|
||||
hasFocus = true
|
||||
|
@ -658,7 +658,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = checkbox.id,
|
||||
hasFocus = true
|
||||
|
@ -703,7 +703,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = bulleted.id,
|
||||
hasFocus = true
|
||||
|
@ -748,7 +748,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = numbered.id,
|
||||
hasFocus = true
|
||||
|
@ -793,7 +793,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = toggle.id,
|
||||
hasFocus = true
|
||||
|
@ -838,7 +838,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = quote.id,
|
||||
hasFocus = true
|
||||
|
@ -889,7 +889,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = checkbox.id,
|
||||
hasFocus = true
|
||||
|
@ -973,7 +973,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = bulleted.id,
|
||||
hasFocus = true
|
||||
|
@ -1056,7 +1056,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = quote.id,
|
||||
hasFocus = true
|
||||
|
@ -1139,7 +1139,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = toggle.id,
|
||||
hasFocus = true
|
||||
|
@ -1222,7 +1222,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = numbered.id,
|
||||
hasFocus = true
|
||||
|
@ -1339,7 +1339,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = paragraph.id,
|
||||
hasFocus = true
|
||||
|
@ -1412,7 +1412,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = paragraph.id,
|
||||
hasFocus = true
|
||||
|
@ -1473,7 +1473,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = paragraph.id,
|
||||
hasFocus = true
|
||||
|
@ -1562,7 +1562,7 @@ class EditorBackspaceDeleteTest : EditorPresentationTestSetup() {
|
|||
// TESTING
|
||||
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = paragraph.id,
|
||||
hasFocus = true
|
||||
|
|
|
@ -50,7 +50,7 @@ class EditorBlockActionsTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
|
||||
// Simulating long tap on link block, in order to enter multi-select mode.
|
||||
|
@ -92,7 +92,7 @@ class EditorBlockActionsTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// Simulating long tap on "divider" block, in order to enter multi-select mode.
|
||||
|
||||
|
@ -134,7 +134,7 @@ class EditorBlockActionsTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// Simulating long tap on "p1" block, in order to enter multi-select mode.
|
||||
|
||||
|
@ -183,7 +183,7 @@ class EditorBlockActionsTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// Simulating long tap on "p1" block, in order to enter multi-select mode.
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ class EditorCheckboxTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onCheckboxClicked(view)
|
||||
|
||||
|
@ -136,7 +136,7 @@ class EditorCheckboxTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onCheckboxClicked(view)
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ class EditorCreateBlockTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
vm.onBlockFocusChanged(id = a.id, hasFocus = true)
|
||||
vm.onSelectionChanged(
|
||||
id = a.id,
|
||||
|
|
|
@ -73,7 +73,7 @@ class EditorDuplicateTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// Simulating long tap on "c" block, in order to enter multi-select mode.
|
||||
|
||||
|
@ -150,7 +150,7 @@ class EditorDuplicateTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// Simulating long tap on "c" block, in order to enter multi-select mode.
|
||||
|
||||
|
@ -298,7 +298,7 @@ class EditorDuplicateTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// Simulating long tap on "a" block, in order to enter in multi-select mode.
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ class EditorEmptySpaceInteractionTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -140,7 +140,7 @@ class EditorEmptySpaceInteractionTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -189,7 +189,7 @@ class EditorEmptySpaceInteractionTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root.id)
|
||||
vm.onStart(id = root.id, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -259,7 +259,7 @@ class EditorEmptySpaceInteractionTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// Checking that no text block is focused
|
||||
|
||||
|
@ -306,7 +306,7 @@ class EditorEmptySpaceInteractionTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -338,7 +338,7 @@ class EditorEmptySpaceInteractionTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -383,7 +383,7 @@ class EditorEmptySpaceInteractionTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class EditorErrorMessageTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
runBlockingTest {
|
||||
|
||||
|
|
|
@ -62,13 +62,13 @@ class EditorEventSubscriptionTest : EditorPresentationTestSetup() {
|
|||
|
||||
verifyNoInteractions(interceptEvents)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
verify(interceptEvents, times(1)).build(params)
|
||||
|
||||
vm.onStop()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
verify(interceptEvents, times(2)).build(params)
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val expected = listOf(
|
||||
BlockView.Title.Basic(
|
||||
|
@ -250,7 +250,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val expected =
|
||||
listOf(
|
||||
|
@ -352,7 +352,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val expected =
|
||||
listOf(
|
||||
|
@ -455,7 +455,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val expected = listOf(
|
||||
BlockView.Title.Basic(
|
||||
|
@ -576,7 +576,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val expected = listOf(
|
||||
BlockView.Title.Basic(
|
||||
|
@ -706,7 +706,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val expected = listOf(
|
||||
BlockView.Title.Basic(
|
||||
|
@ -830,7 +830,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val expected = listOf(
|
||||
BlockView.Title.Basic(
|
||||
|
@ -958,7 +958,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val expected = listOf(
|
||||
BlockView.Title.Basic(
|
||||
|
@ -1063,7 +1063,7 @@ class EditorFeaturedRelationsTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val expected = listOf(
|
||||
BlockView.Title.Basic(
|
||||
|
|
|
@ -97,7 +97,7 @@ class EditorFocusTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val testViewStateObserver = vm.state.test()
|
||||
|
||||
|
@ -150,7 +150,7 @@ class EditorFocusTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val testViewStateObserver = vm.state.test()
|
||||
val testFocusObserver = vm.focus.test()
|
||||
|
@ -189,7 +189,7 @@ class EditorFocusTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val testViewStateObserver = vm.state.test()
|
||||
val testFocusObserver = vm.focus.test()
|
||||
|
@ -250,7 +250,7 @@ class EditorFocusTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.state.test().apply {
|
||||
assertValue { value ->
|
||||
|
@ -319,7 +319,7 @@ class EditorFocusTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
vm.onSelectionChanged(
|
||||
id = paragraph.id,
|
||||
selection = IntRange(0, 0)
|
||||
|
@ -361,7 +361,7 @@ class EditorFocusTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING Click on text block
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = first.id,
|
||||
hasFocus = true
|
||||
|
@ -413,7 +413,7 @@ class EditorFocusTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING Click on title block
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = title.id,
|
||||
hasFocus = true
|
||||
|
@ -480,7 +480,7 @@ class EditorFocusTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING Click on cell block
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = cells[0].id,
|
||||
hasFocus = true
|
||||
|
|
|
@ -144,7 +144,7 @@ class EditorGranularChangeTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// Checking that checkbox is not checked
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
advanceUntilIdle()
|
||||
|
||||
|
@ -89,7 +89,7 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
advanceUntilIdle()
|
||||
|
||||
|
@ -135,7 +135,7 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
stubFileLimitEvents()
|
||||
stubSetInternalFlags()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
advanceUntilIdle()
|
||||
|
||||
|
@ -175,7 +175,7 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
stubFileLimitEvents()
|
||||
stubSetInternalFlags()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
advanceUntilIdle()
|
||||
|
||||
|
@ -215,7 +215,7 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
// stubFileLimitEvents()
|
||||
// stubSetInternalFlags()
|
||||
//
|
||||
// vm.onStart(root)
|
||||
// vm.onStart(id = root, space = defaultSpace)
|
||||
//
|
||||
// advanceUntilIdle()
|
||||
// vm.onObjectTypesWidgetDoneClicked()
|
||||
|
@ -267,7 +267,7 @@ class EditorInternalFlagsTest : EditorPresentationTestSetup() {
|
|||
stubFileLimitEvents()
|
||||
stubSetInternalFlags()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
advanceUntilIdle()
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ class EditorLatexBlockTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -137,7 +137,7 @@ class EditorLatexBlockTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onBlockFocusChanged(
|
||||
id = child,
|
||||
|
@ -159,7 +159,7 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onBlockFocusChanged(
|
||||
id = child,
|
||||
|
@ -228,7 +228,7 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onBlockFocusChanged(
|
||||
id = child,
|
||||
|
@ -293,7 +293,7 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onBlockFocusChanged(
|
||||
id = child,
|
||||
|
@ -369,7 +369,7 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onBlockFocusChanged(
|
||||
id = child,
|
||||
|
@ -496,7 +496,7 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onBlockFocusChanged(
|
||||
id = child,
|
||||
|
@ -642,7 +642,7 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onBlockFocusChanged(
|
||||
id = child,
|
||||
|
@ -769,7 +769,7 @@ class EditorListBlockTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onBlockFocusChanged(
|
||||
id = child,
|
||||
|
|
|
@ -89,7 +89,7 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val expected = listOf(
|
||||
BlockView.Title.Basic(
|
||||
|
@ -154,7 +154,7 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val expected = listOf(
|
||||
BlockView.Title.Basic(
|
||||
|
@ -219,7 +219,7 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val expected = listOf(
|
||||
BlockView.Title.Basic(
|
||||
|
@ -286,7 +286,7 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -325,7 +325,10 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
// checking navigation command
|
||||
|
||||
testObserver.assertValue { value ->
|
||||
value is EventWrapper && value.peekContent() == AppNavigation.Command.OpenObject(target)
|
||||
value is EventWrapper && value.peekContent() == AppNavigation.Command.OpenObject(
|
||||
target = target,
|
||||
space = defaultSpace
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,7 +391,7 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -436,7 +439,10 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
// checking navigation command
|
||||
|
||||
testObserver.assertValue { value ->
|
||||
value is EventWrapper && value.peekContent() == AppNavigation.Command.OpenObject(target)
|
||||
value is EventWrapper && value.peekContent() == AppNavigation.Command.OpenObject(
|
||||
target = target,
|
||||
space = defaultSpace
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -494,7 +500,7 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -603,7 +609,7 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -709,7 +715,7 @@ class EditorLockPageTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
|||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.ObjectTypeIds.PAGE
|
||||
import com.anytypeio.anytype.core_models.ext.content
|
||||
import com.anytypeio.anytype.presentation.BuildConfig
|
||||
import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
|
@ -16,7 +15,6 @@ import com.anytypeio.anytype.test_utils.MockDataFactory
|
|||
import com.jraska.livedata.test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.test.advanceUntilIdle
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import net.lachlanmckee.timberjunit.TimberTestRule
|
||||
|
@ -92,7 +90,7 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() {
|
|||
|
||||
//TESTING
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = block.id,
|
||||
hasFocus = true
|
||||
|
@ -239,7 +237,7 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() {
|
|||
|
||||
//TESTING
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = block.id,
|
||||
hasFocus = true
|
||||
|
@ -411,7 +409,7 @@ class EditorMarkupObjectTest : EditorPresentationTestSetup() {
|
|||
)
|
||||
stubGetDefaultObjectType(type = newObjectType)
|
||||
vm.apply {
|
||||
onStart(root)
|
||||
onStart(id = root, space = defaultSpace)
|
||||
onBlockFocusChanged(
|
||||
id = block.id,
|
||||
hasFocus = true
|
||||
|
|
|
@ -8,14 +8,11 @@ import com.anytypeio.anytype.core_models.Event
|
|||
import com.anytypeio.anytype.core_models.ObjectTypeIds
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.ext.content
|
||||
import com.anytypeio.anytype.core_models.primitives.TypeId
|
||||
import com.anytypeio.anytype.core_models.primitives.TypeKey
|
||||
import com.anytypeio.anytype.domain.base.Either
|
||||
import com.anytypeio.anytype.domain.base.Result
|
||||
import com.anytypeio.anytype.domain.base.Resultat
|
||||
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
||||
import com.anytypeio.anytype.domain.icon.DocumentEmojiIconProvider
|
||||
import com.anytypeio.anytype.domain.page.CreateObjectAsMentionOrLink
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
||||
import com.anytypeio.anytype.presentation.editor.editor.control.ControlPanelState
|
||||
import com.anytypeio.anytype.presentation.editor.editor.mention.MentionConst.MENTION_TITLE_EMPTY
|
||||
|
@ -44,7 +41,6 @@ import org.mockito.kotlin.doReturn
|
|||
import org.mockito.kotlin.stub
|
||||
import org.mockito.kotlin.times
|
||||
import org.mockito.kotlin.verify
|
||||
import org.mockito.kotlin.verifyBlocking
|
||||
import org.mockito.kotlin.verifyNoInteractions
|
||||
|
||||
class EditorMentionTest : EditorPresentationTestSetup() {
|
||||
|
@ -176,7 +172,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.apply {
|
||||
onBlockFocusChanged(
|
||||
|
@ -331,7 +327,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.apply {
|
||||
onBlockFocusChanged(
|
||||
|
@ -478,7 +474,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.apply {
|
||||
onBlockFocusChanged(
|
||||
|
@ -584,7 +580,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.apply {
|
||||
onBlockFocusChanged(
|
||||
|
@ -686,7 +682,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
//TESTING
|
||||
|
||||
|
@ -861,7 +857,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
|
||||
verifyNoInteractions(interceptEvents)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val actual = vm.state.value
|
||||
val expected = ViewState.Success(
|
||||
|
@ -1004,7 +1000,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
|
||||
verifyNoInteractions(interceptEvents)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val actual = vm.state.value
|
||||
val expected = ViewState.Success(
|
||||
|
@ -1116,7 +1112,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.apply {
|
||||
onBlockFocusChanged(
|
||||
|
|
|
@ -58,8 +58,6 @@ class EditorMenuTest : EditorPresentationTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val space = MockDataFactory.randomUuid()
|
||||
|
||||
val doc = page(root)
|
||||
|
||||
val details = Block.Details(
|
||||
|
@ -67,7 +65,7 @@ class EditorMenuTest : EditorPresentationTestSetup() {
|
|||
root to Block.Fields(
|
||||
mapOf(
|
||||
Relations.ID to root,
|
||||
Relations.SPACE_ID to space
|
||||
Relations.SPACE_ID to defaultSpace
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -77,15 +75,15 @@ class EditorMenuTest : EditorPresentationTestSetup() {
|
|||
stubOpenDocument(
|
||||
document = doc,
|
||||
details = details,
|
||||
spaceId = SpaceId(space)
|
||||
spaceId = SpaceId(defaultSpace)
|
||||
)
|
||||
stubSpaceManager(space = space)
|
||||
stubSpaceManager(space = defaultSpace)
|
||||
|
||||
val vm = buildViewModel()
|
||||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val observer = vm.commands.test()
|
||||
|
||||
|
@ -99,7 +97,7 @@ class EditorMenuTest : EditorPresentationTestSetup() {
|
|||
isFavorite = false,
|
||||
isLocked = false,
|
||||
isTemplate = false,
|
||||
space = space,
|
||||
space = defaultSpace,
|
||||
ctx = root
|
||||
)
|
||||
}
|
||||
|
@ -110,7 +108,7 @@ class EditorMenuTest : EditorPresentationTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val space = MockDataFactory.randomUuid()
|
||||
val space = defaultSpace
|
||||
|
||||
val details = Block.Details(
|
||||
mapOf(
|
||||
|
@ -140,7 +138,7 @@ class EditorMenuTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val observer = vm.commands.test()
|
||||
|
||||
|
@ -188,7 +186,7 @@ class EditorMenuTest : EditorPresentationTestSetup() {
|
|||
|
||||
// SETUP
|
||||
|
||||
val space = MockDataFactory.randomUuid()
|
||||
val space = defaultSpace
|
||||
|
||||
val doc = page(root)
|
||||
|
||||
|
@ -221,7 +219,7 @@ class EditorMenuTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val observer = vm.commands.test()
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class EditorMergeTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onBlockFocusChanged(
|
||||
id = second.id,
|
||||
|
@ -175,7 +175,7 @@ class EditorMergeTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onBlockFocusChanged(b.id, true)
|
||||
|
||||
|
@ -282,7 +282,7 @@ class EditorMergeTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onBlockFocusChanged(d.id, true)
|
||||
|
||||
|
@ -345,7 +345,7 @@ class EditorMergeTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onBlockFocusChanged(b.id, true)
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -422,7 +422,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -654,7 +654,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -734,7 +734,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -809,7 +809,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// Simulating long tap on "b" block, in order to enter multi-select mode.
|
||||
|
||||
|
@ -884,7 +884,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
|
|||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// Selecting blocks "a", "b" and "c"
|
||||
|
||||
|
@ -1025,7 +1025,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.apply {
|
||||
onClickListener(ListenerType.LongClick(target = a.id))
|
||||
|
@ -1098,7 +1098,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.apply {
|
||||
onClickListener(ListenerType.LongClick(target = a.id))
|
||||
|
@ -1146,7 +1146,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.apply {
|
||||
onClickListener(ListenerType.LongClick(target = a.id))
|
||||
|
@ -1195,7 +1195,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.apply {
|
||||
onClickListener(ListenerType.LongClick(target = a.id))
|
||||
|
@ -1243,7 +1243,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.apply {
|
||||
onClickListener(ListenerType.LongClick(target = a.id))
|
||||
|
@ -1323,7 +1323,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -1374,7 +1374,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onClickListener(ListenerType.LongClick(target = table.id))
|
||||
|
||||
|
@ -1412,7 +1412,7 @@ class EditorMultiSelectModeTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
vm.onClickListener(ListenerType.CellLongClick(tableId = table.id))
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ class EditorNoteLayoutTest : EditorPresentationTestSetup() {
|
|||
|
||||
val vm = buildViewModel()
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val expected = listOf(
|
||||
BlockView.FeaturedRelation(
|
||||
|
@ -259,7 +259,7 @@ class EditorNoteLayoutTest : EditorPresentationTestSetup() {
|
|||
val vm = buildViewModel()
|
||||
storeOfRelations.merge(objectRelations)
|
||||
|
||||
vm.onStart(root)
|
||||
vm.onStart(id = root, space = defaultSpace)
|
||||
|
||||
val expected = listOf(
|
||||
BlockView.FeaturedRelation(
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue