Skip to content

Commit 6c68cd7

Browse files
author
Leandro Ferreira
committed
Choosing offline workspace
1 parent 918d20d commit 6c68cd7

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

application/features/auth/src/commonMain/kotlin/io/writeopia/auth/workspace/ChooseWorkspaceViewModel.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ class ChooseWorkspaceViewModel(
2121

2222
fun loadWorkspaces() {
2323
viewModelScope.launch {
24-
authRepository.getAuthToken()?.let { token ->
24+
val token = authRepository.getAuthToken()
25+
26+
if (token != null) {
2527
_workspacesState.value = ResultData.Loading()
2628
_workspacesState.value = workspaceApi.getAvailableWorkspaces(token)
29+
} else {
30+
_workspacesState.value = ResultData.Complete(
31+
listOf(Workspace.disconnectedWorkspace())
32+
)
2733
}
2834
}
2935
}

writeopia_models/src/commonMain/kotlin/io/writeopia/sdk/models/workspace/Workspace.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ data class Workspace(
1414
fun disconnectedWorkspace() = Workspace(
1515
id = "disconnected_workspace",
1616
userId = "disconnected_user",
17-
name = "",
17+
name = "Offline workspace",
1818
lastSync = Instant.Companion.DISTANT_PAST,
1919
selected = true,
2020
role = Role.ADMIN.value

0 commit comments

Comments
 (0)