[bijiben] webkit-editor: Remove unneed saving on first load



commit aa8c5c5838458a52ab7be2d76761d679184620f0
Author: Isaque Galdino <igaldino gmail com>
Date:   Tue Jan 23 02:05:15 2018 -0200

    webkit-editor: Remove unneed saving on first load
    
    Every time a note is opened, unnecessary saving action is triggered.
    That changes update times, and changes notes order in main view. It also
    increases note load times, mainly for remote notes, like owncloud.
    
    This patch makes sure that on first load, webkit editor doesn't try to
    save the note.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=792824

 src/libbiji/editor/biji-webkit-editor.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/libbiji/editor/biji-webkit-editor.c b/src/libbiji/editor/biji-webkit-editor.c
index 180d8e7..43eaeaa 100644
--- a/src/libbiji/editor/biji-webkit-editor.c
+++ b/src/libbiji/editor/biji-webkit-editor.c
@@ -57,7 +57,7 @@ struct _BijiWebkitEditorPrivate
   gboolean has_text;
   gchar *selected_text;
   BlockFormat block_format;
-
+  gboolean first_load;
   EEditorSelection *sel;
 };
 
@@ -516,7 +516,12 @@ on_script_message (WebKitUserContentManager *user_content,
 
   message_name = get_js_property_string (js_context, js_object, "messageName");
   if (g_strcmp0 (message_name, "ContentsUpdate") == 0)
-    biji_webkit_editor_handle_contents_update (self, js_context, js_object);
+    {
+      if (self->priv->first_load)
+        self->priv->first_load = FALSE;
+      else
+        biji_webkit_editor_handle_contents_update (self, js_context, js_object);
+    }
   else if (g_strcmp0 (message_name, "SelectionChange") == 0)
     biji_webkit_editor_handle_selection_change (self, js_context, js_object);
   g_free (message_name);
@@ -535,6 +540,7 @@ biji_webkit_editor_constructed (GObject *obj)
   self = BIJI_WEBKIT_EDITOR (obj);
   view = WEBKIT_WEB_VIEW (self);
   priv = self->priv;
+  priv->first_load = TRUE;
 
   G_OBJECT_CLASS (biji_webkit_editor_parent_class)->constructed (obj);
 


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