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

App | Tech | Update MW 0.28.2 (dirty) (#350)

This commit is contained in:
Konstantin Ivanov 2023-09-07 10:02:31 +02:00 committed by GitHub
parent 4b859336e2
commit f4e6d585b3
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 35 additions and 124 deletions

View file

@ -1,7 +1,3 @@
package com.anytypeio.anytype.core_models.exceptions
sealed class CreateAccountException : Exception() {
object BadInviteCode : CreateAccountException()
object NetworkError: CreateAccountException()
object OfflineDevice: CreateAccountException()
}
sealed class CreateAccountException : Exception()

View file

@ -1,5 +1,5 @@
[versions]
middlewareVersion = "v0.28.1"
middlewareVersion = "v0.28.2"
kotlinVersion = '1.7.10'
androidxCoreVersion = "1.10.1"

View file

@ -9,7 +9,7 @@ afterEvaluate {
artifact(file('lib.aar'))
groupId 'io.anyproto'
artifactId 'anytype-heart-android'
version = '2.3.0'
version = 'v0.28.2'
}
}
}

View file

@ -27,18 +27,7 @@ class MiddlewareServiceImplementation @Inject constructor(
val response = Rpc.Account.Create.Response.ADAPTER.decode(encoded)
val error = response.error
if (error != null && error.code != Rpc.Account.Create.Response.Error.Code.NULL) {
when (error.code) {
Rpc.Account.Create.Response.Error.Code.NET_OFFLINE -> {
throw CreateAccountException.OfflineDevice
}
Rpc.Account.Create.Response.Error.Code.BAD_INVITE_CODE -> {
throw CreateAccountException.BadInviteCode
}
Rpc.Account.Create.Response.Error.Code.NET_ERROR -> {
throw CreateAccountException.NetworkError
}
else -> throw Exception(error.description)
}
throw Exception(error.description)
} else {
return response
}

View file

@ -74,36 +74,11 @@ class SetupNewAccountViewModel(
) { result ->
result.either(
fnL = { error ->
when (error) {
CreateAccountException.BadInviteCode -> {
_state.postValue(SetupNewAccountViewState.InvalidCodeError("Invalid invitation code!"))
viewModelScope.launch {
delay(300)
navigation.postValue(EventWrapper(AppNavigation.Command.ExitToInvitationCodeScreen))
}
}
CreateAccountException.NetworkError -> {
_state.postValue(
SetupNewAccountViewState.ErrorNetwork(
"Failed to create your account due to a network error: ${error.message}"
)
)
}
CreateAccountException.OfflineDevice -> {
_state.postValue(
SetupNewAccountViewState.ErrorNetwork(
"Your device seems to be offline. Please, check your connection and try again."
)
)
}
else -> {
_state.postValue(
SetupNewAccountViewState.Error(
"Error while creating an account: ${error.message ?: "Unknown error"}"
)
)
}
}
_state.postValue(
SetupNewAccountViewState.Error(
"Error while creating an account: ${error.message ?: "Unknown error"}"
)
)
Timber.e(error, "Error while creating account")
},
fnR = {

View file

@ -88,20 +88,8 @@ class OnboardingVoidViewModel @Inject constructor(
) { result ->
result.either(
fnL = { error ->
Timber.d("Error while creating account: ${error.message ?: "Unknown error"}").also {
when(error) {
CreateAccountException.NetworkError -> {
sendToast(
"Failed to create your account due to a network error: ${error.message ?: "Unknown error"}"
)
}
CreateAccountException.OfflineDevice -> {
sendToast("Your device seems to be offline. Please, check your connection and try again.")
}
else -> {
sendToast("Error while creating an account: ${error.message ?: "Unknown error"}")
}
}
Timber.e(error, "Error while creating account").also {
sendToast("Error while creating an account: ${error.message ?: "Unknown error"}")
}
},
fnR = {

View file

@ -40,10 +40,6 @@ message Rpc {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
VERSION_IS_EMPTY = 3;
NOT_FOUND = 101;
TIMEOUT = 102;
}
}
}
@ -68,8 +64,6 @@ message Rpc {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
NODE_NOT_STARTED = 101;
}
}
@ -90,8 +84,6 @@ message Rpc {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
NODE_NOT_STARTED = 101;
}
}
@ -252,7 +244,7 @@ message Rpc {
option (no_auth) = true;
string name = 1; // Account name
oneof avatar {
oneof avatar { //TODO: Remove if not needed, GO-1926
string avatarLocalPath = 2; // Path to an image, that will be used as an avatar of this account
}
string storePath = 3; // Path to local storage
@ -266,7 +258,7 @@ message Rpc {
message Response {
Error error = 1; // Error while trying to create an account
anytype.model.Account account = 2; // A newly created account; In case of a failure, i.e. error is non-NULL, the account model should contain empty/default-value fields
Config config = 3; // deprecated, use account
Config config = 3; // deprecated, use account, GO-1926
message Error {
Code code = 1;
string description = 2;
@ -278,16 +270,9 @@ message Rpc {
ACCOUNT_CREATED_BUT_FAILED_TO_START_NODE = 101;
ACCOUNT_CREATED_BUT_FAILED_TO_SET_NAME = 102;
ACCOUNT_CREATED_BUT_FAILED_TO_SET_AVATAR = 103;
FAILED_TO_STOP_RUNNING_NODE = 104;
FAILED_TO_WRITE_CONFIG = 105;
FAILED_TO_CREATE_LOCAL_REPO = 106;
BAD_INVITE_CODE = 900;
NET_ERROR = 901; // means general network error
NET_CONNECTION_REFUSED = 902; // means we wasn't able to connect to the cafe server
NET_OFFLINE = 903; // client can additionally support this error code to notify user that device is offline
}
}
}
@ -315,14 +300,7 @@ message Rpc {
UNKNOWN_ERROR = 1; // Any other errors
BAD_INPUT = 2;
NO_ACCOUNTS_FOUND = 101;
NEED_TO_RECOVER_WALLET_FIRST = 102;
FAILED_TO_CREATE_LOCAL_REPO = 103;
LOCAL_REPO_EXISTS_BUT_CORRUPTED = 104;
FAILED_TO_RUN_NODE = 105;
WALLET_RECOVER_NOT_PERFORMED = 106;
FAILED_TO_STOP_RUNNING_NODE = 107;
ANOTHER_ANYTYPE_PROCESS_IS_RUNNING = 108;
}
}
}
@ -371,7 +349,7 @@ message Rpc {
message Response {
Error error = 1; // Error while trying to launch/select an account
anytype.model.Account account = 2; // Selected account
Config config = 3; // deprecated, use account
Config config = 3; // deprecated, use account, GO-1926
message Error {
Code code = 1;
string description = 2;
@ -387,11 +365,9 @@ message Rpc {
FAILED_TO_FIND_ACCOUNT_INFO = 104;
LOCAL_REPO_NOT_EXISTS_AND_MNEMONIC_NOT_SET = 105;
FAILED_TO_STOP_SEARCHER_NODE = 106;
FAILED_TO_RECOVER_PREDEFINED_BLOCKS = 107;
ANOTHER_ANYTYPE_PROCESS_IS_RUNNING = 108;
ACCOUNT_IS_DELETED = 109;
FAILED_TO_FETCH_REMOTE_NODE_HAS_INCOMPATIBLE_PROTO_VERSION = 110;
ACCOUNT_IS_DELETED = 111;
}
}
}
@ -478,7 +454,6 @@ message Rpc {
ACCOUNT_IS_NOT_RUNNING = 101;
FAILED_TO_WRITE_CONFIG = 102;
FAILED_TO_GET_CONFIG = 103;
}
}
}
@ -515,7 +490,7 @@ message Rpc {
}
}
message GetConfig {
message GetConfig { //TODO: Remove this request if we do not need it, GO-1926
message Get {
message Request {
}
@ -813,7 +788,7 @@ message Rpc {
message Close {
message Request {
string contextId = 1; // deprecated
string contextId = 1; // deprecated, GO-1926
string objectId = 2;
}
@ -836,7 +811,7 @@ message Rpc {
message Show {
message Request {
string contextId = 1; // deprecated
string contextId = 1; // deprecated, GO-1926
string objectId = 2;
string traceId = 3;
@ -1008,7 +983,6 @@ message Rpc {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
UNKNOWN_OBJECT_TYPE_URL = 3;
// ...
}
}
@ -1088,7 +1062,7 @@ message Rpc {
message OpenBreadcrumbs {
message Request {
string contextId = 1; // deprecated
string contextId = 1; // deprecated, GO-1926
string traceId = 2;
}
@ -1167,7 +1141,7 @@ message Rpc {
int32 offset = 4;
int32 limit = 5;
// additional filter by objectTypes
repeated string objectTypeFilter = 6; // DEPRECATED
repeated string objectTypeFilter = 6; // DEPRECATED, GO-1926
// needed keys in details for return, when empty - will return all
repeated string keys = 7;
}
@ -1195,7 +1169,7 @@ message Rpc {
repeated anytype.model.Block.Content.Dataview.Filter filters = 1;
int32 limit = 2;
// additional filter by objectTypes
repeated string objectTypeFilter = 3; // DEPRECATED
repeated string objectTypeFilter = 3; // DEPRECATED, GO-1926
repeated string keys = 4;
}
@ -1514,7 +1488,6 @@ message Rpc {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
UNKNOWN_OBJECT_TYPE_URL = 3;
}
}
}
@ -1538,7 +1511,6 @@ message Rpc {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
UNKNOWN_OBJECT_TYPE_URL = 3;
}
}
}
@ -1777,7 +1749,6 @@ message Rpc {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
UNKNOWN_OBJECT_TYPE_URL = 3;
}
}
}
@ -1942,10 +1913,9 @@ message Rpc {
enum Code {
NULL = 0;
INTERNAL_ERROR = 1;
UNKNOWN_ERROR = 2;
BAD_INPUT = 3;
ACCOUNT_IS_NOT_RUNNING = 4;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
INTERNAL_ERROR = 3;
NO_OBJECTS_TO_IMPORT = 5;
IMPORT_IS_CANCELED = 6;
LIMIT_OF_ROWS_OR_RELATIONS_EXCEEDED = 7;
@ -1968,10 +1938,10 @@ message Rpc {
enum Code {
NULL = 0;
INTERNAL_ERROR = 1;
UNAUTHORIZED = 2;
UNKNOWN_ERROR = 3;
BAD_INPUT = 4;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
INTERNAL_ERROR = 3;
UNAUTHORIZED = 4;
FORBIDDEN = 5;
SERVICE_UNAVAILABLE = 6;
ACCOUNT_IS_NOT_RUNNING = 7;
@ -1995,9 +1965,9 @@ message Rpc {
enum Code {
NULL = 0;
INTERNAL_ERROR = 1;
UNKNOWN_ERROR = 2;
BAD_INPUT = 3;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
INTERNAL_ERROR = 3;
}
}
@ -2022,6 +1992,7 @@ message Rpc {
PERSONAL_PROJECTS = 1;
KNOWLEDGE_BASE = 2;
NOTES_DIARY = 3;
STRATEGIC_WRITING = 4;
}
}
@ -2248,8 +2219,7 @@ message Rpc {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
UNKNOWN_OBJECT_TYPE_URL = 3;
READONLY_OBJECT_TYPE = 4;
READONLY_OBJECT_TYPE = 3;
// ...
}
}
@ -2272,8 +2242,7 @@ message Rpc {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
UNKNOWN_OBJECT_TYPE_URL = 3;
READONLY_OBJECT_TYPE = 4;
READONLY_OBJECT_TYPE = 3;
// ...
}
}
@ -2464,7 +2433,6 @@ message Rpc {
BAD_INPUT = 2;
// ...
NODE_NOT_STARTED = 103;
FILE_NOT_YET_PINNED = 104;
}
}
@ -2500,7 +2468,7 @@ message Rpc {
string url = 1;
string localPath = 2;
anytype.model.Block.Content.File.Type type = 3;
bool disableEncryption = 4; // deprecated, has no affect
bool disableEncryption = 4; // deprecated, has no affect, GO-1926
anytype.model.Block.Content.File.Style style = 5;
}
@ -2539,7 +2507,6 @@ message Rpc {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
NOT_FOUND = 3;
}
}
}
@ -4714,7 +4681,6 @@ message Rpc {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
NOT_A_DATAVIEW_BLOCK = 3;
// ...
}
}
@ -5526,9 +5492,6 @@ message Rpc {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
NOT_FOUND = 101;
TIMEOUT = 102;
}
}
}