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
f9820cde
Commit
f9820cde
authored
May 11, 2021
by
Valere
Browse files
Fixes on unread badges
parent
14144dc9
Changes
5
Hide whitespace changes
Inline
Side-by-side
matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt
View file @
f9820cde
...
...
@@ -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
...
...
vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt
View file @
f9820cde
...
...
@@ -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 @
f9820cde
...
...
@@ -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/list/SpaceRoomListSectionBuilder.kt
View file @
f9820cde
...
...
@@ -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
(
...
...
@@ -88,12 +89,13 @@ class SpaceRoomListSectionBuilder(
}
RoomListDisplayMode
.
NOTIFICATIONS
->
{
addSection
(
sections
,
activeSpaceAwareQueries
,
R
.
string
.
invitations_header
,
true
,
RoomListViewModel
.
SpaceFilterStrategy
.
ORPHANS_IF_SPACE_NULL
.
takeIf
{
onlyOrphansInHome
}
?:
RoomListViewModel
.
SpaceFilterStrategy
.
ALL_IF_SPACE_NULL
sections
=
sections
,
activeSpaceUpdaters
=
activeSpaceAwareQueries
,
nameRes
=
R
.
string
.
invitations_header
,
notifyOfLocalEcho
=
true
,
spaceFilterStrategy
=
RoomListViewModel
.
SpaceFilterStrategy
.
ORPHANS_IF_SPACE_NULL
.
takeIf
{
onlyOrphansInHome
}
?:
RoomListViewModel
.
SpaceFilterStrategy
.
ALL_IF_SPACE_NULL
,
countRoomAsNotif
=
true
)
{
it
.
memberships
=
listOf
(
Membership
.
INVITE
)
it
.
roomCategoryFilter
=
RoomCategoryFilter
.
ALL
...
...
@@ -129,10 +131,12 @@ class SpaceRoomListSectionBuilder(
private
fun
buildRoomsSections
(
sections
:
MutableList
<
RoomsSection
>,
activeSpaceAwareQueries
:
MutableList
<
RoomListViewModel
.
ActiveSpaceQueryUpdater
>)
{
addSection
(
sections
,
activeSpaceAwareQueries
,
R
.
string
.
invitations_header
,
true
,
RoomListViewModel
.
SpaceFilterStrategy
.
ALL_IF_SPACE_NULL
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
...
...
@@ -234,11 +238,12 @@ class SpaceRoomListSectionBuilder(
}
private
fun
buildDmSections
(
sections
:
MutableList
<
RoomsSection
>,
activeSpaceAwareQueries
:
MutableList
<
RoomListViewModel
.
ActiveSpaceQueryUpdater
>)
{
addSection
(
sections
,
activeSpaceAwareQueries
,
R
.
string
.
invitations_header
,
true
,
RoomListViewModel
.
SpaceFilterStrategy
.
ALL_IF_SPACE_NULL
addSection
(
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_DM
...
...
@@ -272,6 +277,7 @@ class SpaceRoomListSectionBuilder(
@StringRes
nameRes
:
Int
,
notifyOfLocalEcho
:
Boolean
=
false
,
spaceFilterStrategy
:
RoomListViewModel
.
SpaceFilterStrategy
=
RoomListViewModel
.
SpaceFilterStrategy
.
NONE
,
countRoomAsNotif
:
Boolean
=
false
,
query
:
(
RoomSummaryQueryParams
.
Builder
)
->
Unit
)
{
withQueryParams
(
{
query
.
invoke
(
it
)
},
...
...
@@ -313,7 +319,7 @@ class SpaceRoomListSectionBuilder(
}
})
}
RoomListViewModel
.
SpaceFilterStrategy
.
NONE
->
{
RoomListViewModel
.
SpaceFilterStrategy
.
NONE
->
{
// we ignore current space for this one
}
}
...
...
@@ -326,9 +332,15 @@ class SpaceRoomListSectionBuilder(
.
subscribe
{
sections
.
find
{
it
.
sectionName
==
name
}
?.
notificationCount
?.
postValue
(
session
.
getNotificationCountForRooms
(
roomQueryParams
.
process
(
spaceFilterStrategy
,
appStateHandler
.
safeActiveSpaceId
())
))
?.
postValue
(
if
(
countRoomAsNotif
)
{
RoomAggregateNotificationCount
(
it
.
size
,
it
.
size
)
}
else
{
session
.
getNotificationCountForRooms
(
roomQueryParams
.
process
(
spaceFilterStrategy
,
appStateHandler
.
safeActiveSpaceId
())
)
}
)
}.
also
{
onDisposable
.
invoke
(
it
)
}
...
...
vector/src/main/java/im/vector/app/features/spaces/SpacesListViewModel.kt
View file @
f9820cde
...
...
@@ -28,8 +28,7 @@ import dagger.assisted.AssistedInject
import
im.vector.app.AppStateHandler
import
im.vector.app.RoomGroupingMethod
import
im.vector.app.core.platform.VectorViewModel
import
im.vector.app.core.resources.StringProvider
import
im.vector.app.features.ui.UiStateRepository
import
im.vector.app.features.settings.VectorPreferences
import
im.vector.app.group
import
im.vector.app.space
import
io.reactivex.Observable
...
...
@@ -45,6 +44,7 @@ import org.matrix.android.sdk.api.session.room.RoomSortOrder
import
org.matrix.android.sdk.api.session.room.model.Membership
import
org.matrix.android.sdk.api.session.room.model.RoomSummary
import
org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
import
org.matrix.android.sdk.api.session.room.summary.RoomAggregateNotificationCount
import
org.matrix.android.sdk.api.session.user.model.User
import
org.matrix.android.sdk.api.util.toMatrixItem
import
org.matrix.android.sdk.rx.asObservable
...
...
@@ -54,8 +54,7 @@ import java.util.concurrent.TimeUnit
class
SpacesListViewModel
@AssistedInject
constructor
(
@Assisted
initialState
:
SpaceListViewState
,
private
val
appStateHandler
:
AppStateHandler
,
private
val
session
:
Session
,
private
val
stringProvider
:
StringProvider
,
private
val
uiStateRepository
:
UiStateRepository
private
val
vectorPreferences
:
VectorPreferences
)
:
VectorViewModel
<
SpaceListViewState
,
SpaceListAction
,
SpaceListViewEvents
>(
initialState
)
{
@AssistedFactory
...
...
@@ -108,21 +107,34 @@ class SpacesListViewModel @AssistedInject constructor(@Assisted initialState: Sp
}
}.
disposeOnClear
()
// XXX there should be a way to refactor this and share it
session
.
getPagedRoomSummariesLive
(
roomSummaryQueryParams
{
this
.
memberships
=
listOf
(
Membership
.
JOIN
)
this
.
activeSpaceFilter
=
ActiveSpaceFilter
.
ActiveSpace
(
null
)
this
.
activeSpaceFilter
=
ActiveSpaceFilter
.
ActiveSpace
(
null
).
takeIf
{
vectorPreferences
.
labsSpacesOnlyOrphansInHome
()
}
?:
ActiveSpaceFilter
.
None
},
sortOrder
=
RoomSortOrder
.
NONE
).
asObservable
()
.
throttleFirst
(
300
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
Schedulers
.
computation
())
.
subscribe
{
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
)
setState
{
copy
(
homeAggregateCount
=
counts
...
...
@@ -217,7 +229,7 @@ class SpacesListViewModel @AssistedInject constructor(@Assisted initialState: Sp
.
rx
()
.
liveUser
(
session
.
myUserId
)
.
map
{
it
.
getOrNull
()
it
.
getOrNull
()
},
session
.
rx
()
...
...
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