From fb6536e23f54cd3ba98e47970f769b1d027220c2 Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Tue, 18 Aug 2026 15:04:29 +0300 Subject: [PATCH] Optimize pin icon rendering on the inbox message list --- docs/CHANGELOG.md | 1 + models/Message.php | 10 ++++++++-- widgets/InboxMessagePreview.php | 1 + widgets/views/inboxMessagePreview.php | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 25aa3d2d..5d07873f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,6 +4,7 @@ Changelog 3.3.13 (Unreleased) ---------------------- - Fix #512: Validate `from` pagination cursor to prevent unbounded conversation loading +- Fix #514: Optimize pin icon rendering on the inbox message list 3.3.12 (July 16, 2026) ---------------------- diff --git a/models/Message.php b/models/Message.php index ddcf10a4..0c99d40d 100644 --- a/models/Message.php +++ b/models/Message.php @@ -441,9 +441,15 @@ public function isPinned($userId = null): bool return $userMessage && $userMessage->pinned; } - public function getPinIcon($userId = null): ?Icon + /** + * @param int|null $userId + * @param bool|null $isPinned pass the already known pinned state (e.g. from a + * preloaded UserMessage) to avoid an extra lookup via {@see isPinned()} + * @return Icon|null + */ + public function getPinIcon($userId = null, ?bool $isPinned = null): ?Icon { - if ($this->isPinned($userId)) { + if ($isPinned ?? $this->isPinned($userId)) { return Icon::get('map-pin') ->tooltip(Yii::t('MailModule.base', 'Pinned')) ->color('var(--bs-danger)'); diff --git a/widgets/InboxMessagePreview.php b/widgets/InboxMessagePreview.php index d1287342..7e05ed34 100644 --- a/widgets/InboxMessagePreview.php +++ b/widgets/InboxMessagePreview.php @@ -32,6 +32,7 @@ public function run() 'messageText' => $this->getMessagePreview(), 'messageTime' => $this->getMessageTime(), 'lastParticipant' => $this->lastParticipant(), + 'isPinned' => $this->userMessage->pinned, 'options' => $this->getOptions(), ]); } diff --git a/widgets/views/inboxMessagePreview.php b/widgets/views/inboxMessagePreview.php index dd45069b..2b4661a5 100644 --- a/widgets/views/inboxMessagePreview.php +++ b/widgets/views/inboxMessagePreview.php @@ -16,6 +16,7 @@ /* @var $messageText string */ /* @var $messageTime string */ /* @var $lastParticipant User */ +/* @var $isPinned bool */ /* @var $options array */ ?> @@ -31,7 +32,7 @@

- getPinIcon() ?> + getPinIcon(isPinned: $isPinned) ?>