DROID-1504 App | Fix | Minor fixes based on reports from Sentry (#223)
This commit is contained in:
parent
1c3f1d1f20
commit
04ff6862e9
|
@ -9,65 +9,80 @@ class NavigationRouter(
|
|||
) {
|
||||
fun navigate(command: AppNavigation.Command) {
|
||||
Timber.d("Navigate to $command")
|
||||
try {
|
||||
when (command) {
|
||||
is AppNavigation.Command.StartSplashFromDesktop -> navigation.startSplashFromDesktop()
|
||||
is AppNavigation.Command.StartDesktopFromLogin -> navigation.startDesktopFromLogin()
|
||||
is AppNavigation.Command.StartDesktopFromSignUp -> navigation.startDesktopFromSignUp()
|
||||
is AppNavigation.Command.StartDesktopFromSplash -> navigation.startDesktopFromSplash()
|
||||
is AppNavigation.Command.ExitFromMigrationScreen -> navigation.exitFromMigrationScreen()
|
||||
is AppNavigation.Command.OpenCreateAccount -> navigation.createProfile(command.invitationCode)
|
||||
is AppNavigation.Command.ChoosePinCodeScreen -> navigation.choosePinCode()
|
||||
is AppNavigation.Command.EnterKeyChainScreen -> navigation.enterKeychain()
|
||||
is AppNavigation.Command.SelectAccountScreen -> navigation.chooseAccount()
|
||||
is AppNavigation.Command.WorkspaceScreen -> navigation.workspace()
|
||||
is AppNavigation.Command.InvitationCodeScreen -> navigation.enterInvitationCode()
|
||||
is AppNavigation.Command.AboutAnalyticsScreen -> navigation.aboutAnalyticsScreen()
|
||||
is AppNavigation.Command.ExitToInvitationCodeScreen -> navigation.exitToInvitationCodeScreen()
|
||||
is AppNavigation.Command.SetupNewAccountScreen -> navigation.setupNewAccount()
|
||||
is AppNavigation.Command.SetupSelectedAccountScreen -> navigation.setupSelectedAccount(
|
||||
command.id
|
||||
)
|
||||
|
||||
when (command) {
|
||||
is AppNavigation.Command.StartSplashFromDesktop -> navigation.startSplashFromDesktop()
|
||||
is AppNavigation.Command.StartDesktopFromLogin -> navigation.startDesktopFromLogin()
|
||||
is AppNavigation.Command.StartDesktopFromSignUp -> navigation.startDesktopFromSignUp()
|
||||
is AppNavigation.Command.StartDesktopFromSplash -> navigation.startDesktopFromSplash()
|
||||
is AppNavigation.Command.ExitFromMigrationScreen -> navigation.exitFromMigrationScreen()
|
||||
is AppNavigation.Command.OpenCreateAccount -> navigation.createProfile(command.invitationCode)
|
||||
is AppNavigation.Command.ChoosePinCodeScreen -> navigation.choosePinCode()
|
||||
is AppNavigation.Command.EnterKeyChainScreen -> navigation.enterKeychain()
|
||||
is AppNavigation.Command.SelectAccountScreen -> navigation.chooseAccount()
|
||||
is AppNavigation.Command.WorkspaceScreen -> navigation.workspace()
|
||||
is AppNavigation.Command.InvitationCodeScreen -> navigation.enterInvitationCode()
|
||||
is AppNavigation.Command.AboutAnalyticsScreen -> navigation.aboutAnalyticsScreen()
|
||||
is AppNavigation.Command.ExitToInvitationCodeScreen -> navigation.exitToInvitationCodeScreen()
|
||||
is AppNavigation.Command.SetupNewAccountScreen -> navigation.setupNewAccount()
|
||||
is AppNavigation.Command.SetupSelectedAccountScreen -> navigation.setupSelectedAccount(
|
||||
command.id
|
||||
)
|
||||
is AppNavigation.Command.ConfirmPinCodeScreen -> navigation.confirmPinCode(command.code)
|
||||
is AppNavigation.Command.OpenSettings -> navigation.openSettings()
|
||||
is AppNavigation.Command.OpenObject -> navigation.openDocument(command.id)
|
||||
is AppNavigation.Command.OpenSetOrCollection -> navigation.openObjectSet(
|
||||
command.target,
|
||||
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.LaunchObjectSetFromSplash -> navigation.launchObjectSetFromSplash(
|
||||
command.target
|
||||
)
|
||||
is AppNavigation.Command.OpenDatabaseViewAddView -> navigation.openDatabaseViewAddView()
|
||||
is AppNavigation.Command.OpenEditDatabase -> navigation.openEditDatabase()
|
||||
is AppNavigation.Command.OpenKeychainScreen -> navigation.openKeychainScreen()
|
||||
is AppNavigation.Command.OpenUserSettingsScreen -> navigation.openUserSettingsScreen()
|
||||
is AppNavigation.Command.OpenContactsScreen -> navigation.openContacts()
|
||||
is AppNavigation.Command.OpenSwitchDisplayView -> navigation.openSwitchDisplayView()
|
||||
is AppNavigation.Command.OpenCustomizeDisplayView -> navigation.openCustomizeDisplayView()
|
||||
is AppNavigation.Command.Exit -> navigation.exit()
|
||||
is AppNavigation.Command.ExitToDesktop -> navigation.exitToDesktop()
|
||||
is AppNavigation.Command.OpenDebugSettingsScreen -> navigation.openDebugSettings()
|
||||
is AppNavigation.Command.ExitToDesktopAndOpenPage -> navigation.exitToDesktopAndOpenPage(
|
||||
command.pageId
|
||||
)
|
||||
is AppNavigation.Command.OpenPageSearch -> navigation.openPageSearch()
|
||||
is AppNavigation.Command.OpenUpdateAppScreen -> navigation.openUpdateAppScreen()
|
||||
is AppNavigation.Command.DeletedAccountScreen -> navigation.deletedAccountScreen(command.deadline)
|
||||
is AppNavigation.Command.OpenTemplates -> navigation.openTemplates(
|
||||
ctx = command.ctx,
|
||||
type = command.type,
|
||||
templates = command.templates
|
||||
)
|
||||
is AppNavigation.Command.OpenLibrary -> navigation.openLibrary()
|
||||
is AppNavigation.Command.MigrationErrorScreen -> navigation.migrationErrorScreen()
|
||||
is AppNavigation.Command.OpenRemoteStorageScreen -> navigation.openRemoteStorageScreen(command.subscription)
|
||||
else -> Timber.d("Nav command ignored: $command")
|
||||
is AppNavigation.Command.ConfirmPinCodeScreen -> navigation.confirmPinCode(command.code)
|
||||
is AppNavigation.Command.OpenSettings -> navigation.openSettings()
|
||||
is AppNavigation.Command.OpenObject -> navigation.openDocument(command.id)
|
||||
is AppNavigation.Command.OpenSetOrCollection -> navigation.openObjectSet(
|
||||
command.target,
|
||||
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.LaunchObjectSetFromSplash -> navigation.launchObjectSetFromSplash(
|
||||
command.target
|
||||
)
|
||||
|
||||
is AppNavigation.Command.OpenDatabaseViewAddView -> navigation.openDatabaseViewAddView()
|
||||
is AppNavigation.Command.OpenEditDatabase -> navigation.openEditDatabase()
|
||||
is AppNavigation.Command.OpenKeychainScreen -> navigation.openKeychainScreen()
|
||||
is AppNavigation.Command.OpenUserSettingsScreen -> navigation.openUserSettingsScreen()
|
||||
is AppNavigation.Command.OpenContactsScreen -> navigation.openContacts()
|
||||
is AppNavigation.Command.OpenSwitchDisplayView -> navigation.openSwitchDisplayView()
|
||||
is AppNavigation.Command.OpenCustomizeDisplayView -> navigation.openCustomizeDisplayView()
|
||||
is AppNavigation.Command.Exit -> navigation.exit()
|
||||
is AppNavigation.Command.ExitToDesktop -> navigation.exitToDesktop()
|
||||
is AppNavigation.Command.OpenDebugSettingsScreen -> navigation.openDebugSettings()
|
||||
is AppNavigation.Command.ExitToDesktopAndOpenPage -> navigation.exitToDesktopAndOpenPage(
|
||||
command.pageId
|
||||
)
|
||||
|
||||
is AppNavigation.Command.OpenPageSearch -> navigation.openPageSearch()
|
||||
is AppNavigation.Command.OpenUpdateAppScreen -> navigation.openUpdateAppScreen()
|
||||
is AppNavigation.Command.DeletedAccountScreen -> navigation.deletedAccountScreen(
|
||||
command.deadline
|
||||
)
|
||||
|
||||
is AppNavigation.Command.OpenTemplates -> navigation.openTemplates(
|
||||
ctx = command.ctx,
|
||||
type = command.type,
|
||||
templates = command.templates
|
||||
)
|
||||
|
||||
is AppNavigation.Command.OpenLibrary -> navigation.openLibrary()
|
||||
is AppNavigation.Command.MigrationErrorScreen -> navigation.migrationErrorScreen()
|
||||
is AppNavigation.Command.OpenRemoteStorageScreen -> navigation.openRemoteStorageScreen(
|
||||
command.subscription
|
||||
)
|
||||
|
||||
else -> Timber.d("Nav command ignored: $command")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "Error while navigation")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -532,7 +532,7 @@
|
|||
<dialog
|
||||
android:id="@+id/relationCreationFragment"
|
||||
android:name="com.anytypeio.anytype.ui.relations.RelationCreateFromLibraryFragment"
|
||||
android:label="RelationCreationFragment"></dialog>
|
||||
android:label="RelationCreationFragment"/>
|
||||
|
||||
<dialog
|
||||
android:id="@+id/typeEditingFragment"
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.anytypeio.anytype.presentation.spaces.SpaceGradientProvider
|
|||
import com.anytypeio.anytype.presentation.spaces.SpaceIconView
|
||||
import com.anytypeio.anytype.presentation.spaces.spaceIcon
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
@ -44,43 +45,47 @@ class MainSettingsViewModel(
|
|||
val events = MutableSharedFlow<Event>(replay = 0)
|
||||
val commands = MutableSharedFlow<Command>(replay = 0)
|
||||
|
||||
private val profileId = configStorage.get().profile
|
||||
private val workspaceId = configStorage.get().workspace
|
||||
private val profileId = configStorage.getOrNull()?.profile
|
||||
private val workspaceId = configStorage.getOrNull()?.workspace
|
||||
|
||||
val workspaceAndAccount = storelessSubscriptionContainer.subscribe(
|
||||
StoreSearchByIdsParams(
|
||||
subscription = SPACE_STORAGE_SUBSCRIPTION_ID,
|
||||
targets = listOf(workspaceId, profileId),
|
||||
keys = listOf(
|
||||
Relations.ID,
|
||||
Relations.NAME,
|
||||
Relations.ICON_EMOJI,
|
||||
Relations.ICON_IMAGE,
|
||||
Relations.ICON_OPTION
|
||||
val workspaceAndAccount = if (workspaceId != null && profileId != null) {
|
||||
storelessSubscriptionContainer.subscribe(
|
||||
StoreSearchByIdsParams(
|
||||
subscription = SPACE_STORAGE_SUBSCRIPTION_ID,
|
||||
targets = listOf(workspaceId, profileId),
|
||||
keys = listOf(
|
||||
Relations.ID,
|
||||
Relations.NAME,
|
||||
Relations.ICON_EMOJI,
|
||||
Relations.ICON_IMAGE,
|
||||
Relations.ICON_OPTION
|
||||
)
|
||||
)
|
||||
).map { result ->
|
||||
val workspace = result.find { it.id == workspaceId }
|
||||
val profile = result.find { it.id == profileId }
|
||||
WorkspaceAndAccount.Account(
|
||||
space = workspace?.let {
|
||||
WorkspaceAndAccount.SpaceData(
|
||||
name = workspace.name ?: "",
|
||||
icon = workspace.spaceIcon(urlBuilder, spaceGradientProvider)
|
||||
)
|
||||
},
|
||||
profile = profile?.let {
|
||||
WorkspaceAndAccount.ProfileData(
|
||||
name = profile.name ?: "",
|
||||
icon = profile.profileIcon(urlBuilder, spaceGradientProvider)
|
||||
)
|
||||
}
|
||||
)
|
||||
}.stateIn(
|
||||
viewModelScope,
|
||||
SharingStarted.WhileSubscribed(STOP_SUBSCRIPTION_TIMEOUT),
|
||||
WorkspaceAndAccount.Idle
|
||||
)
|
||||
).map { result ->
|
||||
val workspace = result.find { it.id == workspaceId }
|
||||
val profile = result.find { it.id == profileId }
|
||||
WorkspaceAndAccount.Account(
|
||||
space = workspace?.let {
|
||||
WorkspaceAndAccount.SpaceData(
|
||||
name = workspace.name ?: "",
|
||||
icon = workspace.spaceIcon(urlBuilder, spaceGradientProvider)
|
||||
)
|
||||
},
|
||||
profile = profile?.let {
|
||||
WorkspaceAndAccount.ProfileData(
|
||||
name = profile.name ?: "",
|
||||
icon = profile.profileIcon(urlBuilder, spaceGradientProvider)
|
||||
)
|
||||
}
|
||||
)
|
||||
}.stateIn(
|
||||
viewModelScope,
|
||||
SharingStarted.WhileSubscribed(STOP_SUBSCRIPTION_TIMEOUT),
|
||||
WorkspaceAndAccount.Idle
|
||||
)
|
||||
} else {
|
||||
MutableStateFlow(WorkspaceAndAccount.Idle)
|
||||
}
|
||||
|
||||
init {
|
||||
events
|
||||
|
@ -104,14 +109,17 @@ class MainSettingsViewModel(
|
|||
proceedWithSpaceDebug()
|
||||
}
|
||||
Event.OnSpaceImageClicked -> {
|
||||
val showRemoveButton =
|
||||
(workspaceAndAccount.value as? WorkspaceAndAccount.Account)?.space?.icon !is SpaceIconView.Gradient
|
||||
commands.emit(
|
||||
Command.OpenSpaceImageSet(
|
||||
id = configStorage.get().workspace,
|
||||
showRemoveButton = showRemoveButton
|
||||
val config = configStorage.getOrNull()
|
||||
if (config != null) {
|
||||
commands.emit(
|
||||
Command.OpenSpaceImageSet(
|
||||
id = config.workspace,
|
||||
showRemoveButton = isShowRemoveButton()
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
commands.emit(Command.Toast(COULD_NOT_GET_CONFIG_ERROR))
|
||||
}
|
||||
}
|
||||
Event.OnFilesStorageClicked -> {
|
||||
commands.emit(Command.OpenFilesStorageScreen)
|
||||
|
@ -119,6 +127,11 @@ class MainSettingsViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
private fun isShowRemoveButton() : Boolean {
|
||||
return (workspaceAndAccount.value as? WorkspaceAndAccount.Account)
|
||||
?.space?.icon !is SpaceIconView.Gradient
|
||||
}
|
||||
|
||||
private fun proceedWithSpaceDebug() {
|
||||
viewModelScope.launch {
|
||||
debugSpaceShareDownloader
|
||||
|
@ -266,6 +279,7 @@ class MainSettingsViewModel(
|
|||
|
||||
companion object {
|
||||
const val SPACE_DEBUG_MSG = "Kindly share this debug logs with Anytype developers."
|
||||
const val COULD_NOT_GET_CONFIG_ERROR = "Could not get config. Please, try again later."
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user