madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r23141: LJSUP-13883: Journal pages optimizaiton ...

Committer: sbelyaev
LJSUP-13883: Journal pages optimizaiton : stage 1
U   trunk/cgi-bin/LJ/S2.pm
Modified: trunk/cgi-bin/LJ/S2.pm
===================================================================
--- trunk/cgi-bin/LJ/S2.pm	2012-10-15 21:27:38 UTC (rev 23140)
+++ trunk/cgi-bin/LJ/S2.pm	2012-10-15 21:43:44 UTC (rev 23141)
@@ -4195,31 +4195,36 @@
 
     my $newentry_etypeid = 'LJ::Event::JournalNewEntry'->etypeid;
 
-    my $newentry_sub = $this->{__newentry_sub}->{$journalu->id} || undef;
-    if ($remote && !$newentry_sub) { 
-        ($newentry_sub) = $remote->has_subscription( journalid      => $journalu->id,
-                                                    event          => "JournalNewEntry",
-                                                    require_active => 1,);
+    my $__get_newentry_info = sub {
+        my $newentry_sub = $this->{__newentry_sub}->{$journalu->id};
+        if ($remote && !$newentry_sub) { 
+            ($newentry_sub) = $remote->has_subscription( journalid      => $journalu->id,
+                                                        event          => "JournalNewEntry",
+                                                        require_active => 1,);
+    
+            $this->{__newentry_sub}->{$journalu->id} = $newentry_sub;
+        }
+    
+        my $newentry_auth_token;
+    
+        if ($newentry_sub) {
+            $newentry_auth_token = LJ::Auth->ajax_auth_token($remote, '/__rpc_esn_subs',
+                                                             subid     => $newentry_sub->id,
+                                                             action    => 'delsub',);
+        } elsif ($remote) {
+            $newentry_auth_token = LJ::Auth->ajax_auth_token($remote, '/__rpc_esn_subs',
+                                                             journalid => $journalu->id,
+                                                             action    => 'addsub',
+                                                             etypeid   => $newentry_etypeid,);
+        }
+        
+        return ($newentry_sub, $newentry_auth_token);
+    };
 
-        $this->{__newentry_sub}->{$journalu->id} = $newentry_sub;
-    }
-
-    my $newentry_auth_token;
-
-    if ($newentry_sub) {
-        $newentry_auth_token = LJ::Auth->ajax_auth_token($remote, '/__rpc_esn_subs',
-                                                         subid     => $newentry_sub->id,
-                                                         action    => 'delsub',);
-    } elsif ($remote) {
-        $newentry_auth_token = LJ::Auth->ajax_auth_token($remote, '/__rpc_esn_subs',
-                                                         journalid => $journalu->id,
-                                                         action    => 'addsub',
-                                                         etypeid   => $newentry_etypeid,);
-    }
-
     if ($key eq "watch_comments") {
         return $null_link if $LJ::DISABLED{'esn'};
         return $null_link unless $remote && $remote->can_use_esn;
+        
         return $null_link if $remote->has_subscription(
                                                        journal => $journalu,
                                                        event   => "JournalNewComment",
@@ -4228,6 +4233,8 @@
                                                        require_active => 1,
                                                        );
 
+        my ($newentry_sub, $newentry_auth_token) = $__get_newentry_info->();
+
         my $auth_token = LJ::Auth->ajax_auth_token($remote, '/__rpc_esn_subs',
                                                    journalid => $journalu->id,
                                                    action    => 'addsub',
@@ -4261,6 +4268,7 @@
         my $subscr = $subs[0];
         return $null_link unless $subscr;
 
+        my ($newentry_sub, $newentry_auth_token) = $__get_newentry_info->();
         my $auth_token = LJ::Auth->ajax_auth_token($remote, '/__rpc_esn_subs',
                                                    subid  => $subscr->id,
                                                    action => 'delsub');

Tags: livejournal, madeon, pm, sbelyaev
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