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
2f5473a4
Commit
2f5473a4
authored
Dec 18, 2018
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat.Android into patch-1
parents
54e7b800
27b10078
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
113 additions
and
122 deletions
+113
-122
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+63
-58
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+0
-2
UiModelMapper.kt
...ava/chat/rocket/android/chatroom/uimodel/UiModelMapper.kt
+1
-1
UserDetailsPresenter.kt
.../android/userdetails/presentation/UserDetailsPresenter.kt
+49
-61
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
2f5473a4
...
@@ -132,6 +132,8 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -132,6 +132,8 @@ class ChatRoomPresenter @Inject constructor(
)
{
)
{
launch
(
CommonPool
+
strategy
.
jobs
)
{
launch
(
CommonPool
+
strategy
.
jobs
)
{
try
{
try
{
chatRoomId
=
roomId
chatRoomType
=
roomType
chatRoles
=
if
(
roomTypeOf
(
roomType
)
!
is
RoomType
.
DirectMessage
)
{
chatRoles
=
if
(
roomTypeOf
(
roomType
)
!
is
RoomType
.
DirectMessage
)
{
client
.
chatRoomRoles
(
roomType
=
roomTypeOf
(
roomType
),
roomName
=
roomName
)
client
.
chatRoomRoles
(
roomType
=
roomTypeOf
(
roomType
),
roomName
=
roomName
)
}
else
emptyList
()
}
else
emptyList
()
...
@@ -172,18 +174,21 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -172,18 +174,21 @@ class ChatRoomPresenter @Inject constructor(
}
}
private
suspend
fun
subscribeRoomChanges
()
{
private
suspend
fun
subscribeRoomChanges
()
{
chatRoomId
?.
let
{
withContext
(
CommonPool
+
strategy
.
jobs
)
{
manager
.
addRoomChannel
(
it
,
roomChangesChannel
)
chatRoomId
?.
let
{
for
(
room
in
roomChangesChannel
)
{
manager
.
addRoomChannel
(
it
,
roomChangesChannel
)
dbManager
.
getRoom
(
room
.
id
)
?.
let
{
for
(
room
in
roomChangesChannel
)
{
view
.
onRoomUpdated
(
roomMapper
.
map
(
chatRoom
=
it
,
showLastMessage
=
true
))
dbManager
.
getRoom
(
room
.
id
)
?.
let
{
view
.
onRoomUpdated
(
roomMapper
.
map
(
chatRoom
=
it
,
showLastMessage
=
true
))
}
}
}
}
}
}
}
}
}
private
fun
unsubscribeRoomChanges
()
{
private
fun
unsubscribeRoomChanges
()
{
chatRoomId
?.
let
{
manager
.
removeRoomChannel
(
it
)
}
chatRoomId
?.
let
{
manager
.
removeRoomChannel
(
it
)
}
}
}
private
fun
isOwnerOrMod
():
Boolean
{
private
fun
isOwnerOrMod
():
Boolean
{
...
@@ -939,32 +944,32 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -939,32 +944,32 @@ class ChatRoomPresenter @Inject constructor(
dbManager
.
chatRoomDao
().
getSync
(
roomId
)
?.
let
{
dbManager
.
chatRoomDao
().
getSync
(
roomId
)
?.
let
{
with
(
it
.
chatRoom
)
{
with
(
it
.
chatRoom
)
{
ChatRoom
(
ChatRoom
(
id
=
id
,
id
=
id
,
subscriptionId
=
subscriptionId
,
subscriptionId
=
subscriptionId
,
type
=
roomTypeOf
(
type
),
type
=
roomTypeOf
(
type
),
unread
=
unread
,
unread
=
unread
,
broadcast
=
broadcast
?:
false
,
broadcast
=
broadcast
?:
false
,
alert
=
alert
,
alert
=
alert
,
fullName
=
fullname
,
fullName
=
fullname
,
name
=
name
,
name
=
name
,
favorite
=
favorite
?:
false
,
favorite
=
favorite
?:
false
,
default
=
isDefault
?:
false
,
default
=
isDefault
?:
false
,
readonly
=
readonly
,
readonly
=
readonly
,
open
=
open
,
open
=
open
,
lastMessage
=
null
,
lastMessage
=
null
,
archived
=
false
,
archived
=
false
,
status
=
null
,
status
=
null
,
user
=
null
,
user
=
null
,
userMentions
=
userMentions
,
userMentions
=
userMentions
,
client
=
client
,
client
=
client
,
announcement
=
null
,
announcement
=
null
,
description
=
null
,
description
=
null
,
groupMentions
=
groupMentions
,
groupMentions
=
groupMentions
,
roles
=
null
,
roles
=
null
,
topic
=
null
,
topic
=
null
,
lastSeen
=
this
.
lastSeen
,
lastSeen
=
this
.
lastSeen
,
timestamp
=
timestamp
,
timestamp
=
timestamp
,
updatedAt
=
updatedAt
updatedAt
=
updatedAt
)
)
}
}
}
}
...
@@ -982,32 +987,32 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -982,32 +987,32 @@ class ChatRoomPresenter @Inject constructor(
}.
map
{
}.
map
{
with
(
it
.
chatRoom
)
{
with
(
it
.
chatRoom
)
{
ChatRoom
(
ChatRoom
(
id
=
id
,
id
=
id
,
subscriptionId
=
subscriptionId
,
subscriptionId
=
subscriptionId
,
type
=
roomTypeOf
(
type
),
type
=
roomTypeOf
(
type
),
unread
=
unread
,
unread
=
unread
,
broadcast
=
broadcast
?:
false
,
broadcast
=
broadcast
?:
false
,
alert
=
alert
,
alert
=
alert
,
fullName
=
fullname
,
fullName
=
fullname
,
name
=
name
?:
""
,
name
=
name
?:
""
,
favorite
=
favorite
?:
false
,
favorite
=
favorite
?:
false
,
default
=
isDefault
?:
false
,
default
=
isDefault
?:
false
,
readonly
=
readonly
,
readonly
=
readonly
,
open
=
open
,
open
=
open
,
lastMessage
=
null
,
lastMessage
=
null
,
archived
=
false
,
archived
=
false
,
status
=
null
,
status
=
null
,
user
=
null
,
user
=
null
,
userMentions
=
userMentions
,
userMentions
=
userMentions
,
client
=
client
,
client
=
client
,
announcement
=
null
,
announcement
=
null
,
description
=
null
,
description
=
null
,
groupMentions
=
groupMentions
,
groupMentions
=
groupMentions
,
roles
=
null
,
roles
=
null
,
topic
=
null
,
topic
=
null
,
lastSeen
=
this
.
lastSeen
,
lastSeen
=
this
.
lastSeen
,
timestamp
=
timestamp
,
timestamp
=
timestamp
,
updatedAt
=
updatedAt
updatedAt
=
updatedAt
)
)
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
2f5473a4
...
@@ -19,7 +19,6 @@ import android.view.Menu
...
@@ -19,7 +19,6 @@ import android.view.Menu
import
android.view.MenuItem
import
android.view.MenuItem
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
android.widget.Button
import
android.widget.EditText
import
android.widget.EditText
import
android.widget.FrameLayout
import
android.widget.FrameLayout
import
android.widget.ImageView
import
android.widget.ImageView
...
@@ -70,7 +69,6 @@ import chat.rocket.android.helper.MessageParser
...
@@ -70,7 +69,6 @@ import chat.rocket.android.helper.MessageParser
import
chat.rocket.android.util.extension.asObservable
import
chat.rocket.android.util.extension.asObservable
import
chat.rocket.android.util.extension.createImageFile
import
chat.rocket.android.util.extension.createImageFile
import
chat.rocket.android.util.extensions.circularRevealOrUnreveal
import
chat.rocket.android.util.extensions.circularRevealOrUnreveal
import
chat.rocket.android.util.extensions.content
import
chat.rocket.android.util.extensions.fadeIn
import
chat.rocket.android.util.extensions.fadeIn
import
chat.rocket.android.util.extensions.fadeOut
import
chat.rocket.android.util.extensions.fadeOut
import
chat.rocket.android.util.extensions.getBitmpap
import
chat.rocket.android.util.extensions.getBitmpap
...
...
app/src/main/java/chat/rocket/android/chatroom/uimodel/UiModelMapper.kt
View file @
2f5473a4
...
@@ -168,7 +168,7 @@ class UiModelMapper @Inject constructor(
...
@@ -168,7 +168,7 @@ class UiModelMapper @Inject constructor(
// TODO: move this to new interactor or FetchChatRoomsInteractor?
// TODO: move this to new interactor or FetchChatRoomsInteractor?
private
suspend
fun
getChatRoomAsync
(
roomId
:
String
):
ChatRoom
?
=
withContext
(
CommonPool
)
{
private
suspend
fun
getChatRoomAsync
(
roomId
:
String
):
ChatRoom
?
=
withContext
(
CommonPool
)
{
return
@withContext
dbManager
.
chatRoomDao
().
getSync
(
roomId
)
?.
let
{
return
@withContext
dbManager
.
getRoom
(
id
=
roomId
)
?.
let
{
with
(
it
.
chatRoom
)
{
with
(
it
.
chatRoom
)
{
ChatRoom
(
ChatRoom
(
id
=
id
,
id
=
id
,
...
...
app/src/main/java/chat/rocket/android/userdetails/presentation/UserDetailsPresenter.kt
View file @
2f5473a4
package
chat.rocket.android.userdetails.presentation
package
chat.rocket.android.userdetails.presentation
import
chat.rocket.android.chatrooms.domain.FetchChatRoomsInteractor
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.db.DatabaseManager
import
chat.rocket.android.db.model.ChatRoomEntity
import
chat.rocket.android.server.domain.GetConnectingServerInteractor
import
chat.rocket.android.server.domain.GetConnectingServerInteractor
import
chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import
chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extension.launchUI
...
@@ -27,6 +29,7 @@ class UserDetailsPresenter @Inject constructor(
...
@@ -27,6 +29,7 @@ class UserDetailsPresenter @Inject constructor(
private
var
currentServer
=
serverInteractor
.
get
()
!!
private
var
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
private
val
interactor
=
FetchChatRoomsInteractor
(
client
,
dbManager
)
fun
loadUserDetails
(
userId
:
String
)
{
fun
loadUserDetails
(
userId
:
String
)
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
...
@@ -39,37 +42,7 @@ class UserDetailsPresenter @Inject constructor(
...
@@ -39,37 +42,7 @@ class UserDetailsPresenter @Inject constructor(
val
openedChatRooms
=
chatRoomByName
(
name
=
u
.
name
)
val
openedChatRooms
=
chatRoomByName
(
name
=
u
.
name
)
val
avatarUrl
=
u
.
username
?.
let
{
currentServer
.
avatarUrl
(
avatar
=
it
)
}
val
avatarUrl
=
u
.
username
?.
let
{
currentServer
.
avatarUrl
(
avatar
=
it
)
}
val
chatRoom
:
ChatRoom
?
=
if
(
openedChatRooms
.
isEmpty
())
{
val
chatRoom
:
ChatRoom
?
=
openedChatRooms
.
firstOrNull
()
ChatRoom
(
id
=
""
,
type
=
roomTypeOf
(
RoomType
.
DIRECT_MESSAGE
),
name
=
u
.
username
?:
u
.
name
.
orEmpty
(),
fullName
=
u
.
name
,
favorite
=
false
,
open
=
false
,
alert
=
false
,
status
=
userStatusOf
(
u
.
status
),
client
=
client
,
broadcast
=
false
,
archived
=
false
,
default
=
false
,
description
=
null
,
groupMentions
=
null
,
userMentions
=
null
,
lastMessage
=
null
,
lastSeen
=
null
,
topic
=
null
,
announcement
=
null
,
roles
=
null
,
unread
=
0
,
readonly
=
false
,
muted
=
null
,
subscriptionId
=
""
,
timestamp
=
null
,
updatedAt
=
null
,
user
=
null
)
}
else
openedChatRooms
.
firstOrNull
()
view
.
showUserDetails
(
view
.
showUserDetails
(
avatarUrl
=
avatarUrl
,
avatarUrl
=
avatarUrl
,
...
@@ -92,48 +65,63 @@ class UserDetailsPresenter @Inject constructor(
...
@@ -92,48 +65,63 @@ class UserDetailsPresenter @Inject constructor(
client
.
createDirectMessage
(
username
=
id
)
client
.
createDirectMessage
(
username
=
id
)
}
}
interactor
.
refreshChatRooms
()
val
userEntity
=
withContext
(
CommonPool
)
{
val
userEntity
=
withContext
(
CommonPool
)
{
dbManager
.
userDao
().
getUser
(
id
=
id
)
dbManager
.
userDao
().
getUser
(
id
=
id
)
}
}
if
(
userEntity
!=
null
)
{
if
(
userEntity
!=
null
)
{
view
.
toDirectMessage
(
val
chatRoom
=
ChatRoom
(
chatRoom
=
ChatRoom
(
id
=
result
.
id
,
id
=
result
.
id
,
type
=
roomTypeOf
(
RoomType
.
DIRECT_MESSAGE
),
type
=
roomTypeOf
(
RoomType
.
DIRECT_MESSAGE
),
name
=
userEntity
.
username
?:
userEntity
.
name
.
orEmpty
(),
name
=
userEntity
.
username
?:
userEntity
.
name
.
orEmpty
(),
fullName
=
userEntity
.
name
,
fullName
=
userEntity
.
name
,
favorite
=
false
,
favorite
=
false
,
open
=
false
,
open
=
false
,
alert
=
false
,
alert
=
false
,
status
=
userStatusOf
(
userEntity
.
status
),
status
=
userStatusOf
(
userEntity
.
status
),
client
=
client
,
client
=
client
,
broadcast
=
false
,
broadcast
=
false
,
archived
=
false
,
archived
=
false
,
default
=
false
,
default
=
false
,
description
=
null
,
description
=
null
,
groupMentions
=
null
,
groupMentions
=
null
,
userMentions
=
null
,
userMentions
=
null
,
lastMessage
=
null
,
lastMessage
=
null
,
lastSeen
=
null
,
lastSeen
=
null
,
topic
=
null
,
topic
=
null
,
announcement
=
null
,
announcement
=
null
,
roles
=
null
,
roles
=
null
,
unread
=
0
,
unread
=
0
,
readonly
=
false
,
readonly
=
false
,
muted
=
null
,
muted
=
null
,
subscriptionId
=
""
,
subscriptionId
=
""
,
timestamp
=
null
,
timestamp
=
null
,
updatedAt
=
result
.
updatedAt
,
updatedAt
=
result
.
updatedAt
,
user
=
null
user
=
null
)
)
)
withContext
(
CommonPool
+
strategy
.
jobs
)
{
dbManager
.
chatRoomDao
().
insertOrReplace
(
chatRoom
=
ChatRoomEntity
(
id
=
chatRoom
.
id
,
name
=
chatRoom
.
name
,
description
=
chatRoom
.
description
,
type
=
chatRoom
.
type
.
toString
(),
fullname
=
chatRoom
.
fullName
,
subscriptionId
=
chatRoom
.
subscriptionId
,
updatedAt
=
chatRoom
.
updatedAt
))
}
view
.
toDirectMessage
(
chatRoom
=
chatRoom
)
}
}
}
catch
(
ex
:
Exception
)
{
}
catch
(
ex
:
Exception
)
{
Timber
.
e
(
ex
)
Timber
.
e
(
ex
)
view
.
onOpenDirectMessageError
()
view
.
onOpenDirectMessageError
()
}
}
}
}
private
suspend
fun
chatRoomByName
(
name
:
String
?
=
null
):
List
<
ChatRoom
>
=
withContext
(
CommonPool
)
{
private
suspend
fun
chatRoomByName
(
name
:
String
?
=
null
):
List
<
ChatRoom
>
=
withContext
(
CommonPool
)
{
return
@withContext
dbManager
.
chatRoomDao
().
getAllSync
().
filter
{
return
@withContext
dbManager
.
chatRoomDao
().
getAllSync
().
filter
{
if
(
name
==
null
)
{
if
(
name
==
null
)
{
...
...
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