Opened 10 years ago
Closed 10 years ago
#5934 closed enhancement (fixed)
Enabling suggestions for @-mentions in groups component
Reported by: | Owned by: | djpaul | |
---|---|---|---|
Milestone: | 2.2 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Groups | Keywords: | has-patch commit |
Cc: |
Description
Everybody loves the new suggestions for @-mentions! - Is there any reason why they currently (BP 2.1.1) aren’t enabled for the groups component?
Looks like suggestions would work properly also for groups by just adding a condition bp_is_groups_component() in bp-activity/bp-activity-functions.php:62 – changing it to:
function bp_activity_maybe_load_mentions_scripts() { $retval = bp_activity_do_mentions() && bp_is_user_active() && ( bp_is_activity_component() || bp_is_groups_component() || bp_is_blog_page() && is_singular() && comments_open() || is_admin() ); return (bool) apply_filters( 'bp_activity_maybe_load_mentions_scripts', $retval ); }
This loads the required script for groups component as well as for group forums.
Then, to enable suggestions specifically for group forums, .bp-suggestions needs to be added in
bp-templates/bp-legacy/buddypress/groups/single/forum/topic.php:141
and in
bp-themes/bp-default/groups/single/forum/topic.php:141
changing it to:
<textarea name="reply_text" id="reply_text" class="bp-suggestions"></textarea>
For bp-default I'll create a pull request in advance.
Wouldn’t that mean a nice improvement?
Attachments (3)
Change History (27)
#2
@
10 years ago
- Keywords has-patch dev-feedback added; needs-patch removed
For bp-default I created a pull request: https://github.com/buddypress/BP-Default/pull/3
#4
@
10 years ago
- Keywords has-patch added; needs-patch removed
Pull request for bp-default created. Patch added. Thank you.
#5
@
10 years ago
why they currently (BP 2.1.1) aren’t enabled for the groups component?
Where precisely within a Group? Do you mean on a Group's activity stream, or legacy bbPress forums, or bbPress 2.x forums?
#7
@
10 years ago
Adding the condition bp_is_groups_component() in bp-activity-functions.php results in performing bp_activity_maybe_load_mentions_scripts() for a Group's activity stream.
Corresponding script also get loaded for Group Forums with that. Specifically for forums, in addition, class="bp-suggestions" needs to be assigned to the textarea in groups/single/forum/topic.php, as target for the mentions script.
With that, suggestions work for legacy bbPress Group forums.
I assume BuddyPress' groups/single/forum/topic.php template is also used for bbPress 2.x forums? If so, suggestions should work for that variant in a similar way.
Please correct me if I'm wrong, thanks.
#8
@
10 years ago
The legacy groups forums are kind of deprecated, I don't know if it's worth supporting it with nice-to-have features like this.
#9
@
10 years ago
I see. But up to now, without the patch for bp-activity/bp-activity-functions.php, suggestions for @-mentions aren't enabled even for a Group's activity stream - besides Group forums.
#10
follow-up:
↓ 11
@
10 years ago
I didn't say that I thought it was a bad idea to add support for the Group Activity Stream, only the legacy Group Forums. I think I thought the bp_is_activity_component
check would also work on the Group Activity screen.
At any rate, the checks in bp_activity_maybe_load_mentions_scripts
are meant to be as specific as possible as this function is called on every page load. There's a lot of screens in Groups that have nothing to do with composing a new activity item, so instead of using bp_is_groups_component
, I'd suggest using bp_is_group_activity
and (if we have to) also bp_is_group_forum_topic_edit
.
#11
in reply to:
↑ 10
@
10 years ago
Replying to DJPaul:
There's a lot of screens in Groups that have nothing to do with composing a new activity item, so instead of using
bp_is_groups_component
, I'd suggest usingbp_is_group_activity
and (if we have to) alsobp_is_group_forum_topic_edit
.
Thank you for carving this out, I totally agree.
#12
@
10 years ago
- Keywords needs-refresh good-first-bug added; has-patch removed
Easy patch for someone to change per the previous comments, so we can get this in for 2.2. :)
#13
@
10 years ago
- Keywords has-patch added; needs-refresh removed
I think we should make sure to only fetch members of the group there. If a group is != public and the user mentioned is not a member of the group...
So i'm suggesting something more like 5934.02.patch
#18
follow-up:
↓ 19
@
10 years ago
I have done some poking, as you can see from the commits. I have added a new patch, 5934.03.patch.
I didn't like the idea of pre-filtering the AJAX response to get the Group ID (I'm not sure that would have worked, anyway), plus we needed some refactoring to let each component filter whether the mentions scripts should load or not, to better match what we try to do elsewhere in BP. I came up with an approach of storing the Group ID in the textarea as a data attribute.
I do not believe we should add support to the legacy Group Forums unless someone has an extremely convincing argument otherwise.
I also think that pre-caching the user's friends, even in a group, generally makes sense most of the time. Since mentions in groups will be new for 2.2, how about we leave this pre-cache as it currently is, and revisit for a future release (and see if we get any user feedback)?
#19
in reply to:
↑ 18
@
10 years ago
Replying to DJPaul:
I also think that pre-caching the user's friends, even in a group, generally makes sense most of the time. Since mentions in groups will be new for 2.2, how about we leave this pre-cache as it currently is, and revisit for a future release (and see if we get any user feedback)?
I'd say, as long as the "not a friend" user suggestion in a group is a member of the group, i think it's ok.
Ideally, if pre-catched friends were members of the current group, it would be great.
#20
@
10 years ago
If there isn't a match in the pre-cached results, then we query the DB for anyone in the users table. I think this is simple and it might confuse users who can't find "Person X" on the Groups Activity, but they can on the Activity Directory (for example).
#21
@
10 years ago
I understand your point. Personally for my community i will change this behavior, as i know my "corporate" members will be afraid to see people that are not member of a private or hidden group listed in the suggestions.
Yeah, and in fact I'd say it was an oversight not to include it in the first place. Can you create a patch?