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
7f80a50b
Commit
7f80a50b
authored
Mar 21, 2018
by
pancor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add save/get functions
parent
c9bb1e91
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
2 deletions
+30
-2
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+30
-2
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
7f80a50b
...
@@ -5,6 +5,7 @@ import chat.rocket.android.R
...
@@ -5,6 +5,7 @@ import chat.rocket.android.R
import
chat.rocket.android.chatroom.domain.UriInteractor
import
chat.rocket.android.chatroom.domain.UriInteractor
import
chat.rocket.android.chatroom.viewmodel.ViewModelMapper
import
chat.rocket.android.chatroom.viewmodel.ViewModelMapper
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.*
import
chat.rocket.android.server.domain.*
import
chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import
chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import
chat.rocket.android.server.infraestructure.state
import
chat.rocket.android.server.infraestructure.state
...
@@ -35,7 +36,8 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
...
@@ -35,7 +36,8 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
private
val
uriInteractor
:
UriInteractor
,
private
val
uriInteractor
:
UriInteractor
,
private
val
messagesRepository
:
MessagesRepository
,
private
val
messagesRepository
:
MessagesRepository
,
factory
:
ConnectionManagerFactory
,
factory
:
ConnectionManagerFactory
,
private
val
mapper
:
ViewModelMapper
)
{
private
val
mapper
:
ViewModelMapper
,
private
val
localRepository
:
LocalRepository
)
{
private
val
currentServer
=
serverInteractor
.
get
()
!!
private
val
currentServer
=
serverInteractor
.
get
()
!!
private
val
manager
=
factory
.
create
(
currentServer
)
private
val
manager
=
factory
.
create
(
currentServer
)
private
val
client
=
manager
.
client
private
val
client
=
manager
.
client
...
@@ -149,7 +151,7 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
...
@@ -149,7 +151,7 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
view
.
showMessage
(
ex
.
message
!!
)
// TODO Remove.
view
.
showMessage
(
ex
.
message
!!
)
// TODO Remove.
Timber
.
e
(
ex
)
// FIXME: Right now we are only catching the exception with Timber.
Timber
.
e
(
ex
)
// FIXME: Right now we are only catching the exception with Timber.
}
}
}
}
}
}
private
fun
subscribeState
()
{
private
fun
subscribeState
()
{
...
@@ -358,4 +360,30 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
...
@@ -358,4 +360,30 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
}
}
}
}
}
}
/**
* Save unfinished message, when user left chat room without sending a message.
*
* @param chatRoomId Chat room Id.
* @param unfinishedMessage The unfinished message to save.
*/
fun
saveUnfinishedMessage
(
chatRoomId
:
String
,
unfinishedMessage
:
String
)
{
if
(
unfinishedMessage
.
isNotBlank
())
{
val
key
=
LocalRepository
.
UNFINISHED_MSG_KEY
+
chatRoomId
localRepository
.
save
(
key
,
unfinishedMessage
)
}
}
/**
* Get unfinished message from local repository, when user left chat room without
* sending a message and now the user is back.
*
* @param chatRoomId Chat room Id.
*
* @return Returns the unfinished message.
*/
fun
getUnfinishedMessage
(
chatRoomId
:
String
):
String
{
val
key
=
LocalRepository
.
UNFINISHED_MSG_KEY
+
chatRoomId
return
localRepository
.
get
(
key
)
?:
""
}
}
}
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