Browse Source

implement pending posts processing

main
ghost 12 months ago
parent
commit
9cd4bb631d
  1. 9
      public/css/default.css
  2. 88
      src/Controller/RoomController.php
  3. 7
      templates/default/room/index.html.twig

9
public/css/default.css

@ -104,11 +104,18 @@ main ul > li:last-child @@ -104,11 +104,18 @@ main ul > li:last-child
border-bottom: none;
}
main ul > li > p
main ul > li p
{
padding: 8px 0;
}
main ul li > span > svg
{
cursor: default;
fill: #999;
float: right;
}
footer
{
/*backdrop-filter: blur(100px);*/

88
src/Controller/RoomController.php

@ -76,38 +76,55 @@ class RoomController extends AbstractController @@ -76,38 +76,55 @@ class RoomController extends AbstractController
// Get room feed
$feed = [];
foreach ((array) $client->kevaFilter($request->get('namespace')) as $post)
// Get pending paradise
foreach ((array) $client->kevaPending() as $pending)
{
// Skip values with meta keys
if (false !== stripos($post['key'], '_KEVA_'))
// Ignore pending posts from other rooms
if ($pending['namespace'] !== $request->get('namespace'))
{
continue;
}
// Set identicon if not anonymous user
if ($post['key'] === '@anonymous')
// Ignore everything in pending queue but keva_put nodes
if ($pending['op'] !== 'keva_put')
{
$icon = false;
continue;
}
else
// Skip values with meta keys
if (false !== stripos($pending['key'], '_KEVA_'))
{
$identicon = new \Jdenticon\Identicon();
$identicon->setValue(
$post['key']
);
$identicon->setSize(12);
continue;
}
$identicon->setStyle(
// Get more info
if ($transaction = $client->getRawTransaction($pending['txid']))
{
$feed[] =
[
'backgroundColor' => 'rgba(255, 255, 255, 0)',
'padding' => 0
]
);
'pending' => true,
'key' => $pending['key'],
'value' => $pending['value'],
'txid' => $pending['txid'],
'transaction' =>
[
'time' => date('c', $transaction['time']),
'timestamp' => $transaction['time'],
'confirmations' => $transaction['confirmations'],
],
'icon' => $this->_identicon($pending['key']),
'sort' => 0//$transaction['time'] // sort order field
];
}
}
$icon = $identicon->getImageDataUri('webp');
// Get regular posts
foreach ((array) $client->kevaFilter($request->get('namespace')) as $post)
{
// Skip values with meta keys
if (false !== stripos($post['key'], '_KEVA_'))
{
continue;
}
// Get more info
@ -115,7 +132,8 @@ class RoomController extends AbstractController @@ -115,7 +132,8 @@ class RoomController extends AbstractController
{
$feed[] =
[
# 'key' => $post['key'],
'pending' => false,
'key' => $post['key'],
'value' => $post['value'],
'height' => $post['height'],
# 'vout' => $post['vout'],
@ -126,7 +144,7 @@ class RoomController extends AbstractController @@ -126,7 +144,7 @@ class RoomController extends AbstractController
'timestamp' => $transaction['time'],
'confirmations' => $transaction['confirmations'],
],
'icon' => $icon,
'icon' => $this->_identicon($post['key']),
'sort' => $transaction['time'] // sort order field
];
}
@ -371,4 +389,30 @@ class RoomController extends AbstractController @@ -371,4 +389,30 @@ class RoomController extends AbstractController
]
);
}
private function _identicon(string $key)
{
if ($key === 'anonymous')
{
return false;
}
else
{
$identicon = new \Jdenticon\Identicon();
$identicon->setValue($key);
$identicon->setSize(12);
$identicon->setStyle(
[
'backgroundColor' => 'rgba(255, 255, 255, 0)',
'padding' => 0
]
);
return $identicon->getImageDataUri('webp');
}
}
}

7
templates/default/room/index.html.twig

@ -27,6 +27,13 @@ @@ -27,6 +27,13 @@
<a href="{{ path('room_namespace', { namespace : request.get('namespace') }) }}#{{ post.txid }}" title="{{ 'time:' | trans }} {{ post.transaction.time }} / {{ 'confirmations:' | trans }} {{ post.transaction.confirmations }}">{{ post.transaction.timestamp | format_ago }}</a>
&bull;
<a href="{{ path('room_namespace', { namespace : request.get('namespace'), txid : post.txid }) }}#{{ post.txid }}">{{ 'reply' | trans }}</a>
{% if post.pending %}
<span title="{{ 'pending in DHT' | trans }}">
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 16 16">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .252.434l3.5 2a.5.5 0 0 0 .496-.868L8 8.71z"/>
</svg>
</span>
{% endif %}
<p>
{{ post.value }}
</p>

Loading…
Cancel
Save