]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Work in progress: inline reply form reusing the main reply form now inserts the succe...
authorBrion Vibber <brion@pobox.com>
Fri, 4 Mar 2011 22:58:30 +0000 (14:58 -0800)
committerBrion Vibber <brion@pobox.com>
Fri, 4 Mar 2011 22:58:30 +0000 (14:58 -0800)
js/util.js

index 1bd011cb0d8069621c17d47c00bc5a3ffe9c3936..09ab23344bb97672ab9518a37a16ab7c35e89c8f 100644 (file)
@@ -387,7 +387,22 @@ var SN = { // StatusNet
                             // New notice post was successful. If on our timeline, show it!
                             var notice = document._importNode($('li', data)[0], true);
                             var notices = $('#notices_primary .notices:first');
-                            if (notices.length > 0 && SN.U.belongsOnTimeline(notice)) {
+                            var replyItem = form.closest('li.notice-reply');
+
+                            if (replyItem.length > 0) {
+                                // If this is an inline reply, insert it in place.
+                                var id = $(notice).attr('id');
+                                if ($("#"+id).length == 0) {
+                                    var parentNotice = replyItem.closest('li.notice');
+                                    replyItem.replaceWith(notice);
+                                    SN.U.NoticeInlineReplyPlaceholder(parentNotice);
+                                } else {
+                                    // Realtime came through before us...
+                                    replyItem.remove();
+                                }
+                            } else if (notices.length > 0 && SN.U.belongsOnTimeline(notice)) {
+                                // Not a reply. If on our timeline, show it at the top!
+
                                 if ($('#'+notice.id).length === 0) {
                                     var notice_irt_value = form.find('[name=inreplyto]').val();
                                     var notice_irt = '#notices_primary #notice-'+notice_irt_value;
@@ -406,10 +421,10 @@ var SN = { // StatusNet
                                     SN.U.NoticeWithAttachment($('#'+notice.id));
                                     SN.U.NoticeReplyTo($('#'+notice.id));
                                 }
-                            }
-                            else {
+                            } else {
                                 // Not on a timeline that this belongs on?
                                 // Just show a success message.
+                                // @fixme inline
                                 showFeedback('success', $('title', data).text());
                             }
                         }