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

[livejournal] r22334: LJSUP-12668: Autosave works incorrect

Committer: anazarov
LJSUP-12668: Autosave works incorrect
U   trunk/htdocs/tools/endpoints/draft.bml
U   trunk/htdocs/update.bml
Modified: trunk/htdocs/tools/endpoints/draft.bml
===================================================================
--- trunk/htdocs/tools/endpoints/draft.bml	2012-06-27 07:20:18 UTC (rev 22333)
+++ trunk/htdocs/tools/endpoints/draft.bml	2012-06-27 07:33:23 UTC (rev 22334)
@@ -1,6 +1,7 @@
 <?_code # -*-bml-*-
 {
     use strict;
+    use LJ::Draft qw{ encode decode };
     use vars qw(%POST);
 
     my $err = sub {
@@ -20,15 +21,19 @@
     }
 
     my $ret = {};
+    my $draft = delete $POST{'saveDraft'};
 
-    if (defined $POST{'saveDraft'}) {
-        $u->set_draft_text($POST{'saveDraft'});
-
-    } elsif ($POST{'clearDraft'}) {
+    if ( defined $draft ) {
+        $u->set_draft_text(encode($draft));
+    } elsif ( $POST{'clearDraft'} ) {
         $u->set_draft_text('');
-
     } else {
-        $ret->{draft} = $u->draft_text;
+        my $decoded = decode($u->draft_text);
+        if ( ref $decoded ) {
+            %$ret = (%$ret, %$decoded);
+        } else {
+            $ret->{'draft'} = $decoded;
+        }
     }
 
     sleep 1 if $LJ::IS_DEV_SERVER;

Modified: trunk/htdocs/update.bml
===================================================================
--- trunk/htdocs/update.bml	2012-06-27 07:20:18 UTC (rev 22333)
+++ trunk/htdocs/update.bml	2012-06-27 07:33:23 UTC (rev 22334)
@@ -1,6 +1,7 @@
 <?_code
 {
     use strict;
+    use LJ::Draft qw{ get_draft_text };
     use vars qw(%GET %POST %ML);
     BML::decl_params(_default => qr/./);
 
@@ -757,7 +758,7 @@
     my $remote = LJ::get_remote();
     my $draft = '""';
     if ($remote) {
-        $draft = LJ::ejs_string($remote->prop('entry_draft'));
+        $draft = LJ::ejs_string(get_draft_text($remote->draft_text));
     }
 
     my $eMLautosave = LJ::ejs(BML::ml('.draft.autosave', { 'time' => '[[time]]' }));

Tags: anazarov, bml, livejournal, nfokz
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