mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
implement observer activity visibility
This commit is contained in:
@@ -481,7 +481,8 @@ class ThreadItem {
|
||||
'rtl' => in_array($item['lang'], rtl_languages()),
|
||||
'reactions_allowed' => $reactions_allowed,
|
||||
'reaction_str' => [t('Add yours'), t('Remove yours')],
|
||||
'is_contained' => $this->is_toplevel() && str_contains($item['tgt_type'], 'Collection')
|
||||
'is_contained' => $this->is_toplevel() && str_contains($item['tgt_type'], 'Collection'),
|
||||
'observer_activity' => ['like' => intval($item['observer_liked']), 'dislike' => intval($item['observer_disliked']), 'announce' => intval($item['observer_announced']), 'comment' => intval($item['observer_commented'])]
|
||||
);
|
||||
|
||||
$arr = array('item' => $item, 'output' => $tmp_item);
|
||||
|
||||
@@ -5355,13 +5355,27 @@ function items_by_parent_ids($ids, $sql_extra = '') {
|
||||
$item_normal = item_normal();
|
||||
$item_normal_c = str_replace('item.', 'c.', $item_normal);
|
||||
|
||||
return dbq(
|
||||
$observer = get_observer_hash();
|
||||
$observer_sql = '';
|
||||
|
||||
if ($observer) {
|
||||
$observer_sql = <<<SQL
|
||||
,
|
||||
COUNT(CASE WHEN c.verb = 'Like' AND c.author_xchan = '$observer' $item_normal_c THEN 1 END) AS observer_liked,
|
||||
COUNT(CASE WHEN c.verb = 'Dislike' AND c.author_xchan = '$observer' $item_normal_c THEN 1 END) AS observer_disliked,
|
||||
COUNT(CASE WHEN c.verb = 'Announce' AND c.author_xchan = '$observer' $item_normal_c THEN 1 END) AS observer_announced,
|
||||
COUNT(CASE WHEN c.verb IN ('Create','Update') AND c.author_xchan = '$observer' $item_normal_c THEN 1 END) AS observer_commented
|
||||
SQL;
|
||||
}
|
||||
|
||||
$ret = dbq(
|
||||
"SELECT
|
||||
item.*,
|
||||
COUNT(CASE c.verb WHEN 'Like' THEN 1 END) AS like_count,
|
||||
COUNT(CASE c.verb WHEN 'Dislike' THEN 1 END) AS dislike_count,
|
||||
COUNT(CASE c.verb WHEN 'Announce' THEN 1 END) AS announce_count,
|
||||
COUNT(CASE WHEN c.verb IN ('Create','Update') THEN 1 END) AS comment_count
|
||||
$observer_sql
|
||||
FROM item
|
||||
LEFT JOIN item c
|
||||
ON c.parent = item.parent
|
||||
@@ -5377,4 +5391,6 @@ function items_by_parent_ids($ids, $sql_extra = '') {
|
||||
$item_normal
|
||||
GROUP BY item.id"
|
||||
);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
{{foreach $item.responses as $verb=>$response}}
|
||||
{{if $item.reactions_allowed || (!$item.reactions_allowed && $response.count)}}
|
||||
<div class="">
|
||||
<button type="button" title="{{$response.count}} {{$response.button.label}}" class="btn btn-sm btn-link{{if !$item.my_responses.$verb}} link-secondary{{/if}} wall-item-{{$response.button.class}}"{{if $item.reactions_allowed}} onclick="request({{$item.id}}, '{{$item.rawmid}}', '{{$verb}}'); return false;"{{/if}} id="wall-item-{{$verb}}-{{$item.id}}">
|
||||
<button type="button" title="{{$response.count}} {{$response.button.label}}" class="btn btn-sm btn-link{{if !$item.observer_activity.$verb}} link-secondary{{/if}} wall-item-{{$response.button.class}}"{{if $item.reactions_allowed}} onclick="request({{$item.id}}, '{{$item.rawmid}}', '{{$verb}}'); return false;"{{/if}} id="wall-item-{{$verb}}-{{$item.id}}">
|
||||
<i class="bi bi-{{$response.button.icon}} generic-icons"></i>{{if $response.count}}<span style="display: inline-block; margin-top: -.25rem;" class="align-top">{{$response.count}}</span>{{/if}}
|
||||
</button>
|
||||
{{if $response.modal}}
|
||||
|
||||
Reference in New Issue
Block a user