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
27e5a7a6
Commit
27e5a7a6
authored
May 02, 2018
by
Lucio Maciel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix sorting on chatrooms and also check for STORE_LAST_MESSAGE or
refresh settings
parent
c1506bc8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
ChatRoomsPresenter.kt
...cket/android/chatrooms/presentation/ChatRoomsPresenter.kt
+16
-2
SettingsRepository.kt
...a/chat/rocket/android/server/domain/SettingsRepository.kt
+2
-0
No files found.
app/src/main/java/chat/rocket/android/chatrooms/presentation/ChatRoomsPresenter.kt
View file @
27e5a7a6
...
...
@@ -64,6 +64,10 @@ class ChatRoomsPresenter @Inject constructor(
view
.
showLoading
()
subscribeStatusChange
()
try
{
// If we still don't have 'Store_Last_Message' setting, refresh the settings
if
(!
settings
.
hasShowLastMessage
())
{
refreshSettingsInteractor
.
refresh
(
currentServer
)
}
view
.
updateChatRooms
(
getUserChatRooms
())
}
catch
(
ex
:
RocketChatException
)
{
ex
.
message
?.
let
{
...
...
@@ -226,9 +230,11 @@ class ChatRoomsPresenter @Inject constructor(
}
ChatRoomsSortOrder
.
ACTIVITY
->
{
when
(
groupByType
)
{
true
->
openChatRooms
.
sortedWith
(
compareBy
(
ChatRoom
::
type
).
thenByDescending
{
it
.
lastMessage
?.
timestamp
})
true
->
openChatRooms
.
sortedWith
(
compareBy
(
ChatRoom
::
type
).
thenByDescending
{
chatroom
->
chatRoomTimestamp
(
chatroom
)
})
false
->
openChatRooms
.
sortedByDescending
{
chatRoom
->
chatRoom
.
lastMessage
?.
timestamp
chatRoom
Timestamp
(
chatRoom
)
}
}
}
...
...
@@ -238,6 +244,14 @@ class ChatRoomsPresenter @Inject constructor(
}
}
private
fun
chatRoomTimestamp
(
chatRoom
:
ChatRoom
):
Long
?
{
return
if
(
settings
.
hasShowLastMessage
()
&&
settings
.
showLastMessage
())
{
chatRoom
.
lastMessage
?.
timestamp
?:
chatRoom
.
updatedAt
}
else
{
chatRoom
.
updatedAt
}
}
private
fun
compareBy
(
selector
:
KProperty1
<
ChatRoom
,
RoomType
>):
Comparator
<
ChatRoom
>
{
return
Comparator
{
a
,
b
->
getTypeConstant
(
a
.
type
)
-
getTypeConstant
(
b
.
type
)
}
}
...
...
app/src/main/java/chat/rocket/android/server/domain/SettingsRepository.kt
View file @
27e5a7a6
...
...
@@ -85,6 +85,8 @@ fun PublicSettings.showEditedStatus(): Boolean = this[SHOW_EDITED_STATUS]?.value
fun
PublicSettings
.
allowedMessagePinning
():
Boolean
=
this
[
ALLOW_MESSAGE_PINNING
]
?.
value
==
true
fun
PublicSettings
.
allowedMessageEditing
():
Boolean
=
this
[
ALLOW_MESSAGE_EDITING
]
?.
value
==
true
fun
PublicSettings
.
allowedMessageDeleting
():
Boolean
=
this
[
ALLOW_MESSAGE_DELETING
]
?.
value
==
true
fun
PublicSettings
.
hasShowLastMessage
():
Boolean
=
this
[
STORE_LAST_MESSAGE
]
!=
null
fun
PublicSettings
.
showLastMessage
():
Boolean
=
this
[
STORE_LAST_MESSAGE
]
?.
value
==
true
fun
PublicSettings
.
uploadMimeTypeFilter
():
Array
<
String
>?
{
...
...
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