Skip to:
Content

BuddyPress.org

Changeset 13415


Ignore:
Timestamp:
02/10/2023 03:40:41 AM (3 years ago)
Author:
imath
Message:

BP Nouveau: Make sure the thread ID is transported into thread view

The Backbone based Messages UI of the Nouveau template pack is now looking for the displayed thread ID inside the messages collection if the current thread object hasn't been returned by the Ajax request. This prevent an error that was happening when trying to reply to a thread message after the thread has been displayed without re-requesting the server.

Props casper99

Closes https://github.com/buddypress/buddypress/pull/63
See #8825

Location:
trunk/src/bp-templates/bp-nouveau
Files:
2 edited

Legend:

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

    r13200 r13415  
    156156                <div class="thread-subject">
    157157                        <span class="thread-count">({{data.count}})</span>
    158                         <a class="subject" href="../view/{{data.id}}/">{{data.subject}}</a>
     158                        <a class="subject" href="./view/{{data.id}}/">{{data.subject}}</a>
    159159                </div>
    160160                <p class="excerpt">{{data.excerpt}}</p>
  • trunk/src/bp-templates/bp-nouveau/js/buddypress-messages.js

    r13369 r13415  
    13551355
    13561356                messagesFetched: function( collection, response ) {
    1357                         if ( ! _.isUndefined( response.thread ) ) {
     1357                        if ( response.thread && !! response.thread.length ) {
    13581358                                this.options.thread = new Backbone.Model( response.thread );
    13591359                        }
     
    13801380
    13811381                sendReply: function( event ) {
     1382                        var threadItem;
    13821383                        event.preventDefault();
    13831384
     
    13861387                        }
    13871388
     1389                        threadItem = this.options.thread;
     1390                        if ( ! threadItem.has( 'id' ) ) {
     1391                                threadItem = this.options.collection.at( 0 );
     1392                        }
     1393
    13881394                        this.reply.set ( {
    1389                                 thread_id : this.options.thread.get( 'id' ),
     1395                                thread_id : threadItem.get( 'id' ),
    13901396                                content   : tinyMCE.activeEditor.getContent(),
    13911397                                sending   : true
Note: See TracChangeset for help on using the changeset viewer.