Ensure users can share a community url (#19710)
* fix: ensure :communities/share-community-url-with-data is defined * fix: ensure we show the share-sheet when pressing the community share-action * fix: ensure we use the correct share-sheet title when sharing a community * e2e: updated inviting contacts to community flow * tweak: remove extra url message when sharing community url on android * tweak: remove extra url message when sharing community channel url on android * tidy: remove redundant event handler for sharing community url --------- Co-authored-by: Yevheniia Berdnyk <ie.berdnyk@gmail.com>
This commit is contained in:
parent
8c26125e52
commit
a1490d414c
|
@ -112,7 +112,7 @@
|
||||||
{:icon :i/share
|
{:icon :i/share
|
||||||
:accessibility-label :share-community
|
:accessibility-label :share-community
|
||||||
:label (i18n/label :t/share-community)
|
:label (i18n/label :t/share-community)
|
||||||
:on-press #(hide-sheet-and-dispatch [:communities/share-community-pressed id])})
|
:on-press #(rf/dispatch [:communities/share-community-pressed id])})
|
||||||
|
|
||||||
(defn leave-community
|
(defn leave-community
|
||||||
[id color]
|
[id color]
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
(ns status-im.contexts.communities.sharing.events
|
(ns status-im.contexts.communities.sharing.events
|
||||||
(:require [legacy.status-im.data-store.chats :as data-store.chats]
|
(:require [legacy.status-im.data-store.chats :as data-store.chats]
|
||||||
[react-native.platform :as platform]
|
[react-native.platform :as platform]
|
||||||
[react-native.share :as share]
|
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
@ -15,8 +14,7 @@
|
||||||
(rf/reg-event-fx :communities/share-community-pressed
|
(rf/reg-event-fx :communities/share-community-pressed
|
||||||
(fn [{:keys [db]} [id]]
|
(fn [{:keys [db]} [id]]
|
||||||
{:db (assoc db :communities/community-id-input id)
|
{:db (assoc db :communities/community-id-input id)
|
||||||
:fx [[:dispatch [:hide-bottom-sheet]]
|
:fx [[:dispatch [:communities/share-community-url-with-data id]]]}))
|
||||||
[:dispatch [:open-modal :legacy-invite-people-community {:id id}]]]}))
|
|
||||||
|
|
||||||
(rf/reg-event-fx :communities/share-community-confirmation-pressed
|
(rf/reg-event-fx :communities/share-community-confirmation-pressed
|
||||||
(fn [_ [users-public-keys community-id]]
|
(fn [_ [users-public-keys community-id]]
|
||||||
|
@ -52,7 +50,6 @@
|
||||||
:linkMetadata {:title title}}]}
|
:linkMetadata {:title title}}]}
|
||||||
{:title title
|
{:title title
|
||||||
:subject title
|
:subject title
|
||||||
:message url
|
|
||||||
:url url
|
:url url
|
||||||
:isNewTask true})}]))]
|
:isNewTask true})}]))]
|
||||||
{:fx [[:dispatch [:communities/get-community-channel-share-data chat-id on-success]]]})))
|
{:fx [[:dispatch [:communities/get-community-channel-share-data chat-id on-success]]]})))
|
||||||
|
@ -70,6 +67,24 @@
|
||||||
:chat-id chat-id
|
:chat-id chat-id
|
||||||
:event :communities/get-community-channel-share-data}))}]})))
|
:event :communities/get-community-channel-share-data}))}]})))
|
||||||
|
|
||||||
|
(rf/reg-event-fx :communities/share-community-url-with-data
|
||||||
|
(fn [_ [community-id]]
|
||||||
|
(let [title (i18n/label :t/community-on-status)
|
||||||
|
on-success (fn [url]
|
||||||
|
(rf/dispatch [:open-share
|
||||||
|
{:options (if platform/ios?
|
||||||
|
{:activityItemSources
|
||||||
|
[{:placeholderItem {:type :text
|
||||||
|
:content title}
|
||||||
|
:item {:default {:type :url
|
||||||
|
:content url}}
|
||||||
|
:linkMetadata {:title title}}]}
|
||||||
|
{:title title
|
||||||
|
:subject title
|
||||||
|
:url url
|
||||||
|
:isNewTask true})}]))]
|
||||||
|
{:fx [[:dispatch [:communities/get-community-share-data community-id on-success]]]})))
|
||||||
|
|
||||||
(rf/reg-event-fx :communities/get-community-share-data
|
(rf/reg-event-fx :communities/get-community-share-data
|
||||||
(fn [_ [community-id on-success]]
|
(fn [_ [community-id on-success]]
|
||||||
{:json-rpc/call
|
{:json-rpc/call
|
||||||
|
@ -81,21 +96,3 @@
|
||||||
{:error err
|
{:error err
|
||||||
:community-id community-id
|
:community-id community-id
|
||||||
:event :communities/get-community-share-data}))}]}))
|
:event :communities/get-community-share-data}))}]}))
|
||||||
|
|
||||||
(rf/reg-event-fx :communities/share-community-channel-url-with-data
|
|
||||||
(fn [_ [chat-id]]
|
|
||||||
(let [title (i18n/label :t/channel-on-status)
|
|
||||||
on-success (fn [url]
|
|
||||||
(share/open
|
|
||||||
(if platform/ios?
|
|
||||||
{:activityItemSources [{:placeholderItem {:type "text"
|
|
||||||
:content title}
|
|
||||||
:item {:default {:type "url"
|
|
||||||
:content url}}
|
|
||||||
:linkMetadata {:title title}}]}
|
|
||||||
{:title title
|
|
||||||
:subject title
|
|
||||||
:message url
|
|
||||||
:url url
|
|
||||||
:isNewTask true})))]
|
|
||||||
{:fx [[:dispatch [:communities/get-community-channel-share-data chat-id on-success]]]})))
|
|
||||||
|
|
|
@ -275,7 +275,7 @@ class TestActivityMultipleDevicePR(MultipleSharedDeviceTestCase):
|
||||||
self.channel_1.send_message(self.text_message)
|
self.channel_1.send_message(self.text_message)
|
||||||
|
|
||||||
self.community_1, self.community_2 = self.home_1.get_community_view(), self.home_2.get_community_view()
|
self.community_1, self.community_2 = self.home_1.get_community_view(), self.home_2.get_community_view()
|
||||||
self.community_1.share_community(self.community_name, self.username_2)
|
self.community_1.invite_to_community(self.community_name, self.username_2)
|
||||||
self.home_1.get_to_community_channel_from_home(self.community_name)
|
self.home_1.get_to_community_channel_from_home(self.community_name)
|
||||||
|
|
||||||
self.chat_2 = self.home_2.get_chat(self.username_1).click()
|
self.chat_2 = self.home_2.get_chat(self.username_1).click()
|
||||||
|
@ -414,7 +414,7 @@ class TestActivityMultipleDevicePRTwo(MultipleSharedDeviceTestCase):
|
||||||
self.channel_1.send_message(self.text_message)
|
self.channel_1.send_message(self.text_message)
|
||||||
|
|
||||||
self.community_1, self.community_2 = self.home_1.get_community_view(), self.home_2.get_community_view()
|
self.community_1, self.community_2 = self.home_1.get_community_view(), self.home_2.get_community_view()
|
||||||
self.community_1.share_community(self.community_name, self.username_2)
|
self.community_1.invite_to_community(self.community_name, self.username_2)
|
||||||
self.home_1.get_to_community_channel_from_home(self.community_name)
|
self.home_1.get_to_community_channel_from_home(self.community_name)
|
||||||
|
|
||||||
self.chat_2 = self.home_2.get_chat(self.username_1).click()
|
self.chat_2 = self.home_2.get_chat(self.username_1).click()
|
||||||
|
@ -472,7 +472,7 @@ class TestActivityMultipleDevicePRTwo(MultipleSharedDeviceTestCase):
|
||||||
self.channel_name = "dogs"
|
self.channel_name = "dogs"
|
||||||
self.home_1.create_community(community_type="closed")
|
self.home_1.create_community(community_type="closed")
|
||||||
self.home_1.reopen_app()
|
self.home_1.reopen_app()
|
||||||
self.community_1.share_community(community_name, self.username_2)
|
self.community_1.invite_to_community(community_name, self.username_2)
|
||||||
|
|
||||||
self.home_2.just_fyi("Request access to community")
|
self.home_2.just_fyi("Request access to community")
|
||||||
self.home_2.navigate_back_to_home_view()
|
self.home_2.navigate_back_to_home_view()
|
||||||
|
|
|
@ -315,7 +315,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
|
||||||
self.channel_1.send_message(self.text_message)
|
self.channel_1.send_message(self.text_message)
|
||||||
|
|
||||||
self.community_1, self.community_2 = self.home_1.get_community_view(), self.home_2.get_community_view()
|
self.community_1, self.community_2 = self.home_1.get_community_view(), self.home_2.get_community_view()
|
||||||
self.community_1.share_community(self.community_name, self.username_2)
|
self.community_1.invite_to_community(self.community_name, self.username_2)
|
||||||
self.home_1.get_to_community_channel_from_home(self.community_name)
|
self.home_1.get_to_community_channel_from_home(self.community_name)
|
||||||
|
|
||||||
self.home_2.just_fyi("Send message to contact (need for blocking contact) test")
|
self.home_2.just_fyi("Send message to contact (need for blocking contact) test")
|
||||||
|
@ -831,7 +831,7 @@ class TestCommunityMultipleDeviceMergedTwo(MultipleSharedDeviceTestCase):
|
||||||
self.home_1.create_community(community_type="open")
|
self.home_1.create_community(community_type="open")
|
||||||
|
|
||||||
self.community_1, self.community_2 = self.home_1.get_community_view(), self.home_2.get_community_view()
|
self.community_1, self.community_2 = self.home_1.get_community_view(), self.home_2.get_community_view()
|
||||||
self.community_1.share_community(self.community_name, self.username_2)
|
self.community_1.invite_to_community(self.community_name, self.username_2)
|
||||||
self.channel_1 = self.home_1.get_to_community_channel_from_home(self.community_name)
|
self.channel_1 = self.home_1.get_to_community_channel_from_home(self.community_name)
|
||||||
|
|
||||||
self.home_2.just_fyi("Send message to contact (need for blocking contact) test")
|
self.home_2.just_fyi("Send message to contact (need for blocking contact) test")
|
||||||
|
@ -1003,7 +1003,7 @@ class TestCommunityMultipleDeviceMergedTwo(MultipleSharedDeviceTestCase):
|
||||||
self.home_1.just_fyi("Device 1 creates a closed community")
|
self.home_1.just_fyi("Device 1 creates a closed community")
|
||||||
self.home_1.create_community(community_type="closed")
|
self.home_1.create_community(community_type="closed")
|
||||||
community_name = "closed community"
|
community_name = "closed community"
|
||||||
self.community_1.share_community(community_name, self.username_2)
|
self.community_1.invite_to_community(community_name, self.username_2)
|
||||||
self.community_1.get_to_community_channel_from_home(community_name, "general")
|
self.community_1.get_to_community_channel_from_home(community_name, "general")
|
||||||
control_message_general_chat = "this message should be visible to the user before joining"
|
control_message_general_chat = "this message should be visible to the user before joining"
|
||||||
self.channel_1.send_message(control_message_general_chat)
|
self.channel_1.send_message(control_message_general_chat)
|
||||||
|
@ -1103,7 +1103,7 @@ class TestCommunityMultipleDeviceMergedTwo(MultipleSharedDeviceTestCase):
|
||||||
self.home_1.just_fyi("Device 1 creates open community")
|
self.home_1.just_fyi("Device 1 creates open community")
|
||||||
self.home_1.create_community(community_type="open")
|
self.home_1.create_community(community_type="open")
|
||||||
community_name = "open community"
|
community_name = "open community"
|
||||||
self.community_1.share_community(community_name, self.username_2)
|
self.community_1.invite_to_community(community_name, self.username_2)
|
||||||
self.community_1.get_to_community_channel_from_home(community_name, "general")
|
self.community_1.get_to_community_channel_from_home(community_name, "general")
|
||||||
control_message_general_chat = "this message should be visible to the user before joining"
|
control_message_general_chat = "this message should be visible to the user before joining"
|
||||||
self.channel_1.send_message(control_message_general_chat)
|
self.channel_1.send_message(control_message_general_chat)
|
||||||
|
|
|
@ -322,6 +322,7 @@ class BaseView(object):
|
||||||
self.qr_code_image = Button(self.driver, accessibility_id="qr-code-image")
|
self.qr_code_image = Button(self.driver, accessibility_id="qr-code-image")
|
||||||
self.sign_in_phrase = SignInPhraseText(self.driver)
|
self.sign_in_phrase = SignInPhraseText(self.driver)
|
||||||
self.toast_content_element = BaseElement(self.driver, accessibility_id="toast-content")
|
self.toast_content_element = BaseElement(self.driver, accessibility_id="toast-content")
|
||||||
|
self.next_button = Button(self.driver, accessibility_id="next-button")
|
||||||
|
|
||||||
# share contact screen
|
# share contact screen
|
||||||
self.show_qr_button = Button(self.driver, accessibility_id="show-qr-button")
|
self.show_qr_button = Button(self.driver, accessibility_id="show-qr-button")
|
||||||
|
|
|
@ -386,6 +386,7 @@ class CommunityView(HomeView):
|
||||||
self.leave_community_button = Button(self.driver, translation_id="leave-community")
|
self.leave_community_button = Button(self.driver, translation_id="leave-community")
|
||||||
self.edit_community_button = Button(self.driver, translation_id="edit-community")
|
self.edit_community_button = Button(self.driver, translation_id="edit-community")
|
||||||
self.share_community_button = Button(self.driver, accessibility_id="share-community")
|
self.share_community_button = Button(self.driver, accessibility_id="share-community")
|
||||||
|
self.invite_people_from_contacts_button = Button(self.driver, accessibility_id="invite-people-from-contacts")
|
||||||
|
|
||||||
# Members
|
# Members
|
||||||
self.invite_people_button = Button(self.driver, accessibility_id="community-invite-people")
|
self.invite_people_button = Button(self.driver, accessibility_id="community-invite-people")
|
||||||
|
@ -471,37 +472,20 @@ class CommunityView(HomeView):
|
||||||
Button(self.driver, xpath="//*[starts-with(@text,'%s')]%s" % (username, decline_suffix)).click()
|
Button(self.driver, xpath="//*[starts-with(@text,'%s')]%s" % (username, decline_suffix)).click()
|
||||||
self.close_button.click()
|
self.close_button.click()
|
||||||
|
|
||||||
# Should not be used anymore, outdated flow
|
def invite_to_community(self, community_name, user_names_to_invite):
|
||||||
def send_invite_to_community(self, community_name, user_names_to_invite):
|
|
||||||
if isinstance(user_names_to_invite, str):
|
if isinstance(user_names_to_invite, str):
|
||||||
user_names_to_invite = [user_names_to_invite]
|
user_names_to_invite = [user_names_to_invite]
|
||||||
self.driver.info("Send %s invite to community" % ', '.join(map(str, user_names_to_invite)))
|
self.driver.info("Share to %s community" % ', '.join(map(str, user_names_to_invite)))
|
||||||
self.jump_to_communities_home()
|
|
||||||
home = self.get_home_view()
|
|
||||||
community_element = home.get_chat(community_name, community=True)
|
|
||||||
community_element.long_press_until_element_is_shown(self.view_members_button)
|
|
||||||
self.view_members_button.click_until_presence_of_element(self.invite_button)
|
|
||||||
self.invite_button.click()
|
|
||||||
for user_name in user_names_to_invite:
|
|
||||||
user_contact = self.element_by_text_part(user_name)
|
|
||||||
user_contact.scroll_and_click()
|
|
||||||
self.share_invite_button.click_until_presence_of_element(self.invite_button)
|
|
||||||
self.back_button.click_until_presence_of_element(self.plus_button)
|
|
||||||
|
|
||||||
def share_community(self, community_name, user_names_to_share):
|
|
||||||
if isinstance(user_names_to_share, str):
|
|
||||||
user_names_to_share = [user_names_to_share]
|
|
||||||
self.driver.info("Share to %s community" % ', '.join(map(str, user_names_to_share)))
|
|
||||||
self.jump_to_communities_home()
|
self.jump_to_communities_home()
|
||||||
home = self.get_home_view()
|
home = self.get_home_view()
|
||||||
home.communities_tab.click()
|
home.communities_tab.click()
|
||||||
community_element = home.get_chat(community_name, community=True)
|
community_element = home.get_chat(community_name, community=True)
|
||||||
community_element.long_press_until_element_is_shown(self.share_community_button)
|
community_element.long_press_until_element_is_shown(self.share_community_button)
|
||||||
self.share_community_button.click()
|
self.invite_people_from_contacts_button.click()
|
||||||
for user_name in user_names_to_share:
|
for user_name in user_names_to_invite:
|
||||||
xpath = "//*[@content-desc='user-avatar']/following-sibling::android.widget.TextView[@text='%s']" % user_name
|
xpath = "//*[@content-desc='user-avatar']/following-sibling::android.widget.TextView[@text='%s']" % user_name
|
||||||
Button(self.driver, xpath=xpath).click()
|
Button(self.driver, xpath=xpath).click()
|
||||||
self.share_invite_button.click()
|
self.next_button.click()
|
||||||
|
|
||||||
|
|
||||||
class PreviewMessage(ChatElementByText):
|
class PreviewMessage(ChatElementByText):
|
||||||
|
|
|
@ -330,7 +330,6 @@ class HomeView(BaseView):
|
||||||
# New UI bottom sheet
|
# New UI bottom sheet
|
||||||
self.start_a_new_chat_bottom_sheet_button = Button(self.driver, accessibility_id="start-a-new-chat")
|
self.start_a_new_chat_bottom_sheet_button = Button(self.driver, accessibility_id="start-a-new-chat")
|
||||||
self.add_a_contact_chat_bottom_sheet_button = Button(self.driver, accessibility_id="add-a-contact")
|
self.add_a_contact_chat_bottom_sheet_button = Button(self.driver, accessibility_id="add-a-contact")
|
||||||
self.setup_chat_button = Button(self.driver, accessibility_id="next-button")
|
|
||||||
|
|
||||||
# Activity centre
|
# Activity centre
|
||||||
self.all_activity_tab_button = ActivityTabButton(self.driver, translation_id="all")
|
self.all_activity_tab_button = ActivityTabButton(self.driver, translation_id="all")
|
||||||
|
@ -459,7 +458,7 @@ class HomeView(BaseView):
|
||||||
raise NoSuchElementException(
|
raise NoSuchElementException(
|
||||||
"User with the name '%s' is not in contacts list so can't create a group chat" % user_name)
|
"User with the name '%s' is not in contacts list so can't create a group chat" % user_name)
|
||||||
check_box.click_until_presence_of_element(chat.get_username_checkbox(user_name, state_on=True))
|
check_box.click_until_presence_of_element(chat.get_username_checkbox(user_name, state_on=True))
|
||||||
self.setup_chat_button.click()
|
self.next_button.click()
|
||||||
self.get_sign_in_view().profile_title_input.send_keys(group_chat_name)
|
self.get_sign_in_view().profile_title_input.send_keys(group_chat_name)
|
||||||
chat.create_group_chat_button.click()
|
chat.create_group_chat_button.click()
|
||||||
self.driver.info("## Group chat %s is created successfully!" % group_chat_name, device=False)
|
self.driver.info("## Group chat %s is created successfully!" % group_chat_name, device=False)
|
||||||
|
|
Loading…
Reference in New Issue