[epiphany] Get rid of web app install_date string



commit d157c9529a8e33b8343a6954cea7346517002bc8
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Tue Feb 22 10:31:53 2022 -0800

    Get rid of web app install_date string
    
    Just create the string in the one place we need it rather than always
    storing it. This introduces no functional changes.

 embed/ephy-about-handler.c                       | 8 +++++++-
 lib/ephy-web-app-utils.c                         | 9 ---------
 lib/ephy-web-app-utils.h                         | 1 -
 src/profile-migrator/ephy-legacy-web-app-utils.c | 8 +-------
 4 files changed, 8 insertions(+), 18 deletions(-)
---
diff --git a/embed/ephy-about-handler.c b/embed/ephy-about-handler.c
index ea6658710..915cfca2e 100644
--- a/embed/ephy-about-handler.c
+++ b/embed/ephy-about-handler.c
@@ -268,10 +268,16 @@ handle_applications_finished_cb (EphyAboutHandler       *handler,
       g_autofree char *encoded_name = NULL;
       g_autofree char *encoded_url = NULL;
       g_autofree char *js_encoded_id = NULL;
+      g_autoptr (GDate) date = NULL;
+      char install_date[128];
 
       if (ephy_web_application_is_system (app))
         continue;
 
+      date = g_date_new ();
+      g_date_set_time_t (date, (time_t)app->install_date_uint64);
+      g_date_strftime (install_date, 127, "%x", date);
+
       /* Most of these fields are at least semi-trusted. The app ID was chosen
        * by ephy so it's safe. The icon URL could be changed by the user to
        * something else after web app creation, though, so better not fully
@@ -291,7 +297,7 @@ handle_applications_finished_cb (EphyAboutHandler       *handler,
                               "<td class=\"date\">%s <br /> %s</td></tr></tbody>",
                               app->id, encoded_icon_url, encoded_name, encoded_url, _("Delete"), app->id,
                               /* Note for translators: this refers to the installation date. */
-                              _("Installed on:"), app->install_date);
+                              _("Installed on:"), install_date);
     }
 
     g_string_append (data_str, "</table></div></body></html>");
diff --git a/lib/ephy-web-app-utils.c b/lib/ephy-web-app-utils.c
index 7f8f37de8..b92d39bf7 100644
--- a/lib/ephy-web-app-utils.c
+++ b/lib/ephy-web-app-utils.c
@@ -563,7 +563,6 @@ ephy_web_application_for_profile_directory (const char *profile_dir)
   g_auto (GStrv) argv = NULL;
   g_autoptr (GFile) file = NULL;
   g_autoptr (GFileInfo) file_info = NULL;
-  g_autoptr (GDate) date = NULL;
   g_autoptr (GError) error = NULL;
   g_autoptr (GKeyFile) key_file = NULL;
 
@@ -596,10 +595,6 @@ ephy_web_application_for_profile_directory (const char *profile_dir)
     file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED, 0, NULL, NULL);
     app->install_date_uint64 = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
 
-    date = g_date_new ();
-    g_date_set_time_t (date, (time_t)app->install_date_uint64);
-    g_date_strftime (app->install_date, 127, "%x", date);
-
     return g_steal_pointer (&app);
   }
 
@@ -627,10 +622,6 @@ ephy_web_application_for_profile_directory (const char *profile_dir)
   file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED, 0, NULL, NULL);
   app->install_date_uint64 = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
 
-  date = g_date_new ();
-  g_date_set_time_t (date, (time_t)app->install_date_uint64);
-  g_date_strftime (app->install_date, 127, "%x", date);
-
   return g_steal_pointer (&app);
 }
 
diff --git a/lib/ephy-web-app-utils.h b/lib/ephy-web-app-utils.h
index 0616d1bfa..6f154043d 100644
--- a/lib/ephy-web-app-utils.h
+++ b/lib/ephy-web-app-utils.h
@@ -33,7 +33,6 @@ typedef struct {
   char *url;
   char *desktop_file; /* only used for legacy apps */
   char *desktop_path;
-  char install_date[128];
   guint64 install_date_uint64;
 } EphyWebApplication;
 
diff --git a/src/profile-migrator/ephy-legacy-web-app-utils.c 
b/src/profile-migrator/ephy-legacy-web-app-utils.c
index 09c31ba1a..c256bf1ac 100644
--- a/src/profile-migrator/ephy-legacy-web-app-utils.c
+++ b/src/profile-migrator/ephy-legacy-web-app-utils.c
@@ -237,8 +237,6 @@ ephy_legacy_web_application_for_profile_directory (const char *profile_dir)
   g_auto (GStrv) argv = NULL;
   g_autoptr (GFile) file = NULL;
   g_autoptr (GFileInfo) file_info = NULL;
-  guint64 created;
-  g_autoptr (GDate) date = NULL;
 
   id = get_app_id_from_profile_directory (profile_dir);
   if (!id)
@@ -265,11 +263,7 @@ ephy_legacy_web_application_for_profile_directory (const char *profile_dir)
 
   /* FIXME: this should use TIME_CREATED but it does not seem to be working. */
   file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED, 0, NULL, NULL);
-  created = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
-
-  date = g_date_new ();
-  g_date_set_time_t (date, (time_t)created);
-  g_date_strftime (app->install_date, 127, "%x", date);
+  app->install_date_uint64 = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
 
   return g_steal_pointer (&app);
 }


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