mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
- fix tab counter failed if only one tab open
This commit is contained in:
parent
d5dc74bea4
commit
ab9f398d7b
1 changed files with 13 additions and 14 deletions
|
|
@ -258,11 +258,8 @@ class TasksController extends ApiController {
|
|||
function postNewCounter()
|
||||
{
|
||||
checkReadAccess();
|
||||
$lists = $this->req->jsonBody['lists'] ?? false;
|
||||
if (!is_array($lists)) {
|
||||
$this->response->data = [ 'total' => 0 ];
|
||||
return;
|
||||
}
|
||||
$lists = $this->req->jsonBody['lists'] ?? [];
|
||||
if (!is_array($lists)) $lists = [];
|
||||
$userLists = [];
|
||||
if (!haveWriteAccess()) {
|
||||
$userLists = $this->getUserListsSimple(true);
|
||||
|
|
@ -281,18 +278,20 @@ class TasksController extends ApiController {
|
|||
if ($later <= 0) continue;
|
||||
$sqlWhereList[] = "(list_id = ". (int)$item['listId']. " AND compl=0 AND d_created > $later)";
|
||||
}
|
||||
$sqlWhere = implode(' OR ', $sqlWhereList);
|
||||
|
||||
|
||||
$db = DBConnection::instance();
|
||||
$a = [];
|
||||
$q = $db->dq("SELECT list_id, COUNT(id) c FROM {$db->prefix}todolist
|
||||
WHERE $sqlWhere GROUP BY list_id");
|
||||
while ($r = $q->fetchAssoc()) {
|
||||
$a[] = [
|
||||
'listId' => (int)$r['list_id'],
|
||||
'counter' => (int)$r['c'],
|
||||
];
|
||||
|
||||
if ($sqlWhereList) {
|
||||
$sqlWhere = implode(' OR ', $sqlWhereList);
|
||||
$q = $db->dq("SELECT list_id, COUNT(id) c FROM {$db->prefix}todolist
|
||||
WHERE $sqlWhere GROUP BY list_id");
|
||||
while ($r = $q->fetchAssoc()) {
|
||||
$a[] = [
|
||||
'listId' => (int)$r['list_id'],
|
||||
'counter' => (int)$r['c'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$b = [];
|
||||
|
|
|
|||
Loading…
Reference in a new issue