diff options
-rw-r--r-- | Zotlabs/Module/Like.php | 61 | ||||
-rwxr-xr-x | boot.php | 2 | ||||
-rw-r--r-- | view/js/main.js | 19 |
3 files changed, 75 insertions, 7 deletions
diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 8ffa7f66c..538282c38 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -357,16 +357,45 @@ class Like extends \Zotlabs\Web\Controller { // drop_item was not done interactively, so we need to invoke the notifier // in order to push the changes to connections - + \Zotlabs\Daemon\Master::Summon(array('Notifier','drop',$rr['id'])); + + } if($interactive) return; - if(! $multi_undo) + if(! $multi_undo) { + $item_normal = item_normal(); + $activities = q("SELECT item.*, item.id AS item_id FROM item + WHERE uid = %d $item_normal + AND thr_parent = '%s' + AND verb IN ('%s', '%s', '%s', '%s', '%s')", + intval($owner_uid), + dbesc($item['mid']), + dbesc(ACTIVITY_LIKE), + dbesc(ACTIVITY_DISLIKE), + dbesc(ACTIVITY_ATTEND), + dbesc(ACTIVITY_ATTENDNO), + dbesc(ACTIVITY_ATTENDMAYBE) + ); + xchan_query($activities,true); + $convitems[] = $item; + $convitems = array_merge($convitems, $activities); + + $json = [ + 'success' => 1, + 'id' => $item['id'], + 'html' => conversation($convitems,'network',true,'r_preview'), + ]; + + echo json_encode($json); killme(); + } + + } } @@ -505,6 +534,31 @@ class Like extends \Zotlabs\Web\Controller { $post = item_store($arr); $post_id = $post['item_id']; + //$item[] = $item; + + $item_normal = item_normal(); + $activities = q("SELECT item.*, item.id AS item_id FROM item + WHERE uid = %d $item_normal + AND thr_parent = '%s' + AND verb IN ('%s', '%s', '%s', '%s', '%s')", + intval($owner_uid), + dbesc($item['mid']), + dbesc(ACTIVITY_LIKE), + dbesc(ACTIVITY_DISLIKE), + dbesc(ACTIVITY_ATTEND), + dbesc(ACTIVITY_ATTENDNO), + dbesc(ACTIVITY_ATTENDMAYBE) + ); + xchan_query($activities,true); + $convitems[] = $item; + $convitems = array_merge($convitems, $activities); + + $json = [ + 'success' => 1, + 'id' => $item['id'], + 'html' => conversation($convitems,'network',true,'r_preview'), + ]; + // save the conversation from expiration if(local_channel() && array_key_exists('item',$post) && (intval($post['item']['id']) != intval($post['item']['parent']))) @@ -548,7 +602,8 @@ class Like extends \Zotlabs\Web\Controller { $o .= t('Thank you.'); return $o; } - + + echo json_encode($json); killme(); } @@ -50,7 +50,7 @@ require_once('include/attach.php'); require_once('include/bbcode.php'); define ( 'PLATFORM_NAME', 'hubzilla' ); -define ( 'STD_VERSION', '5.1.7' ); +define ( 'STD_VERSION', '5.1.8' ); define ( 'ZOT_REVISION', '6.0' ); define ( 'DB_UPDATE_VERSION', 1239 ); diff --git a/view/js/main.js b/view/js/main.js index c6460f356..133d71863 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -633,12 +633,11 @@ function updateConvItems(mode,data) { } if(mode === 'replace') { - $('.thread-wrapper').remove(); // clear existing content + $('.thread-parent').remove(); // clear existing content } $('.thread-wrapper', data).each(function() { if(this.classList.contains('toplevel_item')) { - var ident = this.id; var convId = ident.replace('thread-wrapper-',''); var commentWrap = $('#'+ident+' .collapsed-comments').attr('id'); @@ -1158,7 +1157,21 @@ function justifyPhotosAjax(id) { // is delayed and updateInit runs before it completes. function dolike(ident, verb) { $('#like-rotator-' + ident.toString()).show(); - $.get('like/' + ident.toString() + '?verb=' + verb, updateInit ); + $.get('like/' + ident.toString() + '?verb=' + verb, function (data) { + data = JSON.parse(data); + if(data.success) { + // this is a bit tricky since the top level thread wrapper wraps the whole thread + if($('#thread-wrapper-' + data.id).hasClass('toplevel_item')) { + var wrapper = $('<div></div>').html( data.html ).find('#wall-item-outside-wrapper-' + data.id); + $('#wall-item-outside-wrapper-' + data.id).html(wrapper[0].innerHTML); + } + else { + $('#thread-wrapper-' + data.id).replaceWith(data.html); + } + $('#wall-item-ago-' + data.id + ' .autotime').timeago(); + liking = 0; + } + }); liking = 1; } |