From ba185f32b3a469ec07f74b194d1eab2326408291 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Thu, 1 Nov 2018 23:58:02 -0600 Subject: [PATCH] Add pull to refresh on home screen --- www/js/home.js | 55 +++++++++++++++++++++++++++++++++------------ www/pages/home.html | 16 +++++++------ 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/www/js/home.js b/www/js/home.js index 8ff05b7..8060d11 100644 --- a/www/js/home.js +++ b/www/js/home.js @@ -5,14 +5,19 @@ */ -function loadHomePage() { +function loadHomePage(reload) { + if (typeof reload == 'undefined') { + reload = false; + } $.post(localStorage.getItem("syncurl"), { username: localStorage.getItem("username"), key: localStorage.getItem("key"), action: "listapps" }, function (data) { if (data.status === 'OK') { - loadingProgressDialog.setProgress(80); + if (!reload) { + loadingProgressDialog.setProgress(80); + } var appcards = []; Object.keys(data.apps).forEach(function (k) { var app = data.apps[k]; @@ -32,18 +37,35 @@ function loadHomePage() { color: app.card.color }); }); - loadingProgressDialog.setProgress(90); - router.navigate("/home", { - context: { - appcards: appcards - } - }); - $(".view-main").on("click", "#applist .applist-item", function () { - launchapp($(this).data("api"), $(this).data("url"), $(this).data("icon"), $(this).data("title")); - }); - loadingProgressDialog.setProgress(100); - loadingProgressDialog.close(); + if (reload) { + // Make it seem like it's doing something on fast connections + setTimeout(function () { + app.ptr.done(); + router.navigate("/home", { + context: { + appcards: appcards + }, + reloadCurrent: true + }); + }, 500); + } else { + loadingProgressDialog.setProgress(90); + router.navigate("/home", { + context: { + appcards: appcards + } + }); + $(".view-main").on("click", "#applist .applist-item", function () { + launchapp($(this).data("api"), $(this).data("url"), $(this).data("icon"), $(this).data("title")); + }); + loadingProgressDialog.setProgress(100); + loadingProgressDialog.close(); + } } else { + if (reload) { + app.ptr.done(); + return; + } loadingProgressDialog.close(); app.dialog.alert(data.msg, "Error", function () { restartApplication(); @@ -56,4 +78,9 @@ function loadHomePage() { }); }); -} \ No newline at end of file +} + + +$(".view-main").on("ptr:refresh", ".ptr-content", function () { + loadHomePage(true); +}); \ No newline at end of file diff --git a/www/pages/home.html b/www/pages/home.html index f0e8f5d..ab3a095 100644 --- a/www/pages/home.html +++ b/www/pages/home.html @@ -11,18 +11,20 @@ + + + - +
+ +
+
+
+
-
Apps