Skip to content
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

[#7819] fix - avoid unnecessary effects when joining/syncing already active public chat #7820

Merged
merged 1 commit into from
May 1, 2019

Conversation

bitsikka
Copy link
Contributor

@bitsikka bitsikka commented Mar 22, 2019

Fixes #7819 - which was created first when all repercussions were not fully known; Later #7952, #7974, #7992 were created as they were discovered.

status: ready

@status-github-bot
Copy link

status-github-bot bot commented Mar 22, 2019

Pull Request Checklist

  • Have you updated the documentation, if impacted (e.g. docs.status.im)?

@status-im-auto
Copy link
Member

status-im-auto commented Mar 22, 2019

Jenkins Builds

Click to see older builds (108)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 6367f75 #1 2019-03-22 17:32:07 ~16 min ios 📦 ipa
✔️ 6367f75 #1 2019-03-22 17:32:48 ~17 min macos 📦 dmg
✔️ 6367f75 #1 2019-03-22 17:35:45 ~20 min android 📦 apk
✔️ 6367f75 #1 2019-03-22 17:35:57 ~20 min android-e2e 📦 apk
✔️ 6367f75 #1 2019-03-22 17:43:40 ~28 min linux 📦 App
✔️ 6367f75 #1 2019-03-23 13:31:17 ~23 min windows 📦 exe
8cd8a69 #2 2019-03-25 15:33:02 ~3 min ios 📄 log
8cd8a69 #2 2019-03-25 15:33:15 ~3 min macos 📄 log
8cd8a69 #2 2019-03-25 15:36:19 ~6 min linux 📄 log
8cd8a69 #2 2019-03-25 15:36:36 ~7 min android 📄 log
8cd8a69 #2 2019-03-25 15:37:18 ~8 min android-e2e 📄 log
cdd677f #3 2019-03-25 15:53:04 ~3 min ios 📄 log
cdd677f #3 2019-03-25 15:53:08 ~3 min macos 📄 log
cdd677f #3 2019-03-25 15:56:34 ~6 min android-e2e 📄 log
cdd677f #3 2019-03-25 15:56:39 ~6 min android 📄 log
cdd677f #3 2019-03-25 15:58:17 ~8 min windows 📄 log
cdd677f #3 2019-03-25 15:58:18 ~8 min linux 📄 log
✔️ d53d422 #6 2019-03-25 16:45:04 ~15 min macos 📦 dmg
✔️ d53d422 #6 2019-03-25 16:45:14 ~15 min ios 📦 ipa
✔️ d53d422 #6 2019-03-25 16:53:00 ~23 min windows 📦 exe
✔️ d53d422 #6 2019-03-25 16:55:09 ~25 min linux 📦 App
✔️ d53d422 #6 2019-03-25 16:56:15 ~26 min android 📦 apk
✔️ d53d422 #6 2019-03-25 16:56:45 ~27 min android-e2e 📦 apk
✔️ 44fbe73 #7 2019-03-25 18:18:40 ~17 min macos 📦 dmg
✔️ 44fbe73 #7 2019-03-25 18:18:51 ~17 min ios 📦 ipa
✔️ 44fbe73 #7 2019-03-25 18:23:51 ~22 min android-e2e 📦 apk
✔️ 44fbe73 #7 2019-03-25 18:26:36 ~24 min windows 📦 exe
✔️ 44fbe73 #7 2019-03-25 18:28:03 ~26 min android 📦 apk
✔️ 44fbe73 #7 2019-03-25 18:31:47 ~30 min linux 📦 App
✔️ ecc5ef8 #8 2019-03-25 19:08:47 ~16 min ios 📦 ipa
✔️ ecc5ef8 #8 2019-03-25 19:09:15 ~17 min macos 📦 dmg
✔️ ecc5ef8 #8 2019-03-25 19:10:45 ~18 min android 📦 apk
✔️ ecc5ef8 #8 2019-03-25 19:14:27 ~22 min linux 📦 App
✔️ ecc5ef8 #8 2019-03-25 19:16:39 ~24 min android-e2e 📦 apk
✔️ ecc5ef8 #8 2019-03-25 19:18:18 ~26 min windows 📦 exe
780a4f8 #9 2019-04-05 14:47:36 ~29 sec ios 📄 log
780a4f8 #9 2019-04-05 14:47:47 ~32 sec macos 📄 log
✔️ 780a4f8 #9 2019-04-05 15:23:27 ~36 min android 📦 apk
✔️ 780a4f8 #9 2019-04-05 15:30:39 ~43 min windows 📦 exe
✔️ 780a4f8 #9 2019-04-05 15:31:07 ~43 min linux 📦 App
✔️ d976eb4 #10 2019-04-05 16:57:29 ~28 min android 📦 apk
✔️ d976eb4 #10 2019-04-05 17:02:12 ~32 min macos 📦 dmg
✔️ d976eb4 #10 2019-04-05 17:04:44 ~35 min ios 📦 ipa
✔️ d976eb4 #10 2019-04-05 17:09:35 ~39 min windows 📦 exe
✔️ d976eb4 #10 2019-04-05 17:10:33 ~40 min linux 📦 App
✔️ cc940de #11 2019-04-08 15:36:31 ~13 min macos 📦 dmg
✔️ cc940de #11 2019-04-08 15:43:17 ~20 min ios 📦 ipa
✔️ cc940de #11 2019-04-08 15:58:37 ~35 min windows 📦 exe
✔️ cc940de #11 2019-04-08 16:00:25 ~37 min linux 📦 App
✔️ cc940de #11 2019-04-08 16:01:31 ~38 min android 📦 apk
✔️ cc940de #11 2019-04-08 18:40:41 ~24 min android-e2e 📦 apk
✔️ 5e63155 #13 2019-04-10 14:25:43 ~17 min macos 📦 dmg
✔️ 5e63155 #13 2019-04-10 14:27:15 ~19 min android-e2e 📦 apk
✔️ 5e63155 #13 2019-04-10 14:33:00 ~25 min android 📦 apk
✔️ 5e63155 #13 2019-04-10 14:35:40 ~27 min linux 📦 App
✔️ 5e63155 #13 2019-04-10 14:42:24 ~34 min windows 📦 exe
✔️ 887d477 #14 2019-04-12 09:15:16 ~15 min macos 📦 dmg
✔️ 887d477 #14 2019-04-12 09:22:16 ~22 min ios 📦 ipa
✔️ 887d477 #14 2019-04-12 09:38:20 ~38 min android-e2e 📦 apk
✔️ 887d477 #14 2019-04-12 09:47:48 ~48 min linux 📦 App
✔️ 887d477 #14 2019-04-12 09:48:08 ~48 min android 📦 apk
✔️ 887d477 #14 2019-04-12 09:49:14 ~49 min windows 📦 exe
✔️ d441d13 #15 2019-04-13 12:17:15 ~15 min macos 📦 dmg
✔️ d441d13 #15 2019-04-13 12:18:45 ~17 min android 📦 apk
✔️ d441d13 #15 2019-04-13 12:21:15 ~19 min android-e2e 📦 apk
✔️ d441d13 #15 2019-04-13 12:23:17 ~21 min linux 📦 App
✔️ d441d13 #15 2019-04-13 12:23:32 ~21 min windows 📦 exe
✔️ d441d13 #15 2019-04-13 12:28:18 ~26 min ios 📦 ipa
✔️ de71029 #16 2019-04-15 20:55:35 ~15 min macos 📦 dmg
✔️ de71029 #16 2019-04-15 20:58:13 ~18 min android 📦 apk
✔️ de71029 #16 2019-04-15 20:59:07 ~19 min linux 📦 App
✔️ de71029 #16 2019-04-15 20:59:48 ~20 min android-e2e 📦 apk
✔️ de71029 #16 2019-04-15 21:00:26 ~20 min windows 📦 exe
✔️ de71029 #16 2019-04-15 21:02:28 ~22 min ios 📦 ipa
✔️ bc0ec6e #17 2019-04-16 18:00:06 ~17 min android 📦 apk
✔️ bc0ec6e #17 2019-04-16 18:01:13 ~18 min macos 📦 dmg
✔️ bc0ec6e #17 2019-04-16 18:03:11 ~20 min linux 📦 App
✔️ bc0ec6e #17 2019-04-16 18:03:38 ~20 min windows 📦 exe
✔️ bc0ec6e #17 2019-04-16 18:04:59 ~22 min ios 📦 ipa
✔️ bc0ec6e #17 2019-04-16 18:06:22 ~23 min android-e2e 📦 apk
✔️ 285df85 #18 2019-04-17 06:54:46 ~16 min macos 📦 dmg
✔️ 285df85 #18 2019-04-17 06:55:36 ~16 min linux 📦 App
✔️ 285df85 #18 2019-04-17 06:56:05 ~17 min android 📦 apk
✔️ 285df85 #18 2019-04-17 06:56:20 ~17 min windows 📦 exe
✔️ 285df85 #18 2019-04-17 07:02:00 ~23 min ios 📦 ipa
1dc4b34 #19 2019-04-26 18:38:28 ~3 min linux 📄 log
1dc4b34 #19 2019-04-26 18:38:35 ~3 min macos 📄 log
1dc4b34 #19 2019-04-26 18:38:38 ~4 min ios 📄 log
1dc4b34 #19 2019-04-26 18:38:43 ~4 min windows 📄 log
1dc4b34 #19 2019-04-26 18:41:12 ~6 min android 📄 log
27d328e #20 2019-04-26 18:46:36 ~4 min ios 📄 log
27d328e #20 2019-04-26 18:46:37 ~4 min macos 📄 log
27d328e #20 2019-04-26 18:46:55 ~4 min linux 📄 log
27d328e #20 2019-04-26 18:47:42 ~5 min windows 📄 log
27d328e #20 2019-04-26 18:49:03 ~6 min android 📄 log
27d328e #20 2019-04-26 18:49:17 ~6 min android-e2e 📄 log
✔️ 2ee5079 #21 2019-04-26 19:04:51 ~14 min macos 📦 dmg
✔️ 2ee5079 #21 2019-04-26 19:04:59 ~15 min linux 📦 App
✔️ 2ee5079 #21 2019-04-26 19:05:36 ~15 min windows 📦 exe
✔️ 2ee5079 #21 2019-04-26 19:06:35 ~16 min android 📦 apk
✔️ 2ee5079 #21 2019-04-26 19:12:33 ~22 min ios 📦 ipa
✔️ 2ee5079 #21 2019-04-26 19:29:18 ~39 min android-e2e 📦 apk
✔️ e90a145 #22 2019-05-01 08:16:50 ~16 min linux 📦 App
✔️ e90a145 #22 2019-05-01 08:17:09 ~17 min android 📦 apk
✔️ e90a145 #22 2019-05-01 08:17:42 ~17 min macos 📦 dmg
✔️ e90a145 #22 2019-05-01 08:23:41 ~23 min ios 📦 ipa
✔️ e90a145 #22 2019-05-01 08:27:09 ~27 min android-e2e 📦 apk
✔️ e90a145 #22 2019-05-01 08:28:12 ~27 min windows 📦 exe
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 8720ce4 #23 2019-05-01 11:38:31 ~14 min macos 📦 dmg
✔️ 8720ce4 #23 2019-05-01 11:39:56 ~16 min android-e2e 📦 apk
✔️ 8720ce4 #23 2019-05-01 11:40:36 ~16 min linux 📦 App
✔️ 8720ce4 #23 2019-05-01 11:41:03 ~17 min android 📦 apk
✔️ 8720ce4 #23 2019-05-01 11:46:20 ~22 min windows 📦 exe
✔️ 8720ce4 #23 2019-05-01 11:49:13 ~25 min ios 📦 ipa
✔️ 8c93bc2 #24 2019-05-01 13:18:30 ~15 min macos 📦 dmg
✔️ 8c93bc2 #24 2019-05-01 13:27:13 ~24 min ios 📦 ipa

Copy link
Contributor

@yenda yenda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice finding, here is how I would recommend to fix it according to guidelines https://github.com/status-im/status-react/blob/develop/doc/codebase-structure-and-guidelines.md

The event :chat.ui/start-public-chat doesn't have a good name for an event, it should say what happened and not what will happen, so something like "chat.ui/public-chat-topic-pressed" for instance.
That way the event will still allow for the inclusion of the semantics that you propose, which is to navigate to the chat if it is already open.

The number one argument for doing this is that we want to keep the logic in the views as small as possible to make things more testable. You can easily write a test that shows that chat.ui/public-chat-topic-pressed returns the effects to navigate to the right chat when it already exists or create the chat and navigate to it when it doesn't, but it is harder to do so if the logic is in the view in the first place.
Also keep in mind that reagent component rerender when their argument are changing, active-chat subscription aggregates a lot of things (contacts, chats, messages..) so it will trigger a lot of unnecessary re-renders (probably not a big deal though in that case)

Keep up the good work and thank you very much for your contributions and interest in learning Clojure!

@bitsikka
Copy link
Contributor Author

bitsikka commented Mar 25, 2019

Nice finding, here is how I would recommend to fix it according to guidelines https://github.com/status-im/status-react/blob/develop/doc/codebase-structure-and-guidelines.md

The event :chat.ui/start-public-chat doesn't have a good name for an event, it should say what happened and not what will happen, so something like "chat.ui/public-chat-topic-pressed" for instance.
That way the event will still allow for the inclusion of the semantics that you propose, which is to navigate to the chat if it is already open.

The number one argument for doing this is that we want to keep the logic in the views as small as possible to make things more testable. You can easily write a test that shows that chat.ui/public-chat-topic-pressed returns the effects to navigate to the right chat when it already exists or create the chat and navigate to it when it doesn't, but it is harder to do so if the logic is in the view in the first place.
Also keep in mind that reagent component rerender when their argument are changing, active-chat subscription aggregates a lot of things (contacts, chats, messages..) so it will trigger a lot of unnecessary re-renders (probably not a big deal though in that case)

Keep up the good work and thank you very much for your contributions and interest in learning Clojure!

Thanks @yenda !

Totally make sense! I see what you mean.

Thanks for a detailed feedback. It did feel a bit off, implementing this PR the way it is.

I shall go about refactoring as you suggested.

@yenda
Copy link
Contributor

yenda commented Mar 25, 2019

@bitsikka yes please, also note that there is other occurrences of start-public-chat event dispatch, for instance in browser

@bitsikka
Copy link
Contributor Author

@bitsikka yes please, also note that there is other occurrences of start-public-chat event dispatch, for instance in browser

Understood. This refactoring will touch a bit wider area.

@bitsikka
Copy link
Contributor Author

@yenda in the changes I just pushed I kept the event name same :chat.ui/start-public-chat for the shake of touching less number of files than necessary. The event with the name and the handler with the same name was used in quite a lot of different places. In some cases the "pressed" part did not make sense.

Maybe this thing is complecting too many concerns? 🤔

Apart from that, now it should handle all cases of checking-chat-exists(only if not, then creating it) and navigating to it.

Should I still change the name?

@bitsikka
Copy link
Contributor Author

Not sure why the builds are failing. Can't see the Details. I get Access Denied when trying to see the details.

@bitsikka
Copy link
Contributor Author

Not sure why the builds are failing. Can't see the Details. I get Access Denied when trying to see the details.

nvm.. circular dependency

src/status_im/chat/models.cljs Outdated Show resolved Hide resolved
@bitsikka
Copy link
Contributor Author

@yenda fixed the if to when as well as including back an desirable(i think) improvement that was causing circular dependency before

@bitsikka
Copy link
Contributor Author

example of "improvement"

an inconsistency bug
there would've been no channel sync between devices if a public chat was created as a result of clicking a Universal link

@yenda
Copy link
Contributor

yenda commented Mar 25, 2019

@bitsikka why did you use a negative predicate dont-sync? instead of sync?, I think even dont-navigate would be better as navigate? but doesn't need to be fixed in this PR. It's weird to have negative predicates and lead to double negations in the code which can be confusing

@bitsikka
Copy link
Contributor Author

bitsikka commented Mar 25, 2019

@bitsikka why did you use a negative predicate dont-sync? instead of sync?, I think even dont-navigate would be better as navigate? but doesn't need to be fixed in this PR. It's weird to have negative predicates and lead to double negations in the code which can be confusing

It is weird indeed - I was just following dont-navigate? which existed before, and it kind-of made sense when coming from dispatch site. dont-sync? is only ever set (to true) in status-im.pairing.core/sync-public-chat, everywhere else it is ignored hence nil/false implicitly by-default.

@yenda
Copy link
Contributor

yenda commented Mar 25, 2019

@bitsikka then you can give it a default value of true

{:keys [dont-navigate? sync?] :or {sync? true} :as opts }

@bitsikka
Copy link
Contributor Author

@bitsikka then you can give it a default value of true

{:keys [dont-navigate? sync?] :or {sync? true} :as opts }

nice 😄 I like that very much 👍

fix coming up

@bitsikka
Copy link
Contributor Author

done!

so far so good

gained a bit! thanks!

@bitsikka bitsikka changed the title [#7819] fix avoid unnecessary steps when (re)starting new chat [#7819] fix - avoid unnecessary effects when joining/syncing already active public chat Apr 13, 2019
@annadanchenko
Copy link

@bitsikka is it ready for review again?

@bitsikka
Copy link
Contributor Author

bitsikka commented Apr 16, 2019

@bitsikka is it ready for review again?

@annadanchenko yes

@bitsikka
Copy link
Contributor Author

this will probably conflict while merging with #7963, so I'll rebase and update it once again after #7963 is merged

Copy link
Member

@flexsurfer flexsurfer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the delay! lgtm, thanks!

@mandrigin
Copy link
Contributor

@yenda is your "Request Changes" still actual? If no, can you dismiss or re-review this?

src/status_im/chat/models.cljs Outdated Show resolved Hide resolved
@yenda
Copy link
Contributor

yenda commented Apr 26, 2019

one change required and good to go

@bitsikka
Copy link
Contributor Author

bitsikka commented Apr 26, 2019

one change required and good to go

@yenda

The Change you requested causes circular dependency, and I don't know yet any other way to avoid that other than the way I approached it. Do you know how else to avoid it?

@bitsikka
Copy link
Contributor Author

@yenda done!

@yenda
Copy link
Contributor

yenda commented Apr 27, 2019

@bitsikka Looks good thanks!

@oskarth oskarth requested review from a team April 30, 2019 03:14
@yenda yenda removed the request for review from a team April 30, 2019 14:32
@yenda yenda self-assigned this Apr 30, 2019
@yenda yenda removed the request for review from a team April 30, 2019 14:33
@churik
Copy link
Member

churik commented May 1, 2019

@bitsikka would appreciate if you can rebase it in latest develop for testing.
Also I didn't quite understand, issues #7952, #7974, #7992 should be addressed in separate PRs, right?
BTW, thanks a lot for uncovering those!

@churik churik self-assigned this May 1, 2019
@bitsikka
Copy link
Contributor Author

bitsikka commented May 1, 2019

@churik rebased

All the issues are handled in this PR

I'm sorry about terse descriptions and lack of tests - will do better next time

Joining already joined public chat causes never ending "Loading..." #7952

  1. In device A add public chat like #status
  2. In same device go to + button and add the same public chat #status

The "Never ending Loading.." part is not happening in my brief test anymore for some reason, However, still the underlaying not necessary and non-visual side-effects to app-db and realm are happening which this PR would prevent

I should've added tests to make this more apparent - sorry about that

upon re-syncing unseen message badges disappear(marked seen) without seeing the new messages #7974

  1. Have a couple of public chats in device A
  2. Pair and sync A with device B
  3. be in Home/Chat list screen on both devices
  4. Wait and let both devices receive messages in any number of public chats (so message badges appear)
  5. In Device A - go to Profile>Devices press "Sync all devices" again
  6. Notice in device B - unread badges disappear even though you have not read the messages in any of the devices yet

new public chat started as a result of clicking a universal link is not synced across paired devices #7992

  1. Have two devices A and B paired and synced
  2. Open a Universal Link for a NEW public chat in device A
  3. Check device B - it does not have the new public chat

Initially, the implementation was such that this had to be in this PR. Implementation changed towards the end with @yenda's guidance, and this should then have been a separate PR, but it is not - it is in this PR as well. Sorry about that.

@statustestbot
Copy link

100% of end-end tests have passed

Total executed tests: 48
Failed tests: 0
Passed tests: 48

Passed tests (48)

Click to expand
1. test_block_user_from_public_chat
Device sessions

2. test_filters_from_daap
Device sessions

3. test_copy_and_paste_messages
Device sessions

4. test_send_transaction_from_daap
Device sessions

5. test_request_and_receive_tokens_in_1_1_chat
Device sessions

6. test_deploy_contract_from_daap
Device sessions

7. test_public_chat_messaging
Device sessions

8. test_password_in_logcat_sign_in
Device sessions

9. test_text_message_1_1_chat
Device sessions

10. test_add_to_contacts
Device sessions

11. test_sign_typed_message (TestRail link is not found)
Device sessions

12. test_unread_messages_counter_1_1_chat
Device sessions

13. test_logcat_send_transaction_from_daap
Device sessions

14. test_send_message_in_group_chat
Device sessions

15. test_logcat_send_transaction_from_wallet
Device sessions

16. test_send_token_with_7_decimals
Device sessions

17. test_modify_transaction_fee_values
Device sessions

18. test_send_eth_from_wallet_to_address
Device sessions

19. test_manage_assets
Device sessions

20. test_logcat_send_transaction_in_1_1_chat
Device sessions

21. test_request_and_receive_eth_in_1_1_chat
Device sessions

22. test_swipe_to_delete_public_chat
Device sessions

23. test_send_emoji
Device sessions

24. test_search_chat_on_home
Device sessions

25. test_logcat_recovering_account
Device sessions

26. test_messaging_in_different_networks
Device sessions

27. test_send_tokens_in_1_1_chat
Device sessions

28. test_network_mismatch_for_send_request_commands
Device sessions

29. test_logcat_sign_message_from_daap
Device sessions

30. test_swipe_to_delete_1_1_chat
Device sessions

31. test_switch_users_and_add_new_account
Device sessions

32. test_send_stt_from_wallet
Device sessions

33. test_send_eth_in_1_1_chat
Device sessions

34. test_login_with_new_account
Device sessions

35. test_send_eth_from_wallet_to_contact
Device sessions

36. test_add_contact_from_public_chat
Device sessions

37. test_send_two_transactions_one_after_another_in_dapp
Device sessions

38. test_password_in_logcat_creating_account
Device sessions

39. test_backup_recovery_phrase
Device sessions

40. test_offline_status
Device sessions

41. test_open_google_com_via_open_dapp
Device sessions

42. test_unread_messages_counter_public_chat
Device sessions

43. test_sign_message_from_daap
Device sessions

44. test_user_can_remove_profile_picture
Device sessions

45. test_share_contact_code_and_wallet_address
Device sessions

46. test_request_eth_in_wallet
Device sessions

47. test_refresh_button_browsing_app_webview
Device sessions

48. test_backup_recovery_phrase_warning_from_wallet
Device sessions

@churik
Copy link
Member

churik commented May 1, 2019

Tested on IOS / Android.
All issues are fixed.
As regression checked devices pairing and creating different types of chats.

Also briefly checked that can install \ join the public chat from Mac OSx build.
@bitsikka thanks for a great job!

…active public chat

Signed-off-by: yenda <eric@status.im>
@yenda yenda merged commit f9e5101 into status-im:develop May 1, 2019
@bitsikka bitsikka deleted the fix/#7819 branch May 1, 2019 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

avoid series of effects involved in start-public-chat if re-adding already active chat
10 participants