Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
7f8b2e7d
Commit
7f8b2e7d
authored
Apr 02, 2018
by
Lucio Maciel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Logout on invalid token.
parent
ef31f2ef
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
16 deletions
+31
-16
MainPresenter.kt
...va/chat/rocket/android/main/presentation/MainPresenter.kt
+25
-10
NavHeaderViewModelMapper.kt
...rocket/android/main/viewmodel/NavHeaderViewModelMapper.kt
+5
-5
SettingsRepository.kt
...a/chat/rocket/android/server/domain/SettingsRepository.kt
+1
-1
No files found.
app/src/main/java/chat/rocket/android/main/presentation/MainPresenter.kt
View file @
7f8b2e7d
...
...
@@ -11,6 +11,7 @@ import chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.extensions.launchUI
import
chat.rocket.android.util.extensions.registerPushToken
import
chat.rocket.common.RocketChatAuthException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.RocketChatClient
...
...
@@ -55,6 +56,11 @@ class MainPresenter @Inject constructor(
saveAccount
(
model
)
view
.
setupNavHeader
(
model
,
getAccountsInteractor
.
get
())
}
catch
(
ex
:
Exception
)
{
when
(
ex
)
{
is
RocketChatAuthException
->
{
logout
()
}
else
->
{
Timber
.
d
(
ex
,
"Error loading my information for navheader"
)
ex
.
message
?.
let
{
view
.
showMessage
(
it
)
...
...
@@ -64,6 +70,8 @@ class MainPresenter @Inject constructor(
}
}
}
}
}
private
suspend
fun
saveAccount
(
me
:
NavHeaderViewModel
)
{
val
icon
=
settings
.
favicon
()
?.
let
{
...
...
@@ -81,17 +89,25 @@ class MainPresenter @Inject constructor(
try
{
clearTokens
()
client
.
logout
()
disconnect
()
removeAccountInterector
.
remove
(
currentServer
)
tokenRepository
.
remove
(
currentServer
)
navigator
.
toNewServer
()
}
catch
(
exception
:
RocketChatException
)
{
Timber
.
d
(
exception
,
"Error calling logout"
)
exception
.
message
?.
let
{
view
.
showMessage
(
it
)
}.
ifNull
{
view
.
showGenericErrorMessage
()
}
}
try
{
disconnect
()
removeAccountInterector
.
remove
(
currentServer
)
tokenRepository
.
remove
(
currentServer
)
navigator
.
toNewServer
()
}
catch
(
ex
:
Exception
)
{
Timber
.
d
(
ex
,
"Error cleaning up the session..."
)
}
navigator
.
toNewServer
()
}
}
...
...
@@ -100,7 +116,6 @@ class MainPresenter @Inject constructor(
val
pushToken
=
localRepository
.
get
(
LocalRepository
.
KEY_PUSH_TOKEN
)
if
(
pushToken
!=
null
)
{
client
.
unregisterPushToken
(
pushToken
)
localRepository
.
clear
(
LocalRepository
.
KEY_PUSH_TOKEN
)
}
localRepository
.
clearAllFromServer
(
currentServer
)
}
...
...
app/src/main/java/chat/rocket/android/main/viewmodel/NavHeaderViewModelMapper.kt
View file @
7f8b2e7d
...
...
@@ -7,16 +7,16 @@ import javax.inject.Inject
class
NavHeaderViewModelMapper
@Inject
constructor
(
serverInteractor
:
GetCurrentServerInteractor
,
getSettingsInteractor
:
GetSettingsInteractor
)
{
private
va
r
settings
:
PublicSettings
=
getSettingsInteractor
.
get
(
serverInteractor
.
get
()
!!
)
private
va
l
baseUrl
=
settings
.
baseUrl
()
!!
private
va
l
currentServer
=
serverInteractor
.
get
()
!!
private
va
r
settings
:
PublicSettings
=
getSettingsInteractor
.
get
(
currentServer
)
fun
mapToViewModel
(
me
:
Myself
):
NavHeaderViewModel
{
val
username
=
mapUsername
(
me
)
val
thumb
=
me
.
username
?.
let
{
UrlHelper
.
getAvatarUrl
(
baseUrl
,
it
)
}
val
thumb
=
me
.
username
?.
let
{
UrlHelper
.
getAvatarUrl
(
currentServer
,
it
)
}
val
image
=
settings
.
wideTile
()
?:
settings
.
faviconLarge
()
val
logo
=
image
?.
let
{
UrlHelper
.
getServerLogoUrl
(
baseUrl
,
it
)
}
val
logo
=
image
?.
let
{
UrlHelper
.
getServerLogoUrl
(
currentServer
,
it
)
}
return
NavHeaderViewModel
(
username
,
baseUrl
,
thumb
,
logo
)
return
NavHeaderViewModel
(
username
,
currentServer
,
thumb
,
logo
)
}
private
fun
mapUsername
(
me
:
Myself
):
String
{
...
...
app/src/main/java/chat/rocket/android/server/domain/SettingsRepository.kt
View file @
7f8b2e7d
...
...
@@ -95,5 +95,5 @@ fun PublicSettings.uploadMaxFileSize(): Int {
return
this
[
UPLOAD_MAX_FILE_SIZE
]
?.
value
?.
let
{
it
as
Int
}
?:
Int
.
MAX_VALUE
}
fun
PublicSettings
.
baseUrl
():
String
?
=
this
[
SITE_URL
]
?.
value
as
String
fun
PublicSettings
.
baseUrl
():
String
?
=
this
[
SITE_URL
]
?.
value
as
String
?
fun
PublicSettings
.
siteName
():
String
?
=
this
[
SITE_NAME
]
?.
value
as
String
?
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment