From: Hypolite Petovan <hypolite@mrpetovan.com>
Date: Fri, 7 Dec 2018 05:54:40 +0000 (-0500)
Subject: Add delivery queue display in frio and vier
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6538a8eaca3224ce563b4f242dab6cda971e72d3;p=friendica.git

Add delivery queue display in frio and vier

- Add new $item.owner_self and $item.delivery keys for display
- Add new sub/delivery_count.tpl template
---

diff --git a/src/Object/Post.php b/src/Object/Post.php
index 2bad9a6262..8aae024ffb 100644
--- a/src/Object/Post.php
+++ b/src/Object/Post.php
@@ -394,6 +394,7 @@ class Post extends BaseObject
 			'location'        => $location_e,
 			'indent'          => $indent,
 			'shiny'           => $shiny,
+			'owner_self'      => $item['author-link'] == defaults($_SESSION, 'my_url', null),
 			'owner_url'       => $this->getOwnerUrl(),
 			'owner_photo'     => $a->removeBaseURL(ProxyUtils::proxifyUrl($item['owner-avatar'], false, ProxyUtils::SIZE_THUMB)),
 			'owner_name'      => $owner_name_e,
@@ -421,6 +422,14 @@ class Post extends BaseObject
 			'commented'       => $item['commented'],
 			'created_date'    => $item['created'],
 			'return'          => ($a->cmd) ? bin2hex($a->cmd) : '',
+			'delivery'        => [
+				'queue_count'       => $item['delivery_queue_count'],
+				'queue_done'        => $item['delivery_queue_done'],
+				'notifier_pending'  => L10n::t('Notifier task is pending'),
+				'delivery_pending'  => L10n::t('Delivery to remote servers is pending'),
+				'delivery_underway' => L10n::t('Delivery to remote servers is underway'),
+				'delivery_almost'   => L10n::t('Delivery to remote servers is mostly done'),
+			],
 		];
 
 		$arr = ['item' => $item, 'output' => $tmp_item];
diff --git a/view/templates/sub/delivery_count.tpl b/view/templates/sub/delivery_count.tpl
new file mode 100644
index 0000000000..d10eda639b
--- /dev/null
+++ b/view/templates/sub/delivery_count.tpl
@@ -0,0 +1,13 @@
+{{*
+	Please don't use this template as is, this is a placeholder that needs to be
+	overriden with specific icons to avoid taking too much visual space
+*}}
+{{if $delivery.queue_count == 0}}
+	{{$delivery.notifier_pending|escape}}
+{{elseif $delivery.queue_done == 0}}
+	{{$delivery.delivery_pending|escape}} {{$item.delivery.queue_done}}/{{$item.delivery.queue_count}}
+{{elseif $delivery.queue_done / $delivery.queue_count < 0.75}}
+	{{$delivery.delivery_underway|escape}} {{$item.delivery.queue_done}}/{{$item.delivery.queue_count}}
+{{else}}
+	{{$delivery.delivery_almost|escape}} {{$item.delivery.queue_done}}/{{$item.delivery.queue_count}}
+{{/if}}
diff --git a/view/theme/frio/templates/sub/delivery_count.tpl b/view/theme/frio/templates/sub/delivery_count.tpl
new file mode 100644
index 0000000000..05d1d171c7
--- /dev/null
+++ b/view/theme/frio/templates/sub/delivery_count.tpl
@@ -0,0 +1,13 @@
+{{if $delivery.queue_count == 0}}
+	<i class="fa fa-hourglass-o" aria-hidden="true" title="{{$delivery.notifier_pending|escape}}"></i>
+	<span class="sr-only">{{$delivery.notifier_pending|escape}}</span>
+{{elseif $delivery.queue_done == 0}}
+	<i class="fa fa-hourglass" aria-hidden="true" title="{{$delivery.delivery_pending|escape}} {{$item.delivery.queue_done}}/{{$item.delivery.queue_count}}"></i>
+	<span class="sr-only">{{$delivery.delivery_pending|escape}}</span>
+{{elseif $delivery.queue_done / $delivery.queue_count < 0.75}}
+	<i class="fa fa-paper-plane-o" aria-hidden="true" title="{{$delivery.delivery_underway|escape}} {{$item.delivery.queue_done}}/{{$item.delivery.queue_count}}"></i>
+	<span class="sr-only">{{$delivery.delivery_underway|escape}}</span>
+{{else}}
+	<i class="fa fa-paper-plane" aria-hidden="true" title="{{$delivery.delivery_almost|escape}} {{$item.delivery.queue_done}}/{{$item.delivery.queue_count}}"></i>
+	<span class="sr-only">{{$delivery.delivery_almost|escape}}</span>
+{{/if}}
diff --git a/view/theme/frio/templates/wall_thread.tpl b/view/theme/frio/templates/wall_thread.tpl
index af3e27228b..8d357960fe 100644
--- a/view/theme/frio/templates/wall_thread.tpl
+++ b/view/theme/frio/templates/wall_thread.tpl
@@ -12,8 +12,8 @@ The div get's closed if thread_level = 2 and the value of $top_child_nr is the s
 as the value of $top_child_total (this is done at the end of this file)
 *}}
 {{if $item.thread_level==1}}
-	{{assign var="top_child_total" count($item.children)}}
-	{{assign var="top_child_nr" 0}}
+	{{assign var="top_child_total" value=count($item.children)}}
+	{{assign var="top_child_nr" value=0}}
 {{/if}}
 {{if $item.thread_level==2}}
 	{{assign var="top_child_nr" value=$top_child_nr+1 scope=parent}}
@@ -55,15 +55,14 @@ as the value of $top_child_total (this is done at the end of this file)
 {{/if}}
 {{/if}}
 
-<!-- TODO => Unknow block -->
+{{* TODO => Unknown block *}}
 <div class="wall-item-decor" style="display:none;">
 	{{if $item.star}}
 	<span class="icon s22 star {{$item.isstarred}}" id="starred-{{$item.id}}" title="{{$item.star.starred}}">{{$item.star.starred}}</span>
 	{{/if}}
 	{{if $item.lock}}<span class="navicon lock fakelink" onclick="lockview(event,{{$item.id}});" title="{{$item.lock}}"></span><span class="fa fa-lock"></span>{{/if}}
 </div>
-<!-- ./TODO => Unknow block -->
-
+{{* /TODO => Unknown block *}}
 
 
 {{* Use a different div container in dependence max thread-level = 7 *}}
@@ -220,7 +219,14 @@ as the value of $top_child_total (this is done at the end of this file)
 			<h5 class="media-heading">
 				<a href="{{$item.profile_url}}" title="{{$item.linktitle}}" class="wall-item-name-link userinfo"><span>{{$item.name}}</span></a>
 				<p class="text-muted">
-					<small><a class="time" href="{{$item.plink.orig}}"><span class="wall-item-ago">{{$item.ago}}</span></a> {{if $item.location}}&nbsp;&mdash;&nbsp;({{$item.location nofilter}}){{/if}}</small>
+					<small>
+						<a class="time" href="{{$item.plink.orig}}"><span class="wall-item-ago">{{$item.ago}}</span></a>
+						{{if $item.location}}&nbsp;&mdash;&nbsp;({{$item.location nofilter}}){{/if}}
+						{{if $item.owner_self}}
+							&bullet;
+							{{include file="sub/delivery_count.tpl" delivery=$item.delivery}}
+						{{/if}}
+					</small>
 				</p>
 			</h5>
 		</div>
diff --git a/view/theme/vier/templates/sub/delivery_count.tpl b/view/theme/vier/templates/sub/delivery_count.tpl
new file mode 100644
index 0000000000..594ce38c53
--- /dev/null
+++ b/view/theme/vier/templates/sub/delivery_count.tpl
@@ -0,0 +1,13 @@
+{{if $delivery.queue_count == 0}}
+	<i class="icon-spinner" aria-hidden="true" title="{{$delivery.notifier_pending|escape}}"></i>
+	<span class="sr-only">{{$delivery.notifier_pending|escape}}</span>
+{{elseif $delivery.queue_done == 0}}
+	<i class="icon-spinner" aria-hidden="true" title="{{$delivery.delivery_pending|escape}} {{$item.delivery.queue_done}}/{{$item.delivery.queue_count}}"></i>
+	<span class="sr-only">{{$delivery.delivery_pending|escape}}</span>
+{{elseif $delivery.queue_done / $delivery.queue_count < 0.75}}
+	<i class="icon-plane" aria-hidden="true" title="{{$delivery.delivery_underway|escape}} {{$item.delivery.queue_done}}/{{$item.delivery.queue_count}}"></i>
+	<span class="sr-only">{{$delivery.delivery_underway|escape}}</span>
+{{else}}
+	<i class="icon-plane" aria-hidden="true" title="{{$delivery.delivery_almost|escape}} {{$item.delivery.queue_done}}/{{$item.delivery.queue_count}}"></i>
+	<span class="sr-only">{{$delivery.delivery_almost|escape}}</span>
+{{/if}}
diff --git a/view/theme/vier/templates/wall_thread.tpl b/view/theme/vier/templates/wall_thread.tpl
index 8a857bcb7d..607a789e56 100644
--- a/view/theme/vier/templates/wall_thread.tpl
+++ b/view/theme/vier/templates/wall_thread.tpl
@@ -56,6 +56,10 @@
 			{{if $item.owner_url}}{{$item.via}} <a href="{{$item.owner_url}}" target="redir" title="{{$item.olinktitle}}" class="wall-item-name-link"><span class="wall-item-name{{$item.osparkle}}" id="wall-item-ownername-{{$item.id}}">{{$item.owner_name}}</span></a>{{/if}}
 			<span class="wall-item-ago">
 				{{if $item.plink}}<a title="{{$item.plink.title}}" href="{{$item.plink.href}}" class="u-url" style="color: #999"><time class="dt-published" datetime="{{$item.localtime}}">{{$item.created}}</time></a>{{else}} <time class="dt-published" datetime="{{$item.localtime}}">{{$item.created}}</time> {{/if}}
+				{{if $item.owner_self}}
+					&bullet;
+					{{include file="sub/delivery_count.tpl" delivery=$item.delivery}}
+				{{/if}}
 			</span>
 			{{if $item.lock}}<span class="icon s10 lock fakelink" onclick="lockview(event,{{$item.id}});" title="{{$item.lock}}">{{$item.lock}}</span>{{/if}}
 			<span class="wall-item-network" title="{{$item.app}}">