cuny-academic-commons / bp-event-organiser

Allows Event Organiser plugin events to be assigned to BuddyPress groups and generates a group calendar page for each group
GNU General Public License v2.0
3 stars 1 forks source link

Pre-fetch user groups for autocomplete #42

Open boonebgorges opened 9 years ago

boonebgorges commented 9 years ago

We've had a report in testing about lag when fetching groups via autocomplete. Most people will be a member of fairly few few groups, so how about just loading them all into a JS object on pageload, and avoiding AJAX altogether? Only question would be what to do about super admins - maybe tack an item to the end of the suggestion list "Search all site groups", which would fire an AJAX request.

r-a-y commented 9 years ago

I hardcoded a delay of 500ms to the AJAX lookup to prevent too much querying. Perhaps I can drop this value in half? https://github.com/cuny-academic-commons/bp-event-organiser/blob/master/assets/js/group-select.js#L77

boonebgorges commented 9 years ago

I suppose this would be OK, but it also means that no results will be returned in some cases, right? That seems like a dead end.

On 05/12/15 12:16, r-a-y wrote:

I hardcoded a delay of 500ms to the AJAX lookup to prevent too much querying. Perhaps I can drop this value in half? https://github.com/cuny-academic-commons/bp-event-organiser/blob/master/assets/js/group-select.js#L77

— Reply to this email directly or view it on GitHub https://github.com/cuny-academic-commons/bp-event-organiser/issues/42#issuecomment-101335493.

r-a-y commented 9 years ago

Maybe only show the "Groups" metabox if the logged-in user has groups (excluding super admins)?

boonebgorges commented 9 years ago

Yeah, definitely only show the metabox if the user has groups.

Forget my comment here https://github.com/cuny-academic-commons/bp-event-organiser/issues/42#issuecomment-101343841 - I was confusing a delay with a timeout.

The basic issue is this: if a user is a member of 5 groups, it seems like a waste to make them go back to the server to match group names - this process places a load on the server, by reloading WP, and introduces latency due to network effects. IMO it's worth the minor inconvenience to super admins (that they won't be able to add groups of which they're not a member) to make performance better for everyone else. Maybe the super admin issue can be addressed by using AJAX in the Dashboard only, so that if an admin needed to associate an event with groups he's not a member of, it'd have to be done in wp-admin.