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

Communities now correctly listed in pending/joined sections. #14515

Merged
merged 1 commit into from
Dec 13, 2022

Conversation

vkjr
Copy link
Contributor

@vkjr vkjr commented Dec 9, 2022

Summary

Review notes

The behavior of added information box was not really defined (agreed to wait for John on the design meeting), so its adding doesn't really close an issue. Moreover, you won't see it in UI because currently, when you join an open community, it is treated as fully joined even if the user didn't have a network connection at the moment of joining. Not sure if this behavior is correct. @churik, maybe you know. If not, we can probably open a bug.

Platforms

  • Android
  • iOS

status: ready

@vkjr vkjr self-assigned this Dec 9, 2022
@status-github-bot status-github-bot bot added this to REVIEW in Pipeline for QA Dec 9, 2022
@status-im-auto
Copy link
Member

status-im-auto commented Dec 9, 2022

Jenkins Builds

Click to see older builds (20)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ e6b9508 #1 2022-12-09 15:30:48 ~3 min tests 📄log
✔️ e6b9508 #1 2022-12-09 15:34:53 ~7 min android 🤖apk 📲
✔️ e6b9508 #1 2022-12-09 15:34:54 ~7 min android-e2e 🤖apk 📲
✔️ e6b9508 #1 2022-12-09 15:45:13 ~17 min ios 📱ipa 📲
✔️ 67ac994 #2 2022-12-12 17:09:24 ~3 min tests 📄log
✔️ 67ac994 #2 2022-12-12 17:14:11 ~7 min android-e2e 🤖apk 📲
✔️ 67ac994 #2 2022-12-12 17:14:33 ~8 min android 🤖apk 📲
✔️ 67ac994 #2 2022-12-12 17:24:21 ~18 min ios 📱ipa 📲
✔️ ce7f586 #3 2022-12-12 17:45:05 ~2 min tests 📄log
✔️ ce7f586 #3 2022-12-12 17:50:16 ~7 min android 🤖apk 📲
✔️ ce7f586 #3 2022-12-12 17:50:21 ~7 min android-e2e 🤖apk 📲
✔️ ce7f586 #3 2022-12-12 17:57:39 ~15 min ios 📱ipa 📲
c3ff1d1 #4 2022-12-12 18:15:18 ~1 min tests 📄log
✔️ c3ff1d1 #4 2022-12-12 18:21:47 ~8 min android-e2e 🤖apk 📲
✔️ c3ff1d1 #4 2022-12-12 18:22:00 ~8 min android 🤖apk 📲
✔️ c3ff1d1 #4 2022-12-12 18:33:12 ~19 min ios 📱ipa 📲
✔️ 7e2120e #5 2022-12-13 10:09:28 ~2 min tests 📄log
✔️ 7e2120e #5 2022-12-13 10:15:18 ~8 min android-e2e 🤖apk 📲
✔️ 7e2120e #5 2022-12-13 10:17:29 ~10 min android 🤖apk 📲
✔️ 7e2120e #5 2022-12-13 10:24:57 ~17 min ios 📱ipa 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 2a2f926 #6 2022-12-13 13:02:08 ~3 min tests 📄log
✔️ 2a2f926 #6 2022-12-13 13:06:04 ~7 min android 🤖apk 📲
✔️ 2a2f926 #6 2022-12-13 13:06:22 ~7 min android-e2e 🤖apk 📲
✔️ 2a2f926 #6 2022-12-13 13:17:47 ~19 min ios 📱ipa 📲
✔️ 51cf65c #7 2022-12-13 20:14:43 ~2 min tests 📄log
✔️ 51cf65c #7 2022-12-13 20:20:19 ~7 min android 🤖apk 📲
✔️ 51cf65c #7 2022-12-13 20:20:25 ~7 min android-e2e 🤖apk 📲
✔️ 51cf65c #7 2022-12-13 20:29:19 ~16 min ios 📱ipa 📲

@vkjr
Copy link
Contributor Author

vkjr commented Dec 9, 2022

@J-Son89, as I mentioned in review notes, this one doesn't really fix the issue, that it was originally expected to fix, so I'm not sure if I should add the "fixes" header, wdyt?

@@ -159,8 +159,31 @@

(def channel-list-component (memoize channel-list-component-fn))

(defn join-community [{:keys [joined can-join? requested-to-join-at community-color] :as community}]
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -105,6 +105,28 @@
(fn [communities]
(map :id communities)))


;; Return communities splitted by level of user participation. Some communities user
Copy link
Member

@J-Son89 J-Son89 Dec 9, 2022

Choose a reason for hiding this comment

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

Can this comment not go as a doc string in the function?
e.g

(re-frame/reg-sub
:communities/community-ids-by-user-involvement
 :<- [:communities/communities]
"doc string goes here"
...

also imo we only really need the last line
Result map has form: {:joined [id1, id2] :pending [id3, id5] :opened [id4]}"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, docstring doesn't work here, because it is a function call, and looks like reg-sub doesn't support docstring (I tried).
Also, I wasn't able to remove newlines between the description and code - linter argues.

As for description, I would say that mentioning that opened communities remain in database can add a piece of information for the reader

Copy link
Contributor

Choose a reason for hiding this comment

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

@vkjr, you're right about the docstring, we can't use it here, but could you join the comments with the reg-sub call? There are two empty lines between them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ilmotta, for some reason linter returns an error when I put the comments right before the code :-/

Copy link
Contributor

Choose a reason for hiding this comment

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

Such a weird recommendation from cljfmt! You're totally right, I guess if you prefer you can always add the comments at the top of the anonymous function, but not much of an improvement 🤷‍♂️

(re-frame/reg-sub
 :communities/community-ids-by-user-involvement
 :<- [:communities/communities]
 ;; Return communities splitted by level of user participation. Some communities
 ;; user already joined, to some of them join request sent and others were opened
 ;; one day and their data remained in app-db. Result map has form:
 ;; {:joined [id1, id2] :pending [id3, id5] :opened [id4]}"
 (fn [communities]
   (reduce (fn [{:keys [joined pending open] :as acc} community]
             (let [joined? (:joined community)
                   requested? (pos? (:requested-to-join-at community))
                   id (:id community)]
               (cond
                 joined?    (assoc acc :joined (conj joined id))
                 requested? (assoc acc :pending (conj pending id))
                 :else      (assoc acc :opened (conj open id)))))
           {:joined [] :pending [] :opened []}
           communities)))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, nice idea! For me, it really seems like the best option! I would go that way)

@@ -1894,4 +1895,4 @@
"remove-user-from-group": "Remove {{username}} from the group",
"edit-name-image": "Edit name and image",
"owner": "Owner"
}
}
Copy link
Member

Choose a reason for hiding this comment

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

could you please rollback new line

(when-not joined
[quo/button
{:on-press #(rf/dispatch [:bottom-sheet/show-sheet
{:content (constantly [requests.actions/request-to-join community])
Copy link
Member

Choose a reason for hiding this comment

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

why constantly? its hard to read here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part was extracted as-is from a bigger component)

Copy link
Member

Choose a reason for hiding this comment

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

could you change it please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure!

Copy link
Contributor

Choose a reason for hiding this comment

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

Humm, let's not generalize that constantly is hard to read. This is just personal preference. I find it quite clear in many contexts, and it fits like a glove in this piece of code. But of course I'm okay with switching to just (fn [] [requests.actions/request-to-join community])

Copy link
Member

@flexsurfer flexsurfer Dec 10, 2022

Choose a reason for hiding this comment

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

i mean we've never used constantly so im not used to it, so we need to use the same pattern for all such cases in the code, constantly is good in java i guess , to safely have a function with any number of arguments if you don't use them, in javascript we don't care, so constantly is useless

:content-height 300}])
:override-background-color community-color
:style
{:width "100%"
Copy link
Member

Choose a reason for hiding this comment

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

move to styles ns

requested? (pos? (:requested-to-join-at community))
id (:id community)]
(cond
joined? (assoc acc :joined (conj joined id))
Copy link
Member

Choose a reason for hiding this comment

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

update could be used


:opened
[communities-list communities])]))
[communities-list (:opened communities-ids)])]))
Copy link
Contributor

Choose a reason for hiding this comment

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

case without a default branch will throw an exception. If you're sure the tab is always within the valid set of branches, another alternative is to remove case and just use the following:

[communities-list (get communities-ids tab)]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer not to rely on using the same keywords for naming tabs and for naming vectors of communities, since they have different logical meanings and can change in the future. So I would add the :default section with simple error indication to visually catch this case. Wdyt?

:default
       [quo/information-box
        {:type :error
         :icon :i/info}
        (i18n/label :t/error)]
        ```

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes total sense to me @vkjr. Thanks

@@ -46,20 +46,20 @@
:render-fn render-fn}])

(defn segments-community-lists [selected-tab]
(let [communities (rf/sub [:communities/community-ids])
(let [communities-ids (rf/sub [:communities/community-ids-by-user-involvement])
Copy link
Contributor

Choose a reason for hiding this comment

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

Whenever I read <something>-ids, I think it's a collection (it's very conventional), but in reality it's a map indexed by the user "involvement". I would suggest renaming this binding to something like ids-by-user-involvement.

(when node-offline?
[quo/information-box
{:type :informative
:icon :main-icons/info
Copy link
Contributor

Choose a reason for hiding this comment

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

[Guidelines] Use the :i prefix instead of :main-icons.

{:type :informative
:icon :main-icons/info
:style {:margin-top 12}}
(i18n/label :request-processed-after-node-online)])]))
Copy link
Contributor

Choose a reason for hiding this comment

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

[Guidelines] Use the :t qualification in translation keywords.



(re-frame/reg-sub
:communities/community-ids-by-user-involvement
Copy link
Contributor

Choose a reason for hiding this comment

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

How about tests for this new layer-3 subscription? It's begging for some! If it's a new layer-3 subscription such as this one, we should properly test it. Feel free to ping me if it's not clear how to test this. You can find examples in:

  • subs/communities_test.cljs
  • subs/wallet/wallet_test.cljs
  • subs/activity_center_test.cljs

On a side note, I actually think soon we should re-evaluate our minimum requirements for test coverage in PRs.

@vkjr vkjr requested a review from flexsurfer December 12, 2022 17:25
[communities-list communities])]))
[communities-list (:opened ids-by-user-involvement)]

:default
Copy link
Contributor

@ilmotta ilmotta Dec 12, 2022

Choose a reason for hiding this comment

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

Just a minor correction here @vkjr, the default branch in the case macro doesn't take an option, only the cond macro understands that.

;; This explodes :boom: 
(let [tab :unknown]
  (case tab
    :joined  :joined
    :pending :pending
    :opened  :opened
    :default :error))

(let [tab :unknown]
  (cond 
    (= tab :joined)  :joined
    (= tab :pending) :pending
    (= tab :opened)  :opened
    :default         :error))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦 , thanks for noticing!


(def node-offline-information-box
{:type :informative
Copy link
Member

Choose a reason for hiding this comment

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

we should have only styles in style ns, not properties

(def blur-channel-header
{:blur-amount 32
Copy link
Member

Choose a reason for hiding this comment

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

we should have only styles in style ns, not properties

@vkjr vkjr force-pushed the 14456_node_offline_box branch 2 times, most recently from c3ff1d1 to 7e2120e Compare December 13, 2022 10:06
@vkjr vkjr moved this from REVIEW to E2E Tests in Pipeline for QA Dec 13, 2022
@status-im-auto
Copy link
Member

100% of end-end tests have passed

Total executed tests: 8
Failed tests: 0
Passed tests: 8
Not executed tests: 2
IDs of not executed tests: 702807,702808 

Not executed tests (2)

Click to expand
  • Rerun not executed tests
  • Passed tests (8)

    Click to expand

    Class TestDeeplinkOneDeviceNewUI:

    1. test_deep_link_with_invalid_user_public_key_own_profile_key, id: 702774
    Device sessions

    2. test_public_chat_open_using_deep_link, id: 702776
    Device sessions

    3. test_deep_link_open_user_profile, id: 702775
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_pin_messages, id: 702731
    Device sessions

    2. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745
    Device sessions

    3. test_1_1_chat_message_reaction, id: 702730
    Device sessions

    4. test_1_1_chat_text_message_delete_push_disappear, id: 702733
    Device sessions

    Class TestGroupChatMediumMultipleDeviceNewUI:

    1. test_group_chat_pin_messages, id: 702732
    Device sessions

    @vkjr vkjr moved this from E2E Tests to CONTRIBUTOR in Pipeline for QA Dec 13, 2022
    @vkjr vkjr moved this from CONTRIBUTOR to E2E Tests in Pipeline for QA Dec 13, 2022
    @status-im-auto
    Copy link
    Member

    100% of end-end tests have passed

    Total executed tests: 8
    Failed tests: 0
    Passed tests: 8
    Not executed tests: 2
    
    IDs of not executed tests: 702807,702808 
    

    Not executed tests (2)

    Click to expand
  • Rerun not executed tests
  • Passed tests (8)

    Click to expand

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_text_message_delete_push_disappear, id: 702733
    Device sessions

    2. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745
    Device sessions

    3. test_1_1_chat_message_reaction, id: 702730
    Device sessions

    4. test_1_1_chat_pin_messages, id: 702731
    Device sessions

    Class TestGroupChatMediumMultipleDeviceNewUI:

    1. test_group_chat_pin_messages, id: 702732
    Device sessions

    Class TestDeeplinkOneDeviceNewUI:

    1. test_public_chat_open_using_deep_link, id: 702776
    Device sessions

    2. test_deep_link_with_invalid_user_public_key_own_profile_key, id: 702774
    Device sessions

    3. test_deep_link_open_user_profile, id: 702775
    Device sessions

    @vkjr vkjr merged commit 68ea7cd into develop Dec 13, 2022
    Pipeline for QA automation moved this from E2E Tests to DONE Dec 13, 2022
    @vkjr vkjr deleted the 14456_node_offline_box branch December 13, 2022 20:55
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    Archived in project
    Development

    Successfully merging this pull request may close these issues.

    None yet

    5 participants