[Rt-commit] rt branch, 4.6/unread-message-count, updated. rt-4.4.4-541-g55d9d23525

Aaron Trevena ast at bestpractical.com
Fri Jan 24 15:32:38 EST 2020


The branch, 4.6/unread-message-count has been updated
       via  55d9d23525903ef6221ae01f7ee2dcefa84b4676 (commit)
      from  62e2a9a216cab9a8b2a25b1b8f36d2945814f837 (commit)

Summary of changes:
 lib/RT/Ticket.pm                         | 50 +++++++++-----------------------
 share/html/Elements/RT__Ticket/ColumnMap |  9 +++---
 2 files changed, 17 insertions(+), 42 deletions(-)

- Log -----------------------------------------------------------------
commit 55d9d23525903ef6221ae01f7ee2dcefa84b4676
Author: Aaron Trevena <ast at bestpractical.com>
Date:   Fri Jan 24 20:28:03 2020 +0000

    Reworked unread message count to be consistent with core
    
    CSS style was un-necessary, simplified to just be bold like title
    Worked new unread count value into existing method in list context

diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index f257885bc6..d43b0e58c8 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1524,41 +1524,6 @@ sub TotalTimeWorkedPerUser {
     return $time;
 }
 
-=head2 SeenUpToCount
-
-Returns the number of transactions marked as seen by this user for this ticket
-
-=cut
-
-sub SeenUpToCount {
-    my $self= shift;
-    my $uid = $self->CurrentUser->id;
-    my $attr = $self->FirstAttribute( "User-". $uid ."-SeenUpTo" );
-    if( $attr && $attr->Content gt $self->LastUpdated) {
-        return ( 0, undef);
-    }
-
-    my $txns = $self->Transactions;
-    $txns->Limit( FIELD => 'Type', VALUE => 'Comment' );
-    $txns->Limit( FIELD => 'Type', VALUE => 'Correspond' );
-    $txns->Limit( FIELD => 'Creator', OPERATOR => '!=', VALUE => $uid );
-    $txns->Limit(
-        FIELD => 'Created',
-        OPERATOR => '>',
-        VALUE => $attr->Content
-    ) if $attr;
-
-    my $count = $txns->Count;
-
-    if( $count) {
-        my $first_unread = $txns->First;
-        return ($count, $first_unread);
-    } else {
-        return (0, undef);
-    }
-}
-
-
 =head2 Comment
 
 Comment on this ticket.
@@ -2636,6 +2601,8 @@ sub _SetTold {
 
 =head2 SeenUpTo
 
+Returns the first transaction since last viewed/interacted by user
+In list context returns the first transaction and number of transactions marked as seen by this user for this ticket
 
 =cut
 
@@ -2643,7 +2610,9 @@ sub SeenUpTo {
     my $self = shift;
     my $uid = $self->CurrentUser->id;
     my $attr = $self->FirstAttribute( "User-". $uid ."-SeenUpTo" );
-    return if $attr && $attr->Content gt $self->LastUpdated;
+    if ($attr && $attr->Content gt $self->LastUpdated ) {
+        return (wantarray) ? ( undef, 0 ) : undef ;
+    }
 
     my $txns = $self->Transactions;
     $txns->Limit( FIELD => 'Type', VALUE => 'Comment' );
@@ -2655,7 +2624,14 @@ sub SeenUpTo {
         VALUE => $attr->Content
     ) if $attr;
     $txns->RowsPerPage(1);
-    return $txns->First;
+
+    my $next_unread_txn = $txns->First;
+    if (wantarray) {
+        my $count = $txns->Count || 0;
+        return ($next_unread_txn, $count);
+    }
+
+    return $next_unread_txn;
 }
 
 =head2 RanTransactionBatch
diff --git a/share/html/Elements/RT__Ticket/ColumnMap b/share/html/Elements/RT__Ticket/ColumnMap
index dea828f128..6c4053a898 100644
--- a/share/html/Elements/RT__Ticket/ColumnMap
+++ b/share/html/Elements/RT__Ticket/ColumnMap
@@ -334,17 +334,16 @@ $COLUMN_MAP = {
     },
     UnreadMessages => {
        title     => 'Unread Messages', # loc
-       attribute => 'UnreadMessages',
        value     => sub {
             my $self = shift;
 
-            my( $count, $first_unread) = $self->SeenUpToCount;
+            my ($first_unread, $count) = $self->SeenUpTo;
 
             return '0' if ! $count;
 
-            return \('<a class="unread_nb" title="jump to Unread & Mark as Seen" href="'. RT->Config->Get('WebPath') .'/Ticket/Display.html?id='
-            . $self->id .'&MarkAsSeen=1&Anchor=txn-'. $first_unread->id .'">'),
-            $count, \'</a>';
+            return \('<a title="jump to Unread & Mark as Seen" href="'. RT->Config->Get('WebPath') .'/Ticket/Display.html?id='
+            . $self->id .'&MarkAsSeen=1&Anchor=txn-'. $first_unread->id .'"><b>'),
+            $count, \'</b></a>';
         }
    }
 };

-----------------------------------------------------------------------


More information about the rt-commit mailing list