Alexander Nazarov (nfokz) wrote in changelog,
Alexander Nazarov
nfokz
changelog

[livejournal] r23470: LJSUP-14359: 2. List of messages + Reply...

Committer: anazarov
LJSUP-14359: 2. List of messages + Reply (Lebedev's redesign) - Unread messages
U   trunk/cgi-bin/LJ/NotificationItem.pm
Modified: trunk/cgi-bin/LJ/NotificationItem.pm
===================================================================
--- trunk/cgi-bin/LJ/NotificationItem.pm	2012-12-14 08:42:54 UTC (rev 23469)
+++ trunk/cgi-bin/LJ/NotificationItem.pm	2012-12-14 09:00:28 UTC (rev 23470)
@@ -158,25 +158,27 @@
 sub _state {
     &_load unless $_[0]->{'_loaded'};
 
-    return $_[0]->{'state'};
+    return $_[0]->{'state'} || '';
 }
 
 # returns if this event is marked as read
 sub read {
-    return 0 unless defined $_[0]->_state;
-    return $_[0]->_state eq 'R';
+    return &_state eq 'R';
 }
 
 # returns if this event is marked as unread
 sub unread {
-    return 0 unless defined $_[0]->_state;
-    return $_[0]->_state eq 'N';
+    return uc &_state eq 'N';
 }
 
+# returns if this event was marked as unread by user
+sub user_unread {
+    return &_state eq 'n';
+}
+
 # returns if this event is marked as spam
 sub spam {
-    return 0 unless defined $_[0]->_state;
-    return $_[0]->_state eq 'S';
+    return &_state eq 'S';
 }
 
 # delete this item from its inbox
@@ -192,20 +194,24 @@
 
 # mark this item as read
 sub mark_read {
-    my $self = shift;
+    # do nothing if it's already marked as read
+    return if &read;
 
-    # do nothing if it's already marked as read
-    return if $self->read;
-    $self->_set_state('R');
+    _set_state($_[0], 'R');
 }
 
+# mark this item as read if it was marked as unread by system
+sub auto_read {
+    &mark_read
+        unless &read or &user_unread;
+}
+
 # mark this item as read
 sub mark_unread {
-    my $self = shift;
+    # do nothing if it's already marked as unread
+    return if &unread;
 
-    # do nothing if it's already marked as unread
-    return if $self->unread;
-    $self->_set_state('N');
+    _set_state($_[0], 'n');
 }
 
 # sets the state of this item

Tags: anazarov, livejournal, nfokz, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments