history wip: Updating history list after saving document
[fnpeditor.git] / modules / data.js
index df40322..33c8df6 100644 (file)
@@ -43,6 +43,17 @@ return function(sandbox) {
         }\r
     });\r
     \r
+    var reloadHistory = function() {\r
+        $.ajax({\r
+            method: 'get',\r
+            url: '/' + gettext('editor') + '/' + document_id + '/history',\r
+            success: function(data) {\r
+                history = data; \r
+                sandbox.publish('historyItemAdded', data.slice(-1)[0]);\r
+            },\r
+        });\r
+    }\r
+    \r
     return {\r
         start: function() {\r
             sandbox.publish('ready');\r
@@ -60,7 +71,7 @@ return function(sandbox) {
                 method: 'post',\r
                 url: '/' + gettext('editor') + '/' + document_id,\r
                 data: JSON.stringify({document:doc}),\r
-                success: function() {sandbox.publish('savingEnded', 'success');},\r
+                success: function() {sandbox.publish('savingEnded', 'success'); reloadHistory();},\r
                 error: function() {sandbox.publish('savingEnded', 'error');}\r
             });\r
         },\r