r57943 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57942‎ | r57943 | r57944 >
Date:14:33, 20 October 2009
Author:werdna
Status:deferred
Tags:
Comment:
LiquidThreads AJAX save fixes:
* Send max-lag with API response for reply and newthread threadactions.
* Wait for the period specified by (max-lag + 1) before reloading threads. Might give slaves a chance to catch up before we reload a thread.
* Use resetArticleID() to tell an article its ID, fixes some fatals when people are watching a thread.
* Scroll to the new thread when it is saved.
* Make sure that the edit form is emptied and removed.
Modified paths:
  • /trunk/extensions/LiquidThreads/api/ApiThreadAction.php (modified) (history)
  • /trunk/extensions/LiquidThreads/lqt.js (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/api/ApiThreadAction.php
@@ -344,13 +344,24 @@
345345
346346 $articleId = $editResult['edit']['pageid'];
347347
 348+ $article->getTitle()->resetArticleID( $articleId );
 349+ $title->resetArticleID( $articleId );
 350+
348351 $thread = LqtView::postEditUpdates( 'new', null, $articleId, $talkpage,
349352 $subject, $summary, null, $text );
350 -
 353+
 354+ $maxLag = wfGetLB()->getMaxLag();
 355+ $maxLag = $maxLag[1];
 356+
 357+ if ($maxLag == -1) {
 358+ $maxLag = 0;
 359+ }
 360+
351361 $result = array(
352362 'result' => 'Success',
353363 'thread-id' => $thread->id(),
354364 'thread-title' => $title->getPrefixedText(),
 365+ 'max-lag' => $maxLag,
355366 );
356367
357368 $result = array( 'thread' => $result );
@@ -431,9 +442,18 @@
432443 }
433444
434445 $articleId = $editResult['edit']['pageid'];
 446+ $article->getTitle()->resetArticleID( $articleId );
 447+ $title->resetArticleID( $articleId );
435448
436449 $thread = LqtView::postEditUpdates( 'reply', $replyTo, $articleId, $talkpage,
437450 $subject, $summary, null, $text );
 451+
 452+ $maxLag = wfGetLB()->getMaxLag();
 453+ $maxLag = $maxLag[1];
 454+
 455+ if ($maxLag == -1) {
 456+ $maxLag = 0;
 457+ }
438458
439459 $result = array(
440460 'action' => 'reply',
@@ -444,6 +464,7 @@
445465 'parent-title' => $replyTo->title()->getPrefixedText(),
446466 'ancestor-id' => $replyTo->topmostThread()->id(),
447467 'ancestor-title' => $replyTo->topmostThread()->title()->getPrefixedText(),
 468+ 'max-lag' => $maxLag,
448469 );
449470
450471 $result = array( 'thread' => $result );
Index: trunk/extensions/LiquidThreads/lqt.js
@@ -642,14 +642,17 @@
643643 function() {
644644 // Set up thread.
645645 liquidThreads.setupThread( $j(this) );
 646+
 647+ targetOffset = $j(this).offset().top;
 648+ $j('html,body').animate(
 649+ {scrollTop: targetOffset},
 650+ 'slow');
646651 }
647652 );
648653 }, 'json' );
649654 }
650655
651656 var doneCallback = function(data) {
652 - spinner.remove();
653 -
654657 try {
655658 var result = data.threadaction.thread.result;
656659 } catch ( err ) {
@@ -671,13 +674,20 @@
672675 return;
673676 }
674677
 678+ var timeout = (data.threadaction.thread['max-lag'] + 1) * 1000;
 679+ var callback;
 680+
675681 if ( type == 'reply' ) {
676 - replyCallback( data );
 682+ callback = replyCallback;
677683 }
678684
679685 if ( type == 'talkpage_new_thread' ) {
680 - newCallback( data );
 686+ callback = newCallback;
681687 }
 688+
 689+ editform.empty().hide();
 690+
 691+ setTimeout( function() { spinner.remove(); callback(data); }, timeout );
682692 };
683693
684694 if ( type == 'reply' ) {

Status & tagging log