Skip to:
Content

BuddyPress.org

Changeset 12941


Ignore:
Timestamp:
05/01/2021 11:58:20 AM (5 years ago)
Author:
imath
Message:

Nouveau: only handle Messages supported views with the Backbone router

When an unsupported view is generated by a plugin (eg: adding a new Messages Component sub nav item), it is skipped by the Backbone router and the link attached to it is loaded the traditional way on click. If the current screen has been added by a plugin, the sub nav click handler also leaves the event loads the page traditionally.

Props Venutius

Fixes #8430

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/js/buddypress-messages.js

    r12856 r12941  
    11/* global wp, BP_Nouveau, _, Backbone, tinymce, tinyMCE */
    22/* jshint devel: true */
    3 /* @version 3.1.0 */
     3/* @since 3.0.0 */
     4/* @version 8.0.0 */
    45window.wp = window.wp || {};
    56window.bp = window.bp || {};
     
    5253                        // Then listen to nav click and load the appropriate view.
    5354                        $( '#subnav a' ).on( 'click', function( event ) {
     55                                var view_id = $( event.target ).prop( 'id' ),
     56                                    supportedView = [ 'inbox', 'starred', 'sentbox', 'compose' ];
     57
     58                                if ( -1 === _.indexOf( supportedView, view_id ) || 'unsupported' === self.box ) {
     59                                        return event;
     60                                }
     61
    5462                                event.preventDefault();
    55 
    56                                 var view_id = $( event.target ).prop( 'id' );
    5763
    5864                                // Remove the editor to be sure it will be added dynamically later.
     
    603609                                                } else {
    604610                                                        usernames = usernames.map( function( username ) {
    605                                                                 username = $.trim( username );
     611                                                                username = username.trim();
    606612                                                                return username;
    607613                                                        } );
    608614
    609                                                         if ( ! usernames || ! $.isArray( usernames ) ) {
     615                                                        if ( ! usernames || ! _.isArray( usernames ) ) {
    610616                                                                errors.push( 'send_to' );
    611617                                                        }
     
    13831389        bp.Nouveau.Messages.Router = Backbone.Router.extend( {
    13841390                routes: {
    1385                         'compose/' : 'composeMessage',
    1386                         'view/:id/': 'viewMessage',
    1387                         'sentbox/' : 'sentboxView',
    1388                         'starred/' : 'starredView',
    1389                         'inbox/'   : 'inboxView',
    1390                         ''        : 'inboxView'
     1391                        'compose/'    : 'composeMessage',
     1392                        'view/:id/'   : 'viewMessage',
     1393                        'sentbox/'    : 'sentboxView',
     1394                        'starred/'    : 'starredView',
     1395                        'inbox/'      : 'inboxView',
     1396                        ''            : 'inboxView',
     1397                        '*unSupported': 'unSupported'
    13911398                },
    13921399
     
    14211428                },
    14221429
     1430                unSupported: function() {
     1431                        bp.Nouveau.Messages.box = 'unsupported';
     1432                },
     1433
    14231434                inboxView: function() {
    14241435                        bp.Nouveau.Messages.box = 'inbox';
Note: See TracChangeset for help on using the changeset viewer.