-
Notifications
You must be signed in to change notification settings - Fork 983
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
Conversation
Jenkins BuildsClick to see older builds (20)
|
@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}] |
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.
👍
src/status_im2/subs/communities.cljs
Outdated
@@ -105,6 +105,28 @@ | |||
(fn [communities] | |||
(map :id communities))) | |||
|
|||
|
|||
;; Return communities splitted by level of user participation. Some communities user |
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.
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]}"
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.
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
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.
@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.
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.
@ilmotta, for some reason linter returns an error when I put the comments right before the code :-/
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.
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)))
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.
Hmm, nice idea! For me, it really seems like the best option! I would go that way)
translations/en.json
Outdated
@@ -1894,4 +1895,4 @@ | |||
"remove-user-from-group": "Remove {{username}} from the group", | |||
"edit-name-image": "Edit name and image", | |||
"owner": "Owner" | |||
} | |||
} |
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.
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]) |
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 constantly? its hard to read here
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 part was extracted as-is from a bigger component)
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.
could you change it please?
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.
sure!
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.
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])
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 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%" |
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.
move to styles ns
src/status_im2/subs/communities.cljs
Outdated
requested? (pos? (:requested-to-join-at community)) | ||
id (:id community)] | ||
(cond | ||
joined? (assoc acc :joined (conj joined 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.
update could be used
|
||
:opened | ||
[communities-list communities])])) | ||
[communities-list (:opened communities-ids)])])) |
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.
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)]
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 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)]
```
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.
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]) |
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.
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 |
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.
[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)])])) |
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.
[Guidelines] Use the :t
qualification in translation keywords.
|
||
|
||
(re-frame/reg-sub | ||
:communities/community-ids-by-user-involvement |
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.
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.
e6b9508
to
67ac994
Compare
[communities-list communities])])) | ||
[communities-list (:opened ids-by-user-involvement)] | ||
|
||
:default |
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.
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))
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.
🤦 , thanks for noticing!
67ac994
to
ce7f586
Compare
|
||
(def node-offline-information-box | ||
{:type :informative |
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.
we should have only styles in style ns, not properties
(def blur-channel-header | ||
{:blur-amount 32 |
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.
we should have only styles in style ns, not properties
c3ff1d1
to
7e2120e
Compare
100% of end-end tests have passed
Not executed tests (2)Passed tests (8)Click to expandClass TestDeeplinkOneDeviceNewUI:
Class TestOneToOneChatMultipleSharedDevicesNewUi:
Class TestGroupChatMediumMultipleDeviceNewUI:
|
7e2120e
to
2a2f926
Compare
100% of end-end tests have passed
Not executed tests (2)Passed tests (8)Click to expandClass TestOneToOneChatMultipleSharedDevicesNewUi:
Class TestGroupChatMediumMultipleDeviceNewUI:
Class TestDeeplinkOneDeviceNewUI:
|
2a2f926
to
51cf65c
Compare
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
status: ready