diff --git a/src/status_im/communities/core.cljs b/src/status_im/communities/core.cljs index f24c21e343..649a7292e0 100644 --- a/src/status_im/communities/core.cljs +++ b/src/status_im/communities/core.cljs @@ -248,13 +248,14 @@ (fx/defn create-channel {:events [::create-channel-confirmation-pressed]} - [cofx community-channel-name community-channel-description] - (let [community-id (fetch-community-id-input cofx)] + [{:keys [db] :as cofx}] + (let [community-id (fetch-community-id-input cofx) + {:keys [name description]} (get db :communities/create-channel)] {::json-rpc/call [{:method "wakuext_createCommunityChat" :params [community-id - {:identity {:display_name community-channel-name + {:identity {:display_name name :color (rand-nth colors/chat-colors) - :description community-channel-description} + :description description} :permissions {:access constants/community-channel-access-no-membership}}] :js-response true :on-success #(re-frame/dispatch [::community-channel-created %]) @@ -262,18 +263,42 @@ (log/error "failed to create community channel" %) (re-frame/dispatch [::failed-to-create-community-channel %]))}]})) +(def community-chat-id-length 68) + +(defn to-community-chat-id [chat-id] + (subs chat-id community-chat-id-length)) + +(fx/defn edit-channel + {:events [::edit-channel-confirmation-pressed]} + [{:keys [db] :as cofx}] + (let [{:keys [name description color community-id]} (get db :communities/create-channel) + chat-id (to-community-chat-id (get db :current-chat-id))] + {::json-rpc/call [{:method "wakuext_editCommunityChat" + :params [community-id + chat-id + {:identity {:display_name name + :description description + :color color} + :permissions {:access constants/community-channel-access-no-membership}}] + :js-response true + :on-success #(re-frame/dispatch [::community-channel-edited %]) + :on-error #(do + (log/error "failed to edit community channel" %) + (re-frame/dispatch [::failed-to-edit-community-channel %]))}]})) + (defn require-membership? [permissions] (not= constants/community-no-membership-access (:access permissions))) -(def community-id-length 68) - (defn can-post? [community _ local-chat-id] - (let [chat-id (subs local-chat-id community-id-length)] + (let [chat-id (to-community-chat-id local-chat-id)] (get-in community [:chats chat-id :can-post?]))) (fx/defn reset-community-id-input [{:keys [db]} id] {:db (assoc db :communities/community-id-input id)}) +(fx/defn reset-channel-info [{:keys [db]}] + {:db (assoc db :communities/create-channel {})}) + (fx/defn invite-people-pressed {:events [::invite-people-pressed]} [cofx id] @@ -292,10 +317,21 @@ (fx/defn create-channel-pressed {:events [::create-channel-pressed]} - [cofx id] + [{:keys [db] :as cofx} id] (fx/merge cofx (reset-community-id-input id) - (navigation/navigate-to :create-community-channel nil))) + (reset-channel-info) + (navigation/navigate-to :communities {:screen :create-community-channel}))) + +(fx/defn edit-channel-pressed + {:events [::edit-channel-pressed]} + [{:keys [db] :as cofx} community-id chat-name description color] + (fx/merge cofx + {:db (assoc db :communities/create-channel {:name chat-name + :description description + :color color + :community-id community-id})} + (navigation/navigate-to :communities {:screen :edit-community-channel}))) (fx/defn community-created {:events [::community-created]} @@ -354,6 +390,13 @@ (navigation/navigate-back) (handle-response response-js))) +(fx/defn community-channel-edited + {:events [::community-channel-edited]} + [cofx response-js] + (fx/merge cofx + (navigation/navigate-back) + (handle-response response-js))) + (fx/defn create-field {:events [::create-field]} [{:keys [db]} field value] @@ -364,6 +407,11 @@ [{:keys [db]} field] {:db (update-in db [:communities/create] dissoc field)}) +(fx/defn create-channel-field + {:events [::create-channel-field]} + [{:keys [db]} field value] + {:db (assoc-in db [:communities/create-channel field] value)}) + (fx/defn member-banned {:events [::member-banned]} [cofx response-js] diff --git a/src/status_im/ethereum/json_rpc.cljs b/src/status_im/ethereum/json_rpc.cljs index 542b91d793..fc874a4323 100644 --- a/src/status_im/ethereum/json_rpc.cljs +++ b/src/status_im/ethereum/json_rpc.cljs @@ -130,6 +130,7 @@ "wakuext_createCommunity" {} "wakuext_editCommunity" {} "wakuext_createCommunityChat" {} + "wakuext_editCommunityChat" {} "wakuext_inviteUsersToCommunity" {} "wakuext_shareCommunity" {} "wakuext_removeUserFromCommunity" {} diff --git a/src/status_im/subs.cljs b/src/status_im/subs.cljs index 57f59a2ae7..5421996a6e 100644 --- a/src/status_im/subs.cljs +++ b/src/status_im/subs.cljs @@ -213,6 +213,7 @@ (reg-root-key-sub :raw-communities :communities) (reg-root-key-sub :communities/create :communities/create) +(reg-root-key-sub :communities/create-channel :communities/create-channel) (reg-root-key-sub :communities/requests-to-join :communities/requests-to-join) (reg-root-key-sub :communities/community-id-input :communities/community-id-input) (reg-root-key-sub :communities/enabled? :communities/enabled?) diff --git a/src/status_im/ui/screens/chat/sheets.cljs b/src/status_im/ui/screens/chat/sheets.cljs index e75e5bd92a..d67ec9a1f6 100644 --- a/src/status_im/ui/screens/chat/sheets.cljs +++ b/src/status_im/ui/screens/chat/sheets.cljs @@ -83,10 +83,14 @@ (fn [{:keys [chat-id group-chat chat-name color]}] [react/view [quo/list-item - {:theme :accent - :title chat-name - :icon [chat-icon/chat-icon-view-chat-sheet - chat-id group-chat chat-name color]}] + {:theme :accent + :title chat-name + :icon [chat-icon/chat-icon-view-chat-sheet + chat-id group-chat chat-name color] + :subtitle (i18n/label :t/view-details) + :chevron true + :accessibility-label :view-community-channel-details + :on-press #(hide-sheet-and-dispatch [:navigate-to :community-channel-details {:chat-id chat-id}])}] [quo/list-item {:theme :accent :title (i18n/label :t/mark-all-read) diff --git a/src/status_im/ui/screens/communities/channel_details.cljs b/src/status_im/ui/screens/communities/channel_details.cljs new file mode 100644 index 0000000000..27697ed1e7 --- /dev/null +++ b/src/status_im/ui/screens/communities/channel_details.cljs @@ -0,0 +1,34 @@ +(ns status-im.ui.screens.communities.channel-details + (:require [quo.core :as quo] + [status-im.utils.handlers :refer [>evt + [quo/animated-header {:left-accessories [{:icon :main-icons/arrow-left + :accessibility-label :back-button + :on-press #(>evt [:navigate-back])}] + :right-accessories (when admin [{:icon :edit + :accessibility-label :invite-button + :on-press #(>evt [::communities/edit-channel-pressed + community-id + chat-name + description + color])}]) + :extended-header (profile-header/extended-header + {:title chat-name + :color color + :subtitle (i18n/label :t/public-channel)}) + :use-insets true} + (when-not (string/blank? description) + [:<> + [quo/list-footer {:color :main} + description] + [quo/separator {:style {:margin-vertical 8}}]])]])) \ No newline at end of file diff --git a/src/status_im/ui/screens/communities/create.cljs b/src/status_im/ui/screens/communities/create.cljs index 1238090d4a..77db27647f 100644 --- a/src/status_im/ui/screens/communities/create.cljs +++ b/src/status_im/ui/screens/communities/create.cljs @@ -115,7 +115,7 @@ :elevation 2}} [icons/icon :main-icons/add {:color colors/white}]]]]]])) -(defn countable-label [{:keys [label value max-length]}] +(defn countable-label [{:keys [label text max-length]}] [rn/view {:style {:padding-bottom 10 :justify-content :space-between :align-items :flex-end @@ -123,10 +123,10 @@ :flex-wrap :nowrap}} [quo/text label] [quo/text {:size :small - :color (if (> (count value) max-length) + :color (if (> (count text) max-length) :negative :secondary)} - (str (count value) "/" max-length)]]) + (str (count text) "/" max-length)]]) (defn form [] (let [{:keys [name description]} (evt - [topbar/topbar {:title (i18n/label :t/create-channel-title)}] - [rn/scroll-view {:style {:flex 1} - :content-container-style {:padding-vertical 16}} - [rn/view {:style {:padding-bottom 16 - :padding-top 10 - :padding-horizontal 16}} - [quo/text-input - {:label (i18n/label :t/name-your-channel) - :placeholder (i18n/label :t/name-your-channel-placeholder) - :on-change-text #(reset! channel-name %) - :auto-focus true}]]] - [toolbar/toolbar - {:show-border? true - :center - [quo/button {:disabled (not (valid? @channel-name)) - :type :secondary - :on-press #(debounce/dispatch-and-chill - [::communities/create-channel-confirmation-pressed @channel-name] - 3000)} - (i18n/label :t/create)]}]]))) +(defn form [] + (let [{:keys [name description]} (evt [::communities/create-channel-field :name %]) + :default-value name + :auto-focus true}]] + [quo/separator {:style {:margin-vertical 10}}] + [rn/view + [create/countable-label {:label (i18n/label :t/description) + :text description + :max-length create/max-description-length}] + [quo/text-input + {:placeholder (i18n/label :t/give-a-short-description-community) + :multiline true + :default-value description + :on-change-text #(>evt [::communities/create-channel-field :description %])}]]]])) + +(defn view [] + (let [{:keys [name description]} ( + [topbar/topbar {:title (i18n/label :t/create-channel-title)}] + [form] + [toolbar/toolbar + {:show-border? true + :center + [quo/button {:disabled (not (valid? name description)) + :type :secondary + :on-press #(debounce/dispatch-and-chill + [::communities/create-channel-confirmation-pressed] + 3000)} + (i18n/label :t/create)]}]])) diff --git a/src/status_im/ui/screens/communities/edit_channel.cljs b/src/status_im/ui/screens/communities/edit_channel.cljs new file mode 100644 index 0000000000..723953a963 --- /dev/null +++ b/src/status_im/ui/screens/communities/edit_channel.cljs @@ -0,0 +1,29 @@ +(ns status-im.ui.screens.communities.edit-channel + (:require [clojure.string :as str] + [quo.core :as quo] + [status-im.i18n.i18n :as i18n] + [status-im.ui.components.toolbar :as toolbar] + [status-im.communities.core :as communities] + [status-im.ui.components.topbar :as topbar] + [status-im.utils.debounce :as debounce] + [status-im.utils.handlers :refer [ + [topbar/topbar {:title (i18n/label :t/edit-channel-title)}] + [create-channel/form] + [toolbar/toolbar + {:show-border? true + :center + [quo/button {:disabled (not (valid? name)) + :type :secondary + :on-press #(debounce/dispatch-and-chill + [::communities/edit-channel-confirmation-pressed] + 3000)} + (i18n/label :t/save)]}]]))) diff --git a/src/status_im/ui/screens/routing/chat_stack.cljs b/src/status_im/ui/screens/routing/chat_stack.cljs index ee39d2fe95..8383e0f269 100644 --- a/src/status_im/ui/screens/routing/chat_stack.cljs +++ b/src/status_im/ui/screens/routing/chat_stack.cljs @@ -9,8 +9,10 @@ [status-im.ui.screens.communities.create :as communities.create] [status-im.ui.screens.communities.import :as communities.import] [status-im.ui.screens.communities.profile :as community.profile] + [status-im.ui.screens.communities.channel-details :as communities.channel-details] [status-im.ui.screens.communities.edit :as community.edit] [status-im.ui.screens.communities.create-channel :as create-channel] + [status-im.ui.screens.communities.edit-channel :as edit-channel] [status-im.ui.screens.communities.membership :as membership] [status-im.ui.screens.communities.members :as members] [status-im.ui.screens.communities.requests-to-join :as requests-to-join] @@ -54,32 +56,40 @@ :component members/members-container} {:name :community-requests-to-join :component requests-to-join/requests-to-join-container} - {:name :create-community-channel - :component create-channel/create-channel}]]) + {:name :community-channel-details + :insets {:top false} + :component communities.channel-details/view}]]) (defn communities [] [communities-stack {:header-mode :none} - (concat - [{:name :communities - :insets {:bottom true - :top false} - :component communities/communities} - {:name :community-import - :insets {:bottom true - :top false} - :component communities.import/view}] - [{:name :community-edit - :insets {:bottom true - :top false} - :component community.edit/edit} - {:name :community-create - :insets {:bottom true - :top false} - :component communities.create/view} - {:name :community-membership - :insets {:bottom true - :top false} - :component membership/membership}])]) + [{:name :communities + :insets {:bottom true + :top false} + :component communities/communities} + {:name :community-import + :insets {:bottom true + :top false} + :component communities.import/view} + {:name :community-edit + :insets {:bottom true + :top false} + :component community.edit/edit} + {:name :community-create + :insets {:bottom true + :top false} + :component communities.create/view} + {:name :community-membership + :insets {:bottom true + :top false} + :component membership/membership} + {:name :create-community-channel + :insets {:bottom true + :top false} + :component create-channel/view} + {:name :edit-community-channel + :insets {:bottom true + :top false} + :component edit-channel/view}]]) (defn new-group-chat [] [group-stack {:header-mode :none diff --git a/status-go-version.json b/status-go-version.json index 844cdc1641..f6b3cb9e99 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -2,7 +2,7 @@ "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh ' instead", "owner": "status-im", "repo": "status-go", - "version": "v0.79.7", - "commit-sha1": "60de443e89bd6a5d4f5b71e7038528d27f26090b", - "src-sha256": "0gjgkqyvpbwg8drwi2mpcan5vxqrnrzl1j0ccmm2m8vq7j3b1332" + "version": "v0.79.10", + "commit-sha1": "d5782fffafc0acde103842f63bccc787181ed8f9", + "src-sha256": "1s4wvvf70szadwp4mqlrb658n6rvkjnfswhkq5vkfqcya3ppw4w2" } diff --git a/translations/en.json b/translations/en.json index 59021d4ebd..f6f1b57052 100644 --- a/translations/en.json +++ b/translations/en.json @@ -167,6 +167,7 @@ "name-your-channel": "Name your channel", "name-your-channel-placeholder": "Channel name", "give-a-short-description": "Give a short description", + "describe-channel": "Describe the channel", "communities-alpha": "Communities (alpha)", "communities-verified": "✓ Verified Status Community", "communities-enabled": "Communities enabled", @@ -187,6 +188,7 @@ "new-community-title": "New community", "membership-title": "Membership requirement", "create-channel-title": "New channel", + "edit-channel-title": "Edit channel", "community-thumbnail-image": "Thumbnail image", "community-thumbnail-upload": "Upload", "community-image-take": "Take a photo", @@ -1534,8 +1536,9 @@ "one-week": "One week", "one-month": "One month", "my-profile": "My profile", - "default-sync-period": "Sync history for", "bip39-password-placeholder": "BIP39 password", + "public-channel": "Public channel", + "default-sync-period": "Sync history for", "anonymous-usage-data": "Anonymous usage data", "anonymous-usage-data-subtitle": "Share anonymous, end-to-end ecrypted data about how you use Status.", "share-anonymous-usage-data": "Share anonymous usage data",