From 026a10941510fb6dc7dc4681e7f306547769880f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Farr=C3=A9?= <23310825+marc-farre@users.noreply.github.com> Date: Sat, 17 Aug 2024 11:03:45 +0100 Subject: [PATCH] Fix: When replying to a message, the conversation is marked as unread (#415) * Fix: When replying to a message, the conversation is marked as unread * Add PR ID to Changelog --- docs/CHANGELOG.md | 1 + models/forms/ReplyForm.php | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 5b86185..00a8d19 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,6 +6,7 @@ Changelog - Enh #411: Standardization of Modal Button Positions - Enh #363: Deny access for files from message where current user is not participant - Fix #412: Fix active message after mark unread +- Fix #15: When replying to a message, the conversation is marked as unread 3.2.2 (July 9, 2024) -------------------- diff --git a/models/forms/ReplyForm.php b/models/forms/ReplyForm.php index e21546d..e78c2b5 100644 --- a/models/forms/ReplyForm.php +++ b/models/forms/ReplyForm.php @@ -82,6 +82,14 @@ public function save() $this->reply->refresh(); // Update created_by date, otherwise db expression is set... $this->reply->notify(); $this->reply->fileManager->attach(Yii::$app->request->post('fileList')); + + // Update last viewed date to avoid marking the conversation as unread + $userMessage = $this->model->getUserMessage($this->reply->user_id); + if ($userMessage) { + $userMessage->last_viewed = date('Y-m-d G:i:s'); + $userMessage->save(); + } + return true; }