1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-1163 MW | Integrate 0.26.0-rc9 (#3096)

* DROID-1163 proto

* DROID-1163 version

* DROID-1163 objectToCollection useCase

* DROID-1163 smartBlockTypes, legacy

* DROID-1163 open object, off

* DROID-1163 tests fix
This commit is contained in:
Konstantin Ivanov 2023-04-17 17:45:52 +02:00 committed by GitHub
parent 477512ab3f
commit 8ef6744eb8
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 60 additions and 69 deletions

View file

@ -139,7 +139,7 @@ class ObjectSetGridColumnRenderingTest : TestObjectSetSetup() {
val root = Block(
id = ctx,
fields = Block.Fields(emptyMap()),
content = Block.Content.Smart(SmartBlockType.SET),
content = Block.Content.Smart(),
children = listOf(header.id, dataview.id)
)

View file

@ -148,7 +148,7 @@ class ObjectSetGridFileCellRenderingTest : TestObjectSetSetup() {
val root = Block(
id = ctx,
fields = Block.Fields(emptyMap()),
content = Block.Content.Smart(SmartBlockType.SET),
content = Block.Content.Smart(),
children = listOf(header.id, dataview.id)
)

View file

@ -114,7 +114,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
val root = Block(
id = ctx,
fields = Block.Fields(emptyMap()),
content = Block.Content.Smart(SmartBlockType.SET),
content = Block.Content.Smart(),
children = listOf(header.id, dataview.id)
)
@ -210,7 +210,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
val root = Block(
id = ctx,
fields = Block.Fields(emptyMap()),
content = Block.Content.Smart(SmartBlockType.SET),
content = Block.Content.Smart(),
children = listOf(header.id, dataview.id)
)
@ -306,7 +306,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
val root = Block(
id = ctx,
fields = Block.Fields(emptyMap()),
content = Block.Content.Smart(SmartBlockType.SET),
content = Block.Content.Smart(),
children = listOf(header.id, dataview.id)
)
@ -402,7 +402,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
val root = Block(
id = ctx,
fields = Block.Fields(emptyMap()),
content = Block.Content.Smart(SmartBlockType.SET),
content = Block.Content.Smart(),
children = listOf(header.id, dataview.id)
)
@ -498,7 +498,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
val root = Block(
id = ctx,
fields = Block.Fields(emptyMap()),
content = Block.Content.Smart(SmartBlockType.SET),
content = Block.Content.Smart(),
children = listOf(header.id, dataview.id)
)
@ -594,7 +594,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
val root = Block(
id = ctx,
fields = Block.Fields(emptyMap()),
content = Block.Content.Smart(SmartBlockType.SET),
content = Block.Content.Smart(),
children = listOf(header.id, dataview.id)
)

View file

@ -147,7 +147,7 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() {
val root = Block(
id = ctx,
fields = Block.Fields(emptyMap()),
content = Block.Content.Smart(SmartBlockType.SET),
content = Block.Content.Smart(),
children = listOf(header.id, dataview.id)
)
@ -263,7 +263,7 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() {
val root = Block(
id = ctx,
fields = Block.Fields(emptyMap()),
content = Block.Content.Smart(SmartBlockType.SET),
content = Block.Content.Smart(),
children = listOf(header.id, dataview.id)
)

View file

@ -179,7 +179,7 @@ class ObjectSetGridPrimitiveRelationTest : TestObjectSetSetup() {
val root = Block(
id = ctx,
fields = Block.Fields(emptyMap()),
content = Block.Content.Smart(SmartBlockType.SET),
content = Block.Content.Smart(),
children = listOf(header.id, dataview.id)
)

View file

@ -142,7 +142,7 @@ class ObjectSetGridTagCellRenderingTest : TestObjectSetSetup() {
val root = Block(
id = ctx,
fields = Block.Fields(emptyMap()),
content = Block.Content.Smart(SmartBlockType.SET),
content = Block.Content.Smart(),
children = listOf(header.id, dataview.id)
)

View file

@ -69,7 +69,7 @@ class ObjectSetHeaderTest : TestObjectSetSetup() {
val root = Block(
id = ctx,
fields = Block.Fields(emptyMap()),
content = Block.Content.Smart(SmartBlockType.SET),
content = Block.Content.Smart(SmartBlockType.PAGE),
children = listOf(header.id, dataview.id)
)

View file

@ -2,28 +2,19 @@ package com.anytypeio.anytype.core_models
enum class SmartBlockType(val code: Int) {
ACCOUNT_OLD(code = 0),
BREADCRUMBS(code = 1),
PAGE(code = 16),
PROFILE_PAGE(code = 17),
HOME(code = 32),
ARCHIVE(code = 48),
DATABASE(code = 64),
SET(code = 65),
COLLECTION(code = 66),
CUSTOM_OBJECT_TYPE(code = 96),
FILE(code = 256),
TEMPLATE(code = 288),
BUNDLED_TEMPLATE(code = 289),
MARKETPLACE_TYPE(code = 272),
MARKETPLACE_RELATION(code = 273),
MARKETPLACE_TEMPLATE(code = 274),
@Deprecated("")
BUNDLED_RELATION(code = 512),
SUB_OBJECT(code = 513),
BUNDLED_OBJECT_TYPE(code = 514),
ANYTYPE_PROFILE(code = 515),
DATE(code = 516),
WORKSPACE_OLD(code = 517),
WORKSPACE(code = 518),
WIDGET(code = 112),
MISSING_OBJECT(code = 519)

View file

@ -541,8 +541,8 @@ class BlockDataRepository(
return remote.objectToSet(ctx, source)
}
override suspend fun objectToCollection(ctx: Id): Id {
return remote.objectToCollection(ctx)
override suspend fun objectToCollection(ctx: Id) {
remote.objectToCollection(ctx)
}
override suspend fun clearBlockContent(ctx: Id, blockIds: List<Id>): Payload {

View file

@ -226,7 +226,7 @@ interface BlockDataStore {
suspend fun fillTableRow(ctx: String, targetIds: List<String>): Payload
suspend fun objectToSet(ctx: Id, source: List<String>): Id
suspend fun objectToCollection(ctx: Id): Id
suspend fun objectToCollection(ctx: Id)
suspend fun blockDataViewSetSource(ctx: Id, block: Id, sources: List<String>): Payload

View file

@ -225,7 +225,7 @@ interface BlockRemote {
suspend fun fillTableRow(ctx: String, targetIds: List<String>): Payload
suspend fun objectToSet(ctx: Id, source: List<String>): Id
suspend fun objectToCollection(ctx: Id): Id
suspend fun objectToCollection(ctx: Id)
suspend fun blockDataViewSetSource(ctx: Id, block: Id, sources: List<String>): Payload

View file

@ -469,8 +469,8 @@ class BlockRemoteDataStore(private val remote: BlockRemote) : BlockDataStore {
return remote.objectToSet(ctx, source)
}
override suspend fun objectToCollection(ctx: Id): Id {
return remote.objectToCollection(ctx)
override suspend fun objectToCollection(ctx: Id) {
remote.objectToCollection(ctx)
}
override suspend fun blockDataViewSetSource(

View file

@ -276,7 +276,7 @@ interface BlockRepository {
suspend fun fillTableRow(ctx: String, targetIds: List<String>): Payload
suspend fun objectToSet(ctx: Id, source: List<String>): Id
suspend fun objectToCollection(ctx: Id): Id
suspend fun objectToCollection(ctx: Id)
suspend fun blockDataViewSetSource(ctx: Id, block: Id, sources: List<String>): Payload

View file

@ -8,10 +8,9 @@ import com.anytypeio.anytype.domain.block.repo.BlockRepository
class ConvertObjectToCollection(
private val repo: BlockRepository,
dispatchers: AppCoroutineDispatchers
) : ResultInteractor<ConvertObjectToCollection.Params, Id>(dispatchers.io) {
) : ResultInteractor<ConvertObjectToCollection.Params, Unit>(dispatchers.io) {
override suspend fun doWork(params: Params): Id =
repo.objectToCollection(ctx = params.ctx)
override suspend fun doWork(params: Params) = repo.objectToCollection(ctx = params.ctx)
data class Params(val ctx: Id)
}

View file

@ -1,5 +1,5 @@
[versions]
middlewareVersion = "v0.26.0-rc6"
middlewareVersion = "v0.26.0-rc9"
kotlinVersion = '1.7.10'
androidxCoreVersion = "1.9.0"
androidxComposeVersion1 = '1.3.1'

View file

@ -501,8 +501,8 @@ class BlockMiddleware(
return middleware.objectToSet(ctx, source)
}
override suspend fun objectToCollection(ctx: Id): Id {
return middleware.objectToCollection(ctx)
override suspend fun objectToCollection(ctx: Id) {
middleware.objectToCollection(ctx)
}
override suspend fun blockDataViewSetSource(

View file

@ -1633,14 +1633,13 @@ class Middleware(
}
@Throws(Exception::class)
fun objectToCollection(ctx: Id): String {
fun objectToCollection(ctx: Id) {
val request = Rpc.Object.ToCollection.Request(
contextId = ctx
)
if (BuildConfig.DEBUG) logRequest(request)
val response = service.objectToCollection(request)
if (BuildConfig.DEBUG) logResponse(response)
return response.collectionId
}
@Throws(Exception::class)

View file

@ -687,19 +687,12 @@ fun ObjectInfo.toCoreModel(): DocumentInfo = DocumentInfo(
)
fun MSmartBlockType.toCoreModel(): SmartBlockType = when (this) {
MSmartBlockType.Breadcrumbs -> SmartBlockType.BREADCRUMBS
MSmartBlockType.Page -> SmartBlockType.PAGE
MSmartBlockType.ProfilePage -> SmartBlockType.PROFILE_PAGE
MSmartBlockType.Home -> SmartBlockType.HOME
MSmartBlockType.Archive -> SmartBlockType.ARCHIVE
MSmartBlockType.Database -> SmartBlockType.DATABASE
MSmartBlockType.Set -> SmartBlockType.SET
MSmartBlockType.STObjectType -> SmartBlockType.CUSTOM_OBJECT_TYPE
MSmartBlockType.File -> SmartBlockType.FILE
MSmartBlockType.Template -> SmartBlockType.TEMPLATE
MSmartBlockType.MarketplaceType -> SmartBlockType.MARKETPLACE_TYPE
MSmartBlockType.MarketplaceRelation -> SmartBlockType.MARKETPLACE_RELATION
MSmartBlockType.MarketplaceTemplate -> SmartBlockType.MARKETPLACE_TEMPLATE
MSmartBlockType.BundledRelation -> SmartBlockType.BUNDLED_RELATION
MSmartBlockType.SubObject -> SmartBlockType.SUB_OBJECT
MSmartBlockType.BundledObjectType -> SmartBlockType.BUNDLED_OBJECT_TYPE
@ -707,10 +700,8 @@ fun MSmartBlockType.toCoreModel(): SmartBlockType = when (this) {
MSmartBlockType.BundledTemplate -> SmartBlockType.BUNDLED_TEMPLATE
MSmartBlockType.Date -> SmartBlockType.DATE
MSmartBlockType.Workspace -> SmartBlockType.WORKSPACE
MSmartBlockType.WorkspaceOld -> SmartBlockType.WORKSPACE_OLD
MSmartBlockType.AccountOld -> SmartBlockType.ACCOUNT_OLD
MSmartBlockType.Widget -> SmartBlockType.WIDGET
MSmartBlockType.Collection -> SmartBlockType.COLLECTION
MSmartBlockType.MissingObject -> SmartBlockType.MISSING_OBJECT
}

View file

@ -4314,8 +4314,8 @@ class EditorViewModel(
val params = ConvertObjectToCollection.Params(ctx = context)
objectToCollection.execute(params).fold(
onFailure = { error -> Timber.e(error, "Error convert object to collection") },
onSuccess = { setId ->
proceedWithOpeningDataViewObject(target = setId, isPopUpToDashboard = true)
onSuccess = {
//proceedWithOpeningDataViewObject(target = setId, isPopUpToDashboard = true)
}
)
}

View file

@ -1192,14 +1192,14 @@ class ObjectSetViewModel(
viewModelScope.launch {
objectToCollection.execute(params).fold(
onFailure = { error -> Timber.e(error, "Error convert object to collection") },
onSuccess = { setId ->
onSuccess = {
logEvent(
state = stateReducer.state.value,
analytics = analytics,
event = ObjectStateAnalyticsEvent.TURN_INTO_COLLECTION,
startTime = startTime
)
proceedWithOpeningCollection(target = setId)
//proceedWithOpeningCollection(target = setId)
}
)
}

View file

@ -28,7 +28,7 @@ object MockObjectTypes {
id = SET,
name = "Set",
objectType = OBJECT_TYPE,
smartBlockTypes = listOf(SmartBlockType.SET.code.toDouble()),
smartBlockTypes = listOf(),
layout = ObjectType.Layout.OBJECT_TYPE.code.toDouble(),
description = "Set of objects with equal types and relations. Database experience based on all objects in Anytype",
isReadOnly = true
@ -38,7 +38,7 @@ object MockObjectTypes {
id = COLLECTION,
name = "Collection",
objectType = OBJECT_TYPE,
smartBlockTypes = listOf(SmartBlockType.COLLECTION.code.toDouble()),
smartBlockTypes = listOf(),
layout = ObjectType.Layout.OBJECT_TYPE.code.toDouble(),
description = "Collection of objects with equal types and relations. Database experience based on all objects in Anytype",
isReadOnly = true
@ -138,7 +138,6 @@ object MockObjectTypes {
name = "Type",
objectType = OBJECT_TYPE,
smartBlockTypes = listOf(
SmartBlockType.CUSTOM_OBJECT_TYPE.code.toDouble(),
SmartBlockType.BUNDLED_OBJECT_TYPE.code.toDouble()
),
layout = ObjectType.Layout.OBJECT_TYPE.code.toDouble(),

View file

@ -249,7 +249,7 @@ open class ObjectSetViewModelTestSetup {
relations = relations,
objectTypes = objectTypes,
dataViewRestrictions = dataViewRestrictions,
type = SmartBlockType.SET
type = SmartBlockType.PAGE
)
) + additionalEvents
)

View file

@ -1601,7 +1601,6 @@ message Rpc {
message Response {
Error error = 1;
string collectionId = 2;
message Error {
Code code = 1;

View file

@ -29,6 +29,8 @@ message Event {
Object.Remove objectRemove = 54;
Object.Restrictions.Set objectRestrictionsSet = 55;
Object.Subscription.Add subscriptionAdd = 60;
Object.Subscription.Remove subscriptionRemove = 61;
Object.Subscription.Position subscriptionPosition = 62;
@ -205,9 +207,11 @@ message Event {
repeated string ids = 1;
}
message Restriction {
string id = 1;
anytype.model.Restrictions restrictions = 2;
message Restrictions {
message Set {
string id = 1;
anytype.model.Restrictions restrictions = 2;
}
}
}
message Block {

View file

@ -17,17 +17,12 @@ message SmartBlockSnapshotBase {
}
enum SmartBlockType {
AccountOld = 0;
Breadcrumbs = 0x01;
AccountOld = 0; // deprecated
Page = 0x10;
ProfilePage = 0x11;
Home = 0x20;
Archive = 0x30;
Database = 0x40;
Set = 0x41; // only have dataview simpleblock
Collection = 0x42;
STObjectType = 0x60; // have relations list
Widget = 0x70;
File = 0x100;
@ -35,16 +30,11 @@ enum SmartBlockType {
Template = 0x120;
BundledTemplate = 0x121;
MarketplaceType = 0x110;
MarketplaceRelation = 0x111;
MarketplaceTemplate = 0x112;
BundledRelation = 0x200; // DEPRECATED
SubObject = 0x201;
BundledObjectType = 0x202;
AnytypeProfile = 0x203;
Date = 0x204;
WorkspaceOld = 0x205; // deprecated thread-based workspace
Workspace = 0x206;
MissingObject = 0x207;

View file

@ -0,0 +1,19 @@
syntax = "proto3";
package anytype;
option go_package = "pb";
import "models.proto";
import "changes.proto";
message SnapshotWithType {
anytype.model.SmartBlockType sbType = 1;
anytype.Change.Snapshot snapshot = 2;
}
message Profile {
string name = 1;
string avatar = 2;
string address = 4;
string spaceDashboardId = 5;
string profileId = 6;
}