mirror of
https://github.com/kevachat/webapp.git
synced 2025-01-14 16:57:56 +00:00
implement pending posts processing
This commit is contained in:
parent
8608557881
commit
9cd4bb631d
@ -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);*/
|
||||
|
@ -76,6 +76,49 @@ class RoomController extends AbstractController
|
||||
// Get room feed
|
||||
$feed = [];
|
||||
|
||||
// Get pending paradise
|
||||
foreach ((array) $client->kevaPending() as $pending)
|
||||
{
|
||||
// Ignore pending posts from other rooms
|
||||
if ($pending['namespace'] !== $request->get('namespace'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore everything in pending queue but keva_put nodes
|
||||
if ($pending['op'] !== 'keva_put')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip values with meta keys
|
||||
if (false !== stripos($pending['key'], '_KEVA_'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get more info
|
||||
if ($transaction = $client->getRawTransaction($pending['txid']))
|
||||
{
|
||||
$feed[] =
|
||||
[
|
||||
'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
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Get regular posts
|
||||
foreach ((array) $client->kevaFilter($request->get('namespace')) as $post)
|
||||
{
|
||||
// Skip values with meta keys
|
||||
@ -84,49 +127,24 @@ class RoomController extends AbstractController
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set identicon if not anonymous user
|
||||
if ($post['key'] === '@anonymous')
|
||||
{
|
||||
$icon = false;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$identicon = new \Jdenticon\Identicon();
|
||||
|
||||
$identicon->setValue(
|
||||
$post['key']
|
||||
);
|
||||
|
||||
$identicon->setSize(12);
|
||||
|
||||
$identicon->setStyle(
|
||||
[
|
||||
'backgroundColor' => 'rgba(255, 255, 255, 0)',
|
||||
'padding' => 0
|
||||
]
|
||||
);
|
||||
|
||||
$icon = $identicon->getImageDataUri('webp');
|
||||
}
|
||||
|
||||
// Get more info
|
||||
if ($transaction = $client->getRawTransaction($post['txid']))
|
||||
{
|
||||
$feed[] =
|
||||
[
|
||||
# 'key' => $post['key'],
|
||||
'value' => $post['value'],
|
||||
'height' => $post['height'],
|
||||
# 'vout' => $post['vout'],
|
||||
'txid' => $post['txid'],
|
||||
'pending' => false,
|
||||
'key' => $post['key'],
|
||||
'value' => $post['value'],
|
||||
'height' => $post['height'],
|
||||
# 'vout' => $post['vout'],
|
||||
'txid' => $post['txid'],
|
||||
'transaction' =>
|
||||
[
|
||||
'time' => date('c', $transaction['time']),
|
||||
'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
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
||||
•
|
||||
<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…
Reference in New Issue
Block a user