mirror of
https://github.com/openvk/openvk
synced 2024-12-22 16:42:32 +03:00
Messages: Redesign, Date fix, Pagination
Search: Kind of fix by adding more shitcode xdddddd Co-authored-by: Daniel <60743585+myslivets@users.noreply.github.com>
This commit is contained in:
parent
6cc7d9c553
commit
db3789bef8
8 changed files with 116 additions and 30 deletions
|
@ -60,6 +60,17 @@ class Message extends RowModel
|
|||
{
|
||||
return new DateTime($this->getRecord()->created);
|
||||
}
|
||||
|
||||
function getSendTimeHumanized(): string
|
||||
{
|
||||
$dateTime = new DateTime($this->getRecord()->created);
|
||||
|
||||
if($dateTime->format("%d.%m.%y") == ovk_strftime_safe("%d.%m.%y", time())) {
|
||||
return $dateTime->format("%T %p");
|
||||
} else {
|
||||
return $dateTime->format("%d.%m.%y");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get date of last edit, if any edits were made, otherwise null.
|
||||
|
@ -125,7 +136,7 @@ class Message extends RowModel
|
|||
"name" => $author->getFirstName().$unreadmsg,
|
||||
],
|
||||
"timing" => [
|
||||
"sent" => (string) $this->getSendTime()->format("%e %B %G" . tr("time_at_sp") . "%X"),
|
||||
"sent" => (string) $this->getSendTimeHumanized(),
|
||||
"edited" => is_null($this->getEditTime()) ? NULL : (string) $this->getEditTime(),
|
||||
],
|
||||
"text" => $this->getText(),
|
||||
|
|
|
@ -44,4 +44,15 @@ class Messages
|
|||
yield new Correspondence($correspondent, $anotherCorrespondent);
|
||||
}
|
||||
}
|
||||
|
||||
function getCorrespondenciesCount(RowModel $correspondent): ?int
|
||||
{
|
||||
$id = $correspondent->getId();
|
||||
$class = get_class($correspondent);
|
||||
$query = file_get_contents(__DIR__ . "/../sql/get-correspondencies-count.tsql");
|
||||
DatabaseConnection::i()->getConnection()->query(file_get_contents(__DIR__ . "/../sql/mysql-msg-fix.tsql"));
|
||||
$count = DatabaseConnection::i()->getConnection()->query($query, $id, $class, $id, $class)->fetch()->cnt;
|
||||
bdump($count);
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
|
|
20
Web/Models/sql/get-correspondencies-count.tsql
Normal file
20
Web/Models/sql/get-correspondencies-count.tsql
Normal file
|
@ -0,0 +1,20 @@
|
|||
SELECT COUNT(id) AS cnt FROM
|
||||
(
|
||||
(
|
||||
SELECT
|
||||
recipient_id AS id
|
||||
FROM messages
|
||||
WHERE
|
||||
sender_id = ?
|
||||
AND
|
||||
sender_type = ?
|
||||
) UNION (
|
||||
SELECT
|
||||
sender_id AS id
|
||||
FROM messages
|
||||
WHERE
|
||||
recipient_id = ?
|
||||
AND
|
||||
recipient_type = ?
|
||||
)
|
||||
) dt
|
|
@ -34,10 +34,18 @@ final class MessengerPresenter extends OpenVKPresenter
|
|||
if(isset($_GET["sel"]))
|
||||
$this->pass("openvk!Messenger->app", $_GET["sel"]);
|
||||
|
||||
$page = $_GET["p"] ?? 1;
|
||||
$page = (int) ($_GET["p"] ?? 1);
|
||||
$correspondences = iterator_to_array($this->messages->getCorrespondencies($this->user->identity, $page));
|
||||
|
||||
|
||||
// #КакаоПрокакалось
|
||||
|
||||
$this->template->corresps = $correspondences;
|
||||
$this->template->paginatorConf = (object) [
|
||||
"count" => $this->messages->getCorrespondenciesCount($this->user->identity),
|
||||
"page" => (int) ($_GET["p"] ?? 1),
|
||||
"amount" => sizeof($this->template->corresps),
|
||||
"perPage" => OPENVK_DEFAULT_PER_PAGE,
|
||||
];
|
||||
}
|
||||
|
||||
function renderApp(int $sel): void
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<div class="wrap2">
|
||||
<div class="wrap1">
|
||||
<div class="page_wrap padding_top">
|
||||
<div n:ifset="tabs" n:ifcontent class="tabs">
|
||||
<div n:ifset="tabs" n:ifcontent class="tabs stupid-fix">
|
||||
{include tabs}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
</div>
|
||||
<div class="crp-entry--info">
|
||||
<a href="{$recipient->getURL()}">{$recipient->getCanonicalName()}</a><br/>
|
||||
<span>{$lastMsg->getSendTime()->format("%e %B %G" . tr("time_at_sp") . "%X")}</span>
|
||||
<span>{$lastMsg->getSendTimeHumanized()}</span>
|
||||
</div>
|
||||
<div n:class="crp-entry--message, $lastMsg->getUnreadState() ? unread">
|
||||
{var $_author = $lastMsg->getSender()}
|
||||
|
@ -45,6 +45,9 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top: 3px;">
|
||||
{include "../components/paginator.xml", conf => $paginatorConf}
|
||||
</div>
|
||||
{else}
|
||||
<br/>
|
||||
<br/>
|
||||
|
|
|
@ -33,16 +33,17 @@
|
|||
{_groups}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<form class="header_search_inputbt">
|
||||
<input name="type" type="hidden" value="{$type ?? 'users'}" />
|
||||
<input name="query" class="header_search_input" placeholder="{_search_placeholder}" value="{$_GET['query'] ?? ''}" />
|
||||
<button class="button_search">{_search_button}</button>
|
||||
</form>
|
||||
|
||||
<form class="header_search_inputbt">
|
||||
<input name="type" type="hidden" value="{$type ?? 'users'}" />
|
||||
<input name="query" class="header_search_input" placeholder="{_search_placeholder}" value="{$_GET['query'] ?? ''}" />
|
||||
<button class="button_search">{_search_button}</button>
|
||||
</form>
|
||||
|
||||
<p style="margin-left: 15px; margin-top: 0;">
|
||||
<b>{tr("results", $count)}</b>
|
||||
</p>
|
||||
<p style="margin-left: 15px; margin-top: 0;">
|
||||
<b>{tr("results", $count)}</b>
|
||||
</p>
|
||||
<div>
|
||||
{/block}
|
||||
|
||||
{block link|strip|stripHtml}
|
||||
|
|
|
@ -798,6 +798,13 @@ table.User {
|
|||
.tabs {
|
||||
border-bottom: 1px solid #707070;
|
||||
padding: 0 10px;
|
||||
margin-left: -10px;
|
||||
width: 607px;
|
||||
}
|
||||
|
||||
.tabs.stupid-fix {
|
||||
margin-left: 0;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
#activetabs {
|
||||
|
@ -913,11 +920,19 @@ table.User {
|
|||
}
|
||||
|
||||
.crp-entry--info {
|
||||
width: 190px;
|
||||
width: 130px;
|
||||
margin-top: 2%;
|
||||
}
|
||||
|
||||
.crp-entry--message{
|
||||
padding: 3px;
|
||||
width: 395px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.crp-entry--image>img {
|
||||
max-width: 64px;
|
||||
max-width: 50px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.crp-entry--info span {
|
||||
|
@ -929,15 +944,14 @@ table.User {
|
|||
}
|
||||
|
||||
.crp-entry--message.unread {
|
||||
background-color: #ededed;
|
||||
padding: 5px;
|
||||
width: 346px;
|
||||
padding: 3px;
|
||||
width: 395px;
|
||||
background: #e6e6e6;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.messenger-app--messages---message.unread {
|
||||
background-color: #ededed;
|
||||
padding: 5px;
|
||||
margin: -5px;
|
||||
padding-bottom: 1.2rem;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
@ -955,20 +969,27 @@ table.User {
|
|||
}
|
||||
|
||||
.crp-entry--message---av img {
|
||||
max-width: 42px;
|
||||
max-width: 32px;
|
||||
border-radius: 3px;
|
||||
margin-top: 20%;
|
||||
margin-left: 10%;
|
||||
}
|
||||
|
||||
.crp-entry--message---av,
|
||||
.crp-entry--message---text {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
max-width: 50px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.crp-entry--message---text {
|
||||
max-height: 45px;
|
||||
max-width: 260px;
|
||||
max-height: 40px;
|
||||
max-width: 310px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
/* white-space: nowrap; */ /* myslivets: а как........... */
|
||||
margin-left: 3%;
|
||||
}
|
||||
|
||||
.crp-entry--message---text,
|
||||
|
@ -976,14 +997,14 @@ table.User {
|
|||
color: #404036;
|
||||
}
|
||||
|
||||
.messenger-app--messages,
|
||||
.messenger-app--input {
|
||||
padding: 10px 70px;
|
||||
padding: 10px 60px;
|
||||
}
|
||||
|
||||
.messenger-app--messages {
|
||||
height: 360px;
|
||||
overflow-y: auto;
|
||||
padding: 10px 60px;
|
||||
}
|
||||
|
||||
.messenger-app--messages---message,
|
||||
|
@ -994,20 +1015,31 @@ table.User {
|
|||
}
|
||||
|
||||
.messenger-app--messages---message {
|
||||
margin-bottom: 1.2rem;
|
||||
margin-bottom: 3px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.messenger-app--messages---message .ava,
|
||||
.messenger-app--input>.ava {
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
object-fit: cover;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.messenger-app--messages---message .ava {
|
||||
width: 37px;
|
||||
height: 37px;
|
||||
object-fit: cover;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.messenger-app--messages---message ._content {
|
||||
padding-left: 20px;
|
||||
width: 300px;
|
||||
width: 310px;
|
||||
line-height: 13.2pt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.messenger-app--messages---message ._content span,
|
||||
.messenger-app--messages---message ._content>a {
|
||||
display: block;
|
||||
|
|
Loading…
Reference in a new issue