Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Neil Alexander
element-android
Commits
56d0699b
Unverified
Commit
56d0699b
authored
May 12, 2021
by
Benoît Marty
Committed by
GitHub
May 12, 2021
Browse files
Merge pull request #3312 from vector-im/feature/bca/spaces_polish
Spaces various fixes and polish
parents
bdc3f189
1799dcbd
Changes
34
Show whitespace changes
Inline
Side-by-side
matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/space/Space.kt
View file @
56d0699b
...
...
@@ -33,7 +33,7 @@ interface Space {
fun
spaceSummary
():
RoomSummary
?
suspend
fun
addChildren
(
roomId
:
String
,
viaServers
:
List
<
String
>,
viaServers
:
List
<
String
>
?
,
order
:
String
?,
autoJoin
:
Boolean
=
false
,
suggested
:
Boolean
?
=
false
)
...
...
matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt
View file @
56d0699b
...
...
@@ -18,19 +18,13 @@ package org.matrix.android.sdk.internal.session.permalinks
import
org.matrix.android.sdk.api.session.events.model.Event
import
org.matrix.android.sdk.api.session.permalinks.PermalinkService.Companion.MATRIX_TO_URL_BASE
import
org.matrix.android.sdk.api.session.room.members.roomMemberQueryParams
import
org.matrix.android.sdk.api.session.room.model.Membership
import
org.matrix.android.sdk.internal.di.UserId
import
org.matrix.android.sdk.internal.session.room.RoomGetter
import
java.net.URLEncoder
import
javax.inject.Inject
import
javax.inject.Provider
internal
class
PermalinkFactory
@Inject
constructor
(
@UserId
private
val
userId
:
String
,
// Use a provider to fix circular Dagger dependency
private
val
roomGetterProvider
:
Provider
<
RoomGetter
>
private
val
viaParameterFinder
:
ViaParameterFinder
)
{
fun
createPermalink
(
event
:
Event
):
String
?
{
...
...
@@ -50,12 +44,12 @@ internal class PermalinkFactory @Inject constructor(
return
if
(
roomId
.
isEmpty
())
{
null
}
else
{
MATRIX_TO_URL_BASE
+
escape
(
roomId
)
+
computeViaParams
(
userId
,
roomId
)
MATRIX_TO_URL_BASE
+
escape
(
roomId
)
+
viaParameterFinder
.
computeViaParams
(
userId
,
roomId
)
}
}
fun
createPermalink
(
roomId
:
String
,
eventId
:
String
):
String
{
return
MATRIX_TO_URL_BASE
+
escape
(
roomId
)
+
"/"
+
escape
(
eventId
)
+
computeViaParams
(
userId
,
roomId
)
return
MATRIX_TO_URL_BASE
+
escape
(
roomId
)
+
"/"
+
escape
(
eventId
)
+
viaParameterFinder
.
computeViaParams
(
userId
,
roomId
)
}
fun
getLinkedId
(
url
:
String
):
String
?
{
...
...
@@ -66,25 +60,6 @@ internal class PermalinkFactory @Inject constructor(
}
else
null
}
/**
* Compute the via parameters.
* Take up to 3 homeserver domains, taking the most representative one regarding room members and including the
* current user one.
*/
private
fun
computeViaParams
(
userId
:
String
,
roomId
:
String
):
String
{
val
userHomeserver
=
userId
.
substringAfter
(
":"
)
return
getUserIdsOfJoinedMembers
(
roomId
)
.
map
{
it
.
substringAfter
(
":"
)
}
.
groupBy
{
it
}
.
mapValues
{
it
.
value
.
size
}
.
toMutableMap
()
// Ensure the user homeserver will be included
.
apply
{
this
[
userHomeserver
]
=
Int
.
MAX_VALUE
}
.
let
{
map
->
map
.
keys
.
sortedByDescending
{
map
[
it
]
}
}
.
take
(
3
)
.
joinToString
(
prefix
=
"?via="
,
separator
=
"&via="
)
{
URLEncoder
.
encode
(
it
,
"utf-8"
)
}
}
/**
* Escape '/' in id, because it is used as a separator
*
...
...
@@ -104,15 +79,4 @@ internal class PermalinkFactory @Inject constructor(
private
fun
unescape
(
id
:
String
):
String
{
return
id
.
replace
(
"%2F"
,
"/"
)
}
/**
* Get a set of userIds of joined members of a room
*/
private
fun
getUserIdsOfJoinedMembers
(
roomId
:
String
):
Set
<
String
>
{
return
roomGetterProvider
.
get
().
getRoom
(
roomId
)
?.
getRoomMembers
(
roomMemberQueryParams
{
memberships
=
listOf
(
Membership
.
JOIN
)
})
?.
map
{
it
.
userId
}
.
orEmpty
()
.
toSet
()
}
}
matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/ViaParameterFinder.kt
0 → 100644
View file @
56d0699b
/*
* Copyright 2021 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.matrix.android.sdk.internal.session.permalinks
import
org.matrix.android.sdk.api.session.room.members.roomMemberQueryParams
import
org.matrix.android.sdk.api.session.room.model.Membership
import
org.matrix.android.sdk.internal.di.UserId
import
org.matrix.android.sdk.internal.session.room.RoomGetter
import
java.net.URLEncoder
import
javax.inject.Inject
import
javax.inject.Provider
internal
class
ViaParameterFinder
@Inject
constructor
(
@UserId
private
val
userId
:
String
,
private
val
roomGetterProvider
:
Provider
<
RoomGetter
>
)
{
fun
computeViaParams
(
roomId
:
String
,
max
:
Int
):
List
<
String
>
{
return
computeViaParams
(
userId
,
roomId
,
max
)
}
/**
* Compute the via parameters.
* Take up to 3 homeserver domains, taking the most representative one regarding room members and including the
* current user one.
*/
fun
computeViaParams
(
userId
:
String
,
roomId
:
String
):
String
{
return
computeViaParams
(
userId
,
roomId
,
3
)
.
joinToString
(
prefix
=
"?via="
,
separator
=
"&via="
)
{
URLEncoder
.
encode
(
it
,
"utf-8"
)
}
}
fun
computeViaParams
(
userId
:
String
,
roomId
:
String
,
max
:
Int
):
List
<
String
>
{
val
userHomeserver
=
userId
.
substringAfter
(
":"
)
return
getUserIdsOfJoinedMembers
(
roomId
)
.
map
{
it
.
substringAfter
(
":"
)
}
.
groupBy
{
it
}
.
mapValues
{
it
.
value
.
size
}
.
toMutableMap
()
// Ensure the user homeserver will be included
.
apply
{
this
[
userHomeserver
]
=
Int
.
MAX_VALUE
}
.
let
{
map
->
map
.
keys
.
sortedByDescending
{
map
[
it
]
}
}
.
take
(
max
)
}
/**
* Get a set of userIds of joined members of a room
*/
private
fun
getUserIdsOfJoinedMembers
(
roomId
:
String
):
Set
<
String
>
{
return
roomGetterProvider
.
get
().
getRoom
(
roomId
)
?.
getRoomMembers
(
roomMemberQueryParams
{
memberships
=
listOf
(
Membership
.
JOIN
)
})
?.
map
{
it
.
userId
}
.
orEmpty
()
.
toSet
()
}
}
matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoom.kt
View file @
56d0699b
...
...
@@ -40,6 +40,7 @@ import org.matrix.android.sdk.api.session.search.SearchResult
import
org.matrix.android.sdk.api.session.space.Space
import
org.matrix.android.sdk.api.util.Optional
import
org.matrix.android.sdk.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM
import
org.matrix.android.sdk.internal.session.permalinks.ViaParameterFinder
import
org.matrix.android.sdk.internal.session.room.state.SendStateTask
import
org.matrix.android.sdk.internal.session.room.summary.RoomSummaryDataSource
import
org.matrix.android.sdk.internal.session.search.SearchTask
...
...
@@ -66,6 +67,7 @@ internal class DefaultRoom @Inject constructor(override val roomId: String,
private
val
roomMembersService
:
MembershipService
,
private
val
roomPushRuleService
:
RoomPushRuleService
,
private
val
sendStateTask
:
SendStateTask
,
private
val
viaParameterFinder
:
ViaParameterFinder
,
private
val
searchTask
:
SearchTask
)
:
Room
,
TimelineService
by
timelineService
,
...
...
@@ -154,6 +156,6 @@ internal class DefaultRoom @Inject constructor(override val roomId: String,
override
fun
asSpace
():
Space
?
{
if
(
roomSummary
()
?.
roomType
!=
RoomType
.
SPACE
)
return
null
return
DefaultSpace
(
this
,
roomSummaryDataSource
)
return
DefaultSpace
(
this
,
roomSummaryDataSource
,
viaParameterFinder
)
}
}
matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomFactory.kt
View file @
56d0699b
...
...
@@ -19,6 +19,7 @@ package org.matrix.android.sdk.internal.session.room
import
org.matrix.android.sdk.api.session.crypto.CryptoService
import
org.matrix.android.sdk.api.session.room.Room
import
org.matrix.android.sdk.internal.session.SessionScope
import
org.matrix.android.sdk.internal.session.permalinks.ViaParameterFinder
import
org.matrix.android.sdk.internal.session.room.alias.DefaultAliasService
import
org.matrix.android.sdk.internal.session.room.call.DefaultRoomCallService
import
org.matrix.android.sdk.internal.session.room.draft.DefaultDraftService
...
...
@@ -60,6 +61,7 @@ internal class DefaultRoomFactory @Inject constructor(private val cryptoService:
private
val
membershipServiceFactory
:
DefaultMembershipService
.
Factory
,
private
val
roomPushRuleServiceFactory
:
DefaultRoomPushRuleService
.
Factory
,
private
val
sendStateTask
:
SendStateTask
,
private
val
viaParameterFinder
:
ViaParameterFinder
,
private
val
searchTask
:
SearchTask
)
:
RoomFactory
{
...
...
@@ -83,7 +85,8 @@ internal class DefaultRoomFactory @Inject constructor(private val cryptoService:
roomMembersService
=
membershipServiceFactory
.
create
(
roomId
),
roomPushRuleService
=
roomPushRuleServiceFactory
.
create
(
roomId
),
sendStateTask
=
sendStateTask
,
searchTask
=
searchTask
searchTask
=
searchTask
,
viaParameterFinder
=
viaParameterFinder
)
}
}
matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt
View file @
56d0699b
...
...
@@ -364,6 +364,8 @@ internal class RoomSummaryUpdater @Inject constructor(
realm
.
where
(
RoomSummaryEntity
::
class
.
java
)
.
process
(
RoomSummaryEntityFields
.
MEMBERSHIP_STR
,
listOf
(
Membership
.
JOIN
))
.
notEqualTo
(
RoomSummaryEntityFields
.
ROOM_TYPE
,
RoomType
.
SPACE
)
// also we do not count DM in here, because home space will already show them
.
equalTo
(
RoomSummaryEntityFields
.
IS_DIRECT
,
false
)
.
contains
(
RoomSummaryEntityFields
.
FLATTEN_PARENT_IDS
,
space
.
roomId
)
.
findAll
().
forEach
{
highlightCount
+=
it
.
highlightCount
...
...
matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/DefaultSpace.kt
View file @
56d0699b
...
...
@@ -24,11 +24,13 @@ import org.matrix.android.sdk.api.session.room.Room
import
org.matrix.android.sdk.api.session.room.model.RoomSummary
import
org.matrix.android.sdk.api.session.space.Space
import
org.matrix.android.sdk.api.session.space.model.SpaceChildContent
import
org.matrix.android.sdk.internal.session.permalinks.ViaParameterFinder
import
org.matrix.android.sdk.internal.session.room.summary.RoomSummaryDataSource
internal
class
DefaultSpace
(
private
val
room
:
Room
,
private
val
spaceSummaryDataSource
:
RoomSummaryDataSource
private
val
spaceSummaryDataSource
:
RoomSummaryDataSource
,
private
val
viaParameterFinder
:
ViaParameterFinder
)
:
Space
{
override
fun
asRoom
():
Room
{
...
...
@@ -46,15 +48,17 @@ internal class DefaultSpace(
}
override
suspend
fun
addChildren
(
roomId
:
String
,
viaServers
:
List
<
String
>,
viaServers
:
List
<
String
>
?
,
order
:
String
?,
autoJoin
:
Boolean
,
suggested
:
Boolean
?)
{
// Find best via
room
.
sendStateEvent
(
eventType
=
EventType
.
STATE_SPACE_CHILD
,
stateKey
=
roomId
,
body
=
SpaceChildContent
(
via
=
viaServers
,
via
=
viaServers
?:
viaParameterFinder
.
computeViaParams
(
roomId
,
3
)
,
autoJoin
=
autoJoin
,
order
=
order
,
suggested
=
suggested
...
...
vector/src/main/java/im/vector/app/core/ui/list/GenericPillItem.kt
0 → 100644
View file @
56d0699b
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
im.vector.app.core.ui.list
import
android.content.res.ColorStateList
import
android.view.Gravity
import
android.widget.ImageView
import
android.widget.TextView
import
androidx.annotation.DrawableRes
import
androidx.core.view.isVisible
import
androidx.core.widget.ImageViewCompat
import
com.airbnb.epoxy.EpoxyAttribute
import
com.airbnb.epoxy.EpoxyModelClass
import
im.vector.app.R
import
im.vector.app.core.epoxy.VectorEpoxyHolder
import
im.vector.app.core.epoxy.VectorEpoxyModel
import
im.vector.app.core.extensions.setTextOrHide
import
im.vector.app.features.themes.ThemeUtils
/**
* A generic list item with a rounded corner background and an optional icon
*/
@EpoxyModelClass
(
layout
=
R
.
layout
.
item_generic_pill_footer
)
abstract
class
GenericPillItem
:
VectorEpoxyModel
<
GenericPillItem
.
Holder
>()
{
@EpoxyAttribute
var
text
:
CharSequence
?
=
null
@EpoxyAttribute
var
style
:
ItemStyle
=
ItemStyle
.
NORMAL_TEXT
@EpoxyAttribute
var
itemClickAction
:
GenericItem
.
Action
?
=
null
@EpoxyAttribute
var
centered
:
Boolean
=
false
@EpoxyAttribute
@DrawableRes
var
imageRes
:
Int
?
=
null
@EpoxyAttribute
var
tintIcon
:
Boolean
=
true
override
fun
bind
(
holder
:
Holder
)
{
super
.
bind
(
holder
)
holder
.
textView
.
setTextOrHide
(
text
)
holder
.
textView
.
typeface
=
style
.
toTypeFace
()
holder
.
textView
.
textSize
=
style
.
toTextSize
()
holder
.
textView
.
gravity
=
if
(
centered
)
Gravity
.
CENTER_HORIZONTAL
else
Gravity
.
START
if
(
imageRes
!=
null
)
{
holder
.
imageView
.
setImageResource
(
imageRes
!!
)
holder
.
imageView
.
isVisible
=
true
}
else
{
holder
.
imageView
.
isVisible
=
false
}
if
(
tintIcon
)
{
val
iconTintColor
=
ThemeUtils
.
getColor
(
holder
.
view
.
context
,
R
.
attr
.
riotx_text_secondary
)
ImageViewCompat
.
setImageTintList
(
holder
.
imageView
,
ColorStateList
.
valueOf
(
iconTintColor
))
}
else
{
ImageViewCompat
.
setImageTintList
(
holder
.
imageView
,
null
)
}
holder
.
view
.
setOnClickListener
{
itemClickAction
?.
perform
?.
run
()
}
}
class
Holder
:
VectorEpoxyHolder
()
{
val
imageView
by
bind
<
ImageView
>(
R
.
id
.
itemGenericPillImage
)
val
textView
by
bind
<
TextView
>(
R
.
id
.
itemGenericPillText
)
}
}
vector/src/main/java/im/vector/app/features/grouplist/HomeSpaceSummaryItem.kt
View file @
56d0699b
...
...
@@ -18,6 +18,7 @@
package
im.vector.app.features.grouplist
import
android.content.res.ColorStateList
import
android.view.View
import
android.widget.ImageView
import
android.widget.TextView
import
androidx.core.content.ContextCompat
...
...
@@ -35,8 +36,9 @@ import im.vector.app.features.themes.ThemeUtils
abstract
class
HomeSpaceSummaryItem
:
VectorEpoxyModel
<
HomeSpaceSummaryItem
.
Holder
>()
{
@EpoxyAttribute
var
selected
:
Boolean
=
false
@EpoxyAttribute
var
listener
:
(()
->
Unit
)?
=
null
@EpoxyAttribute
(
EpoxyAttribute
.
Option
.
DoNotHash
)
var
listener
:
(()
->
Unit
)?
=
null
@EpoxyAttribute
var
countState
:
UnreadCounterBadgeView
.
State
=
UnreadCounterBadgeView
.
State
(
0
,
false
)
@EpoxyAttribute
var
showSeparator
:
Boolean
=
false
override
fun
getViewType
():
Int
{
// mm.. it's reusing the same layout for basic space item
...
...
@@ -56,6 +58,7 @@ abstract class HomeSpaceSummaryItem : VectorEpoxyModel<HomeSpaceSummaryItem.Hold
holder
.
leaveView
.
isVisible
=
false
holder
.
counterBadgeView
.
render
(
countState
)
holder
.
bottomSeparator
.
isVisible
=
showSeparator
}
class
Holder
:
VectorEpoxyHolder
()
{
...
...
@@ -64,5 +67,6 @@ abstract class HomeSpaceSummaryItem : VectorEpoxyModel<HomeSpaceSummaryItem.Hold
val
rootView
by
bind
<
CheckableConstraintLayout
>(
R
.
id
.
itemGroupLayout
)
val
leaveView
by
bind
<
ImageView
>(
R
.
id
.
groupTmpLeave
)
val
counterBadgeView
by
bind
<
UnreadCounterBadgeView
>(
R
.
id
.
groupCounterBadge
)
val
bottomSeparator
by
bind
<
View
>(
R
.
id
.
groupBottomSeparator
)
}
}
vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt
View file @
56d0699b
...
...
@@ -202,7 +202,7 @@ class HomeDetailViewModel @AssistedInject constructor(@Assisted initialState: Ho
setState
{
copy
(
notificationCountCatchup
=
dmRooms
.
totalCount
+
otherRooms
.
totalCount
+
roomsInvite
+
dmInvites
,
notificationHighlightCatchup
=
dmRooms
.
isHighlight
||
otherRooms
.
isHighlight
,
notificationHighlightCatchup
=
dmRooms
.
isHighlight
||
otherRooms
.
isHighlight
||
(
dmInvites
+
roomsInvite
)
>
0
,
notificationCountPeople
=
dmRooms
.
totalCount
+
dmInvites
,
notificationHighlightPeople
=
dmRooms
.
isHighlight
||
dmInvites
>
0
,
notificationCountRooms
=
otherRooms
.
totalCount
+
roomsInvite
,
...
...
vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt
View file @
56d0699b
...
...
@@ -29,6 +29,7 @@ import im.vector.app.RoomGroupingMethod
import
im.vector.app.core.platform.EmptyAction
import
im.vector.app.core.platform.EmptyViewEvents
import
im.vector.app.core.platform.VectorViewModel
import
im.vector.app.features.settings.VectorPreferences
import
io.reactivex.Observable
import
io.reactivex.schedulers.Schedulers
import
org.matrix.android.sdk.api.query.ActiveSpaceFilter
...
...
@@ -52,6 +53,7 @@ data class CountInfo(
class
UnreadMessagesSharedViewModel
@AssistedInject
constructor
(
@Assisted
initialState
:
UnreadMessagesState
,
session
:
Session
,
private
val
vectorPreferences
:
VectorPreferences
,
appStateHandler
:
AppStateHandler
)
:
VectorViewModel
<
UnreadMessagesState
,
EmptyAction
,
EmptyViewEvents
>(
initialState
)
{
...
...
@@ -126,12 +128,24 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
}
is
RoomGroupingMethod
.
BySpace
->
{
val
selectedSpace
=
appStateHandler
.
safeActiveSpaceId
()
val
counts
=
session
.
getNotificationCountForRooms
(
val
inviteCount
=
session
.
getRoomSummaries
(
roomSummaryQueryParams
{
this
.
memberships
=
listOf
(
Membership
.
INVITE
)
}).
size
val
totalCount
=
session
.
getNotificationCountForRooms
(
roomSummaryQueryParams
{
this
.
memberships
=
listOf
(
Membership
.
JOIN
)
this
.
activeSpaceFilter
=
ActiveSpaceFilter
.
ActiveSpace
(
null
)
this
.
activeSpaceFilter
=
ActiveSpaceFilter
.
ActiveSpace
(
null
).
takeIf
{
vectorPreferences
.
labsSpacesOnlyOrphansInHome
()
}
?:
ActiveSpaceFilter
.
None
}
)
val
counts
=
RoomAggregateNotificationCount
(
totalCount
.
notificationCount
+
inviteCount
,
totalCount
.
highlightCount
+
inviteCount
)
val
rootCounts
=
session
.
spaceService
().
getRootSpaceSummaries
()
.
filter
{
// filter out current selection
...
...
vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt
View file @
56d0699b
...
...
@@ -832,7 +832,7 @@ class RoomDetailViewModel @AssistedInject constructor(
session
.
spaceService
().
getSpace
(
spaceId
)
?.
addChildren
(
state
.
roomId
,
listOf
(
session
.
sessionParams
.
homeServerHost
?:
""
)
,
null
,
null
,
true
)
...
...
@@ -849,7 +849,7 @@ class RoomDetailViewModel @AssistedInject constructor(
session
.
spaceService
().
getSpace
(
slashCommandResult
.
spaceId
)
?.
addChildren
(
room
.
roomId
,
listOf
(
session
.
sessionParams
.
homeServerHost
?:
""
)
,
null
,
null
,
false
)
...
...
vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt
View file @
56d0699b
...
...
@@ -69,12 +69,12 @@ class RoomListViewModel @Inject constructor(
* Filter the rooms if they are part of the current space (children and grand children).
* If current space is null, will return orphan rooms only
*/
N
OR
MA
L
,
OR
PHANS_IF_SPACE_NUL
L
,
/**
* Special case when we don't want to discriminate rooms when current space is null.
* In this case return all.
*/
NOT
_IF_
A
LL
,
ALL
_IF_
SPACE_NU
LL
,
/** Do not filter based on space*/
NONE
}
...
...
@@ -131,7 +131,8 @@ class RoomListViewModel @Inject constructor(
},
{
updatableQuery
=
it
}
},
vectorPreferences
.
labsSpacesOnlyOrphansInHome
()
).
buildSections
(
initialState
.
displayMode
)
}
else
{
GroupRoomListSectionBuilder
(
...
...
vector/src/main/java/im/vector/app/features/home/room/list/SpaceRoomListSectionBuilder.kt
View file @
56d0699b
...
...
@@ -41,6 +41,7 @@ import org.matrix.android.sdk.api.session.Session
import
org.matrix.android.sdk.api.session.room.RoomSummaryQueryParams
import
org.matrix.android.sdk.api.session.room.UpdatableLivePageResult
import
org.matrix.android.sdk.api.session.room.model.Membership
import
org.matrix.android.sdk.api.session.room.summary.RoomAggregateNotificationCount
import
org.matrix.android.sdk.rx.asObservable
class
SpaceRoomListSectionBuilder
(
...
...
@@ -50,7 +51,8 @@ class SpaceRoomListSectionBuilder(
val
viewModelScope
:
CoroutineScope
,
private
val
suggestedRoomJoiningState
:
LiveData
<
Map
<
String
,
Async
<
Unit
>>>,
val
onDisposable
:
(
Disposable
)
->
Unit
,
val
onUdpatable
:
(
UpdatableLivePageResult
)
->
Unit
val
onUdpatable
:
(
UpdatableLivePageResult
)
->
Unit
,
val
onlyOrphansInHome
:
Boolean
=
false
)
:
RoomListSectionBuilder
{
val
pagedListConfig
=
PagedList
.
Config
.
Builder
()
...
...
@@ -87,22 +89,31 @@ class SpaceRoomListSectionBuilder(
}
RoomListDisplayMode
.
NOTIFICATIONS
->
{
addSection
(
sections
,
activeSpaceAwareQueries
,
R
.
string
.
invitations_header
,
true
,
RoomListViewModel
.
SpaceFilterStrategy
.
NORMAL
sections
=
sections
,
activeSpaceUpdaters
=
activeSpaceAwareQueries
,
nameRes
=
R
.
string
.
invitations_header
,
notifyOfLocalEcho
=
true
,
spaceFilterStrategy
=
if
(
onlyOrphansInHome
)
{
RoomListViewModel
.
SpaceFilterStrategy
.
ORPHANS_IF_SPACE_NULL
}
else
{
RoomListViewModel
.
SpaceFilterStrategy
.
ALL_IF_SPACE_NULL
},
countRoomAsNotif
=
true
)
{
it
.
memberships
=
listOf
(
Membership
.
INVITE
)
it
.
roomCategoryFilter
=
RoomCategoryFilter
.
ALL
}
addSection
(
sections
,
activeSpaceAwareQueries
,
R
.
string
.
bottom_action_rooms
,
false
,
RoomListViewModel
.
SpaceFilterStrategy
.
NORMAL
sections
=
sections
,
activeSpaceUpdaters
=
activeSpaceAwareQueries
,
nameRes
=
R
.
string
.
bottom_action_rooms
,
notifyOfLocalEcho
=
false
,
spaceFilterStrategy
=
if
(
onlyOrphansInHome
)
{
RoomListViewModel
.
SpaceFilterStrategy
.
ORPHANS_IF_SPACE_NULL
}
else
{
RoomListViewModel
.
SpaceFilterStrategy
.
ALL_IF_SPACE_NULL
}
)
{
it
.
memberships
=
listOf
(
Membership
.
JOIN
)
it
.
roomCategoryFilter
=
RoomCategoryFilter
.
ONLY_WITH_NOTIFICATIONS
...
...
@@ -126,10 +137,12 @@ class SpaceRoomListSectionBuilder(
private
fun
buildRoomsSections
(
sections
:
MutableList
<
RoomsSection
>,
activeSpaceAwareQueries
:
MutableList
<
RoomListViewModel
.
ActiveSpaceQueryUpdater
>)
{
addSection
(
sections
,
activeSpaceAwareQueries
,
R
.
string
.
invitations_header
,
true
,
RoomListViewModel
.
SpaceFilterStrategy
.
NOT_IF_ALL
sections
=
sections
,
activeSpaceUpdaters
=
activeSpaceAwareQueries
,
nameRes
=
R
.
string
.
invitations_header
,
notifyOfLocalEcho
=
true
,
spaceFilterStrategy
=
RoomListViewModel
.
SpaceFilterStrategy
.
ALL_IF_SPACE_NULL
,
countRoomAsNotif
=
true
)
{
it
.
memberships
=
listOf
(
Membership
.
INVITE
)
it
.
roomCategoryFilter
=
RoomCategoryFilter
.
ONLY_ROOMS
...
...
@@ -140,7 +153,7 @@ class SpaceRoomListSectionBuilder(
activeSpaceAwareQueries
,
R
.
string
.
bottom_action_favourites
,
false
,
RoomListViewModel
.
SpaceFilterStrategy
.
NOT
_IF_
A
LL
RoomListViewModel
.
SpaceFilterStrategy
.
ALL
_IF_
SPACE_NU
LL
)
{
it
.
memberships
=
listOf
(
Membership
.
JOIN
)
it
.
roomCategoryFilter
=
RoomCategoryFilter
.
ONLY_ROOMS
...
...
@@ -148,11 +161,15 @@ class SpaceRoomListSectionBuilder(
}
addSection
(
sections
,
activeSpaceAwareQueries
,
R
.
string
.
bottom_action_rooms
,