[gitg/wip/commit] Allow clearing diff view



commit a93c0eddc6b1fd4192f170d33eaa83633cc5de2b
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Wed Jul 3 18:50:18 2013 +0200

    Allow clearing diff view

 libgitg/gitg-diff-view.vala    |   14 +++++++++++++-
 libgitg/resources/diff-view.js |   17 +++++++++++++----
 2 files changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/libgitg/gitg-diff-view.vala b/libgitg/gitg-diff-view.vala
index 2c8b642..bd076e9 100644
--- a/libgitg/gitg-diff-view.vala
+++ b/libgitg/gitg-diff-view.vala
@@ -287,11 +287,23 @@ namespace Gitg
 
                private void update()
                {
-                       if (!d_loaded || (d_diff == null && d_commit == null))
+                       if (!d_loaded)
                        {
                                return;
                        }
 
+                       if (d_diff == null && d_commit == null)
+                       {
+                               run_javascript.begin("update_diff();", d_cancellable, (obj, res) => {
+                                       try
+                                       {
+                                               run_javascript.end(res);
+                                       } catch {}
+                               });
+
+                               return;
+                       }
+
                        // Cancel running operations
                        d_cancellable.cancel();
                        d_cancellable = new Cancellable();
diff --git a/libgitg/resources/diff-view.js b/libgitg/resources/diff-view.js
index 5103eb1..ec989e3 100644
--- a/libgitg/resources/diff-view.js
+++ b/libgitg/resources/diff-view.js
@@ -125,13 +125,24 @@ var html_builder_tick = 0;
 
 function update_diff(id, lsettings)
 {
-       $.extend(settings, lsettings);
-
        if (html_builder_worker)
        {
                html_builder_worker.terminate();
        }
 
+       var content = document.getElementById('diff_content');
+
+       if (typeof id == 'undefined')
+       {
+               $(content).empty();
+               return;
+       }
+
+       if (typeof lsettings != 'undefined')
+       {
+               $.extend(settings, lsettings);
+       }
+
        workeruri = 'diff-view-html-builder.js';
 
        if (settings.debug)
@@ -143,8 +154,6 @@ function update_diff(id, lsettings)
        html_builder_worker = new Worker(workeruri);
        html_builder_tick = 0;
 
-       var content = document.getElementById('diff_content');
-
        html_builder_progress_timeout = setTimeout(function (){
                var eta = 200 / html_builder_tick - 200;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]