-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/aris/presence #4090
Feature/aris/presence #4090
Conversation
Presence in RoomDetails and in Room would be nice to have :) I like this PR 💯 like Web |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some remarks, otherwise, good job (not tried)
...-android/src/main/java/org/matrix/android/sdk/internal/session/presence/di/PresenceModule.kt
Outdated
Show resolved
Hide resolved
...rc/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/ReadReceiptHandler.kt
Outdated
Show resolved
Hide resolved
...trix/android/sdk/internal/session/sync/handler/SyncResponsePostTreatmentAggregatorHandler.kt
Outdated
Show resolved
Hide resolved
...dk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomSummaryEntity.kt
Outdated
Show resolved
Hide resolved
matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt
Outdated
Show resolved
Hide resolved
vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt
Outdated
Show resolved
Hide resolved
matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/presence/PresenceService.kt
Outdated
Show resolved
Hide resolved
matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/presence/PresenceService.kt
Outdated
Show resolved
Hide resolved
matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/presence/PresenceService.kt
Outdated
Show resolved
Hide resolved
...android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt
Outdated
Show resolved
Hide resolved
var lastActiveAgo: Long? = null, | ||
var statusMessage: String? = null, | ||
var isCurrentlyActive: Boolean? = null, | ||
var avatarUrl: String? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not storing also the display name?
...oid/src/main/java/org/matrix/android/sdk/internal/database/query/RoomSummaryEntityQueries.kt
Outdated
Show resolved
Hide resolved
...in/java/org/matrix/android/sdk/internal/database/query/presence/UserPresenceEntityQueries.kt
Outdated
Show resolved
Hide resolved
...ix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/presence/PresenceAPI.kt
Outdated
Show resolved
Hide resolved
...ix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/presence/PresenceAPI.kt
Outdated
Show resolved
Hide resolved
...-android/src/main/java/org/matrix/android/sdk/internal/session/presence/di/PresenceModule.kt
Outdated
Show resolved
Hide resolved
...main/java/org/matrix/android/sdk/internal/session/presence/service/DefaultPresenceService.kt
Outdated
Show resolved
Hide resolved
...c/main/java/org/matrix/android/sdk/internal/session/presence/service/task/SetPresenceTask.kt
Outdated
Show resolved
Hide resolved
...c/main/java/org/matrix/android/sdk/internal/session/presence/service/task/SetPresenceTask.kt
Outdated
Show resolved
Hide resolved
...id/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/PresenceSyncHandler.kt
Outdated
Show resolved
Hide resolved
...id/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/PresenceSyncHandler.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work, I know the PR is still Draft, I've just made first remarks (static review).
...roid/src/main/java/org/matrix/android/sdk/internal/session/presence/model/PresenceContent.kt
Outdated
Show resolved
Hide resolved
setPresenceTask.execute(SetPresenceTask.Params(userId, presence, message)) | ||
} | ||
|
||
override suspend fun fetchPresence(userId: String) = getPresenceTask.execute(GetPresenceTask.Params(userId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said by @ganfra you should add a method to get LiveData of a user presence (or if you want to use Flow, it would be better!), to make it live in the UI.
...k-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small remaining remarks
matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/presence/PresenceService.kt
Outdated
Show resolved
Hide resolved
...roid/src/main/java/org/matrix/android/sdk/internal/session/presence/model/PresenceContent.kt
Outdated
Show resolved
Hide resolved
var userPresence: UserPresenceEntity? = null | ||
set(value) { | ||
if (value != field) field = value | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it make sense to test !=
for Realm object, @BillCarsonFr WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I believe it does not make sense, but there are other implementations like this in RoomSummaryEntity:
var latestPreviewableEvent: TimelineEventEntity? = null set(value) { if (value != field) field = value }
var userDrafts: UserDraftsEntity? = null set(value) { if (value != field) field = value }
So if we decide to remove it let's remove it from the other places too, if you agree
...oid/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomMemberSummaryMapper.kt
Outdated
Show resolved
Hide resolved
.equalTo(RoomMemberSummaryEntityFields.USER_ID, userId) | ||
.findAll() | ||
.map { | ||
it.userPresence = userPresenceEntity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it necessary to do this? The link between it.userPresence
and userPresenceEntity
is always the same, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I think you are partially right, we need that only for the first linking, after that it will auto update the changes, so I simply add in the query .isNull(RoomMemberSummaryEntityFields.USER_PRESENCE.
$)
so now it will only do that for the first linking. Do you think there is a better way for the initial linking with Realm?
...android/src/main/java/org/matrix/android/sdk/internal/session/presence/model/UserPresence.kt
Outdated
Show resolved
Hide resolved
roomId, | ||
userId, | ||
roomMember, | ||
// To resolve an edge cases like, on initial sync RoomMemberEventHandler is called after PresenceSyncHandler, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can change and call PresenceSyncHandler after RoomMemberEventHandler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I deep dived into the problem about what is happening. I will also add a comment in the codebase explaining that. Let me explain, when we use insertOrUpdate
then we have two results:
- Insert : A brand new object is created with a primary key etc and is inserted in the DB
- Update: A primary key is already found in that table so the framework replace the existing object with the new one.
The problem is when there is an update! With An example will be more clear. Let's say we have the following record:
[ MyPrimaryKey: 123, catName: "Anna", dogName:"John" , .... etc]
and now lets say server has an update with [ MyPrimaryKey: 123, catName: "Ketty"]
So now if we do insertOrUpdate
with an object containing only MyPrimaryKey and catName. All the other records will be replaced by null, so after the insertOrUpdate our record will be updated to:
[ MyPrimaryKey: 123, catName: "Anna", dogName:NULL , .... etc]
So to avoid this there are two solutions:
- Manually check if the record exists, and update only the fields we want to update
- Pick the old value and pass it to new object creation (Faster if the select is with @indexed fields)
While userId and roomId are @indexed, I think the second one is clearer and more efficient. What do you think?
vector/src/main/java/im/vector/app/core/ui/views/PresenceStateImageView.kt
Show resolved
Hide resolved
Hey Aris, THX for all your Work!!!! |
- Get Presence Status - Set Presence Status * Integrate presence in room details screen * Integrate presence in room people's view * Update UI to support presence * Fix bug when insertOrUpdate was called on RoomMemberEventHandler and override the correct presence value in RoomMemberSummaryEntity * Improve performance on updateUserPresence in RoomMemberSummaryEntity entity * Remarks & linter fixes * Disable presence when there is no m.presence events. In some servers like matrix.org is disabled atm. * Enhance UI Presence on DM room lists to support dark/light theme * Restore missing lines in gradle.properties to speed up debugging
43c1670
to
e4c3457
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I added 2 commits with some cleanup
@@ -56,7 +56,7 @@ | |||
app:layout_constraintEnd_toStartOf="@+id/memberProfileNameView" | |||
app:layout_constraintHorizontal_chainStyle="packed" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="@+id/memberProfileNameView"/> | |||
app:layout_constraintTop_toTopOf="@+id/memberProfileNameView" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should not have @+id
for app
fields. It is quite enough to have it in the declaration level of the view, even if it is later in the code, it does not change anythink for the compiler and reduce the view references in the code. WDYT @bmarty ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this is not mandatory to have +
for referenced ids, but what would be the main advantage to remove them across the whole codebase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will just reduce the view occurrences when you ctrl + click on a viewId. Probably also optimize the code inspection but not sure this is significant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, so this is about dev exp (which is important!). Can you create an issue so we can handle that? Having a lint check would be nice too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Presence Management
User Presence:
["online", "offline", "unavailable"]
Issue #70