mirror of
https://github.com/kevachat/geminiapp.git
synced 2025-03-13 05:51:39 +00:00
fix room list with pending records
This commit is contained in:
parent
29d4ccceea
commit
df6a2fbce9
@ -47,6 +47,7 @@ class Room
|
||||
// Get room list
|
||||
$namespaces = [];
|
||||
|
||||
// Get recorded rooms
|
||||
foreach ((array) $this->_kevacoin->kevaListNamespaces() as $namespace)
|
||||
{
|
||||
// Skip system namespaces
|
||||
@ -62,9 +63,8 @@ class Room
|
||||
}
|
||||
|
||||
// Add to room list
|
||||
$namespaces[] =
|
||||
$namespaces[$namespace['namespaceId']] =
|
||||
[
|
||||
'namespace' => $namespace['namespaceId'],
|
||||
'name' => $namespace['displayName'],
|
||||
'total' => $this->_total(
|
||||
$namespace['namespaceId']
|
||||
@ -72,6 +72,21 @@ class Room
|
||||
];
|
||||
}
|
||||
|
||||
// Get rooms contain pending data
|
||||
foreach ((array) $this->_kevacoin->kevaPending() as $pending)
|
||||
{
|
||||
// Add to room list
|
||||
$namespaces[$pending['namespaceId']] =
|
||||
[
|
||||
'name' => $this->_namespace(
|
||||
$pending['namespaceId']
|
||||
),
|
||||
'total' => $this->_total(
|
||||
$pending['namespaceId']
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
// Sort rooms by total
|
||||
array_multisort(
|
||||
array_column(
|
||||
@ -88,7 +103,7 @@ class Room
|
||||
);
|
||||
|
||||
$rooms = [];
|
||||
foreach ($namespaces as $namespace)
|
||||
foreach ($namespaces as $namespace => $value)
|
||||
{
|
||||
$rooms[] = str_replace(
|
||||
[
|
||||
@ -97,12 +112,12 @@ class Room
|
||||
'{link}'
|
||||
],
|
||||
[
|
||||
$namespace['name'],
|
||||
$namespace['total'],
|
||||
$value['name'],
|
||||
$value['total'],
|
||||
$this->_link(
|
||||
sprintf(
|
||||
'/room/%s',
|
||||
$namespace['namespace']
|
||||
$namespace
|
||||
)
|
||||
)
|
||||
],
|
||||
@ -424,15 +439,17 @@ class Room
|
||||
);
|
||||
}
|
||||
|
||||
// Namespace clickable
|
||||
else if ($name = $this->_namespace($value))
|
||||
// Room
|
||||
else
|
||||
{
|
||||
$links[] = $this->_link(
|
||||
sprintf(
|
||||
'/room/%s',
|
||||
$value
|
||||
),
|
||||
$name,
|
||||
$this->_namespace(
|
||||
$value
|
||||
),
|
||||
true
|
||||
);
|
||||
}
|
||||
@ -779,7 +796,7 @@ class Room
|
||||
return null;
|
||||
}
|
||||
|
||||
public function _namespace(string $namespace, ?int $cache = 31104000): ?string
|
||||
public function _namespace(string $namespace, ?int $cache = 31104000): string
|
||||
{
|
||||
// Check for cache
|
||||
if ($result = $this->_memory->get([__METHOD__, $namespace]))
|
||||
@ -826,7 +843,7 @@ class Room
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return $namespace;
|
||||
}
|
||||
|
||||
private function _total(string $namespace): int
|
||||
|
Loading…
x
Reference in New Issue
Block a user