Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-client-android
Commits
6692f34b
Commit
6692f34b
authored
4 months ago
by
Adrien Béraud
Committed by
Adrien Béraud
4 months ago
Browse files
Options
Downloads
Patches
Plain Diff
linkdevice: handle addDevice errors
Change-Id: I4b3e39cec92ab1ea2592ecfea1402646fe014096
parent
7883f09f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
jami-android/app/src/main/java/cx/ring/linkdevice/viewmodel/ExportSideViewModel.kt
+18
-14
18 additions, 14 deletions
.../java/cx/ring/linkdevice/viewmodel/ExportSideViewModel.kt
with
18 additions
and
14 deletions
jami-android/app/src/main/java/cx/ring/linkdevice/viewmodel/ExportSideViewModel.kt
+
18
−
14
View file @
6692f34b
...
@@ -55,6 +55,7 @@ class ExportSideViewModel @Inject constructor(
...
@@ -55,6 +55,7 @@ class ExportSideViewModel @Inject constructor(
private
val
_uiState
=
MutableStateFlow
<
AddDeviceExportState
>(
AddDeviceExportState
.
Init
())
private
val
_uiState
=
MutableStateFlow
<
AddDeviceExportState
>(
AddDeviceExportState
.
Init
())
val
uiState
:
StateFlow
<
AddDeviceExportState
>
=
_uiState
.
asStateFlow
()
val
uiState
:
StateFlow
<
AddDeviceExportState
>
=
_uiState
.
asStateFlow
()
private
val
accountId
=
accountService
.
currentAccount
!!
.
accountId
private
var
operationId
:
Long
?
=
null
private
var
operationId
:
Long
?
=
null
private
var
compositeDisposable
=
CompositeDisposable
()
private
var
compositeDisposable
=
CompositeDisposable
()
...
@@ -66,35 +67,39 @@ class ExportSideViewModel @Inject constructor(
...
@@ -66,35 +67,39 @@ class ExportSideViewModel @Inject constructor(
||
(
jamiAuthentication
.
length
!=
59
)
||
(
jamiAuthentication
.
length
!=
59
)
)
{
)
{
Log
.
w
(
TAG
,
"Invalid input: $jamiAuthentication"
)
Log
.
w
(
TAG
,
"Invalid input: $jamiAuthentication"
)
_uiState
.
value
=
// If state is unchanged, error is not emitted again.
AddDeviceExportState
.
Init
()
// If state is unchanged, error is not emitted again.
_uiState
.
value
=
AddDeviceExportState
.
Init
()
_uiState
.
value
=
AddDeviceExportState
.
Init
(
ExportSideInputError
.
INVALID_INPUT
)
_uiState
.
value
=
AddDeviceExportState
.
Init
(
ExportSideInputError
.
INVALID_INPUT
)
return
return
}
}
operationId
=
accountService
val
operationId
=
accountService
.
addDevice
(
accountId
,
jamiAuthentication
)
.
addDevice
(
accountService
.
currentAccount
!!
.
accountId
,
jamiAuthentication
)
if
(
operationId
<
0
)
{
Log
.
e
(
TAG
,
"Failed to add device: $jamiAuthentication $operationId"
)
_uiState
.
value
=
when
(
operationId
)
{
-
1L
->
AddDeviceExportState
.
Init
(
ExportSideInputError
.
INVALID_INPUT
)
else
->
AddDeviceExportState
.
Done
(
AuthError
.
UNKNOWN
)
}
return
}
this
.
operationId
=
operationId
assert
(
compositeDisposable
.
size
()
==
0
)
// Should not have any subscription.
assert
(
compositeDisposable
.
size
()
==
0
)
// Should not have any subscription.
accountService
.
authResultObservable
accountService
.
authResultObservable
.
filter
{
.
filter
{
it
.
accountId
==
accountId
&&
it
.
operationId
==
operationId
}
it
.
accountId
==
accountService
.
currentAccount
?.
accountId
&&
it
.
operationId
==
operationId
}
.
observeOn
(
mUiScheduler
)
.
observeOn
(
mUiScheduler
)
.
subscribe
{
it
:
AuthResult
->
.
subscribe
(
this
::
updateAuthState
)
updateAuthState
(
it
)
.
apply
{
compositeDisposable
.
add
(
this
)
}
}.
apply
{
compositeDisposable
.
add
(
this
)
}
}
}
fun
onIdentityConfirmation
()
{
fun
onIdentityConfirmation
()
{
accountService
.
confirmAddDevice
(
accountService
.
currentAccount
!!
.
accountId
,
operationId
!!
)
accountService
.
confirmAddDevice
(
accountId
,
operationId
!!
)
}
}
fun
onCancel
()
{
fun
onCancel
()
{
val
operationId
=
operationId
?:
return
val
operationId
=
operationId
?:
return
accountService
.
cancelAddDevice
(
accountService
.
currentAccount
!!
.
accountId
,
operationId
)
accountService
.
cancelAddDevice
(
accountId
,
operationId
)
}
}
// There is no token to be received in export side.
// There is no token to be received in export side.
...
@@ -103,7 +108,6 @@ class ExportSideViewModel @Inject constructor(
...
@@ -103,7 +108,6 @@ class ExportSideViewModel @Inject constructor(
}
}
override
fun
onConnectingSignal
()
{
override
fun
onConnectingSignal
()
{
// Nothing to do here.
_uiState
.
value
=
AddDeviceExportState
.
Connecting
_uiState
.
value
=
AddDeviceExportState
.
Connecting
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment