File tree 3 files changed +16
-11
lines changed
matrix-sdk-android/src/main/java/org/matrix/android/sdk
vector/src/main/java/im/vector/app/features/home
3 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -19,5 +19,6 @@ package org.matrix.android.sdk.api.session.room
19
19
enum class RoomSortOrder {
20
20
NAME ,
21
21
ACTIVITY ,
22
+ PRIORITY_AND_ACTIVITY ,
22
23
NONE
23
24
}
Original file line number Diff line number Diff line change @@ -24,13 +24,21 @@ import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields
24
24
25
25
internal fun RealmQuery<RoomSummaryEntity>.process (sortOrder : RoomSortOrder ): RealmQuery <RoomSummaryEntity > {
26
26
when (sortOrder) {
27
- RoomSortOrder .NAME -> {
27
+ RoomSortOrder .NAME -> {
28
28
sort(RoomSummaryEntityFields .DISPLAY_NAME , Sort .ASCENDING )
29
29
}
30
- RoomSortOrder .ACTIVITY -> {
30
+ RoomSortOrder .ACTIVITY -> {
31
31
sort(RoomSummaryEntityFields .LAST_ACTIVITY_TIME , Sort .DESCENDING )
32
32
}
33
- RoomSortOrder .NONE -> {
33
+ RoomSortOrder .PRIORITY_AND_ACTIVITY -> {
34
+ sort(
35
+ arrayOf(
36
+ RoomSummaryEntityFields .IS_FAVOURITE ,
37
+ RoomSummaryEntityFields .IS_LOW_PRIORITY ,
38
+ RoomSummaryEntityFields .LAST_ACTIVITY_TIME ),
39
+ arrayOf(Sort .DESCENDING , Sort .ASCENDING , Sort .DESCENDING ))
40
+ }
41
+ RoomSortOrder .NONE -> {
34
42
}
35
43
}
36
44
return this
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import androidx.core.content.pm.ShortcutManagerCompat
24
24
import im.vector.app.core.di.ActiveSessionHolder
25
25
import io.reactivex.disposables.Disposable
26
26
import io.reactivex.disposables.Disposables
27
+ import org.matrix.android.sdk.api.session.room.RoomSortOrder
27
28
import org.matrix.android.sdk.api.session.room.model.Membership
28
29
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
29
30
import org.matrix.android.sdk.rx.asObservable
@@ -45,7 +46,8 @@ class ShortcutsHandler @Inject constructor(
45
46
?.getPagedRoomSummariesLive(
46
47
roomSummaryQueryParams {
47
48
memberships = listOf (Membership .JOIN )
48
- }
49
+ },
50
+ sortOrder = RoomSortOrder .PRIORITY_AND_ACTIVITY
49
51
)
50
52
?.asObservable()
51
53
?.subscribe { rooms ->
@@ -57,13 +59,7 @@ class ShortcutsHandler @Inject constructor(
57
59
ShortcutManagerCompat .removeLongLivedShortcuts(context, deadShortcutIds)
58
60
59
61
val shortcuts = rooms
60
- .sortedBy { room ->
61
- // pushDynamicShortcut adds each shortcut to the top of the shortcut ranking,
62
- // so higher priority rooms should be at the end of this list to get pushed on last.
63
- if (room.isFavorite) 2
64
- else if (room.isLowPriority) 0
65
- else 1
66
- }
62
+ .asReversed()
67
63
.map { shortcutCreator.create(it) }
68
64
69
65
shortcuts.forEach { shortcut ->
You can’t perform that action at this time.
0 commit comments