-
Notifications
You must be signed in to change notification settings - Fork 984
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
Refactored statuses #2807
Refactored statuses #2807
Conversation
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.
Please motivate this refactoring and add unit tests.
src/status_im/protocol/handlers.cljs
Outdated
message (get-stored-message message-identifier)] | ||
;; proceed with updating status if chat is active, message is in realm and existing | ||
;; status is not already "final" = `:seen` by the user sending the update | ||
(when (and chats-is-active? message (not= :seen (get message :user-statuses from-id))) |
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.
@janherich can you extract message (not= :seen (get message :user-statuses from-id))
so that in result condition will be
(when (and chats-is-active? (not (seen? message from-id))) ..
87522e6
to
7172523
Compare
@rasom done |
7172523
to
6ad62d7
Compare
6ad62d7
to
9df640e
Compare
9df640e
to
3111c63
Compare
3111c63
to
8553f43
Compare
The first issue noticed: In Group chat when contact sends any of /location /request /send and another contact seen the messages - it does not indicated on sender side that someone seen any of three. For text messages/emojii all is fine and it’s indicated on sender side that chat participant seen the message. To reproduce:
TF session representing UserA: https://app.testfairy.com/projects/4803590-status/builds/7396791/sessions/7/?accessToken=wKYxYVkg-xGR9bU/zZg4BkV0EE8 (01:30-03:20) Android 7.0 (Galaxy J7 real device, Status version 0.9.10-494-g3111c630) and iOS (iPhone X, Status version 0.9.11d494) |
Second issue noticed: https://app.testfairy.com/projects/4803622-status/builds/7392267/sessions/24/?accessToken=IFcF1Epo0dBaEz2royLWr5qBAS4 - from 02:23 Steps to reproduce:
Current result: UserA appeared in Chats list of UserB with the counter of unread messages (1 unread message following above steps). |
8553f43
to
06a294a
Compare
Hi @Serhy, the first issue is already fixed, regarding the second one, are you sure it's a regression and it's not happening on develop as well ? |
Moved issue to what seems like right place. Small housekeeping requests: @Serhy Can you please move issue to "PENDING CONTRIBUTOR" (Jan) in future? @janherich Can you please move to "QA TODO" if you request action from QA in future? |
The send/deliver message status looks good in this PR. #2659 fixed as well. However, we are failing on account log in attempt after upgrade, if there was a group chat created in release version. It doesn't happen if only 1-1 chat existed in release version prior upgrade. Both iOS and Android affected. Upgrade from release (0.9.12b) made on 0.9.10-498-g06a294a9+ version TF session with logs and video after upgrade: https://app.testfairy.com/projects/4803622-status/builds/7422116/sessions/25/?accessToken=5900J3aUCqRSfUZgmSynm42W99M Steps to reproduce:
Actual result: |
06a294a
to
6594bba
Compare
Hi @Serhy, I fixed the migration issue mentioned. |
These all looks good: tested on Samsung J7 and iPhone X. |
6594bba
to
52ddccc
Compare
Further refactoring building on #1875, message send/delivery status handling is significantly simplified (don't be fooled by only ~40 LOC removed, it's more like ~80 lines of runtime code less then before when you subtract the realm schema update + migration).
Additionally fixes #2659
Situation before PR
Our logic related to message send/delivery statuses was little bit cluttered.
In each message data object, we had
:message-status
and:user-statuses
and logic updating and displaying those had to take both those places into consideration.Additionally, logic for updating was super bloated, spread in multiple places in
protocol/handlers
ns and I believe it was even inconsistent, which is no surprisewhen you have like 4 places where you do the same checks based on the status
change & current status information.
Situation after PR
Everything related to message send/delivery statuses is held in the
:user-statuses
only.
For incoming message:
Under current public key we have either received (user didn't yet opened the chat with new message) or already seen (chat opened, message displayed) status.
For each other participant, we are informed if the message is delivered to him or seen by him.
For outgoing message:
It's essentially the same as above, only under current-public key, the status signalises that the message is queued to be sent (
:pending
) or already sent (:sent
)I would also like to emphasise that I removed big, complicated effect
::save-message-status!
andmade effect
::pending-messages-save
just dumb facade for realm call without any logic.And that how we should write all our effects (and re-use them), just doing the absolute bare minimum (isolating IO calls), even having simple logic like
(when (#{:message :group-message} type) ...)
in them is bad.The reason why is that we can't really unit test them and whenever we want to reuse the logic with different effects (like we are doing in
status-desktop
) or we would want to have different effect implementation (let's say we are moving from realm to something else), we just have more to code to port (and more possibilities to make mistakes).Additional changes include:
get-message-content-by-id
andget-last-outgoing
of the message data-store ns removed, because they are not used anymorestatus-im.chat.views.input.suggestions
sanitised (proper prefixes, no referring, etc), this was done because I had to touch the ns anyway because of theget-message-content-by-id
removalSteps to test:
status: ready