From b8cc83121f795d2f6bf0982cbaa39da775383c60 Mon Sep 17 00:00:00 2001
From: Benoit Lavenier <benoit.lavenier@e-is.pro>
Date: Fri, 6 Mar 2020 16:00:36 +0100
Subject: [PATCH] [fix] Home: add a cache to home feed [enh] No more include
 feed into release artifact, but load it feed from repo (/doc/feed/)

---
 app/config.json                       | 8 ++++----
 {www => doc/feed}/feed-fr.json        | 0
 gulpfile.js                           | 8 ++++++--
 scripts/release.sh                    | 4 ++--
 www/js/config.js                      | 6 +++---
 www/js/controllers/app-controllers.js | 5 +++--
 6 files changed, 18 insertions(+), 13 deletions(-)
 rename {www => doc/feed}/feed-fr.json (100%)

diff --git a/app/config.json b/app/config.json
index 5db6e6450..271e21a68 100644
--- a/app/config.json
+++ b/app/config.json
@@ -29,8 +29,8 @@
     },
     "feed": {
       "jsonFeed": {
-        "fr-FR": "https://g1.duniter.fr/feed-fr.json",
-        "en": "https://g1.duniter.fr/feed-en.json"
+        "fr-FR": "https://raw.githubusercontent.com/duniter/cesium/master/doc/feed/feed-fr.json",
+        "en": "https://raw.githubusercontent.com/duniter/cesium/master/doc/feed/feed-en.json"
       },
       "maxContentLength": 650
     },
@@ -117,8 +117,8 @@
     },
     "feed": {
       "jsonFeed": {
-        "fr-FR": "https://g1.duniter.fr/feed-fr.json",
-        "en": "https://g1.duniter.fr/feed-en.json"
+        "fr-FR": "https://raw.githubusercontent.com/duniter/cesium/master/doc/feed/feed-fr.json",
+        "en": "https://raw.githubusercontent.com/duniter/cesium/master/doc/feed/feed-en.json"
       },
       "maxContentLength": 650
     },
diff --git a/www/feed-fr.json b/doc/feed/feed-fr.json
similarity index 100%
rename from www/feed-fr.json
rename to doc/feed/feed-fr.json
diff --git a/gulpfile.js b/gulpfile.js
index 65c1381c6..fe75b8e0e 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -342,10 +342,14 @@ function webCopyFiles() {
     gulp.src('./www/img/**/*.*')
       .pipe(gulp.dest(tmpPath + '/img')),
 
-    // Copy manifest.json, feed.json
-    gulp.src(['./www/manifest.json', './www/feed*.json'])
+    // Copy manifest.json
+    gulp.src('./www/manifest.json')
       .pipe(gulp.dest(tmpPath)),
 
+    // Copy feed*.json
+    //gulp.src('./www/feed*.json')
+    //  .pipe(gulp.dest(tmpPath)),
+
     // Copy lib
     gulp.src('./www/lib/**/*.*')
       .pipe(gulp.dest(tmpPath + '/lib')),
diff --git a/scripts/release.sh b/scripts/release.sh
index 5d8e5865b..e6d1088e4 100755
--- a/scripts/release.sh
+++ b/scripts/release.sh
@@ -173,7 +173,7 @@ fi
 echo "----------------------------------"
 echo "- Building desktop artifacts..."
 echo "----------------------------------"
-. ${PROJECT_DIR}/scripts/release-desktop.sh $1 ''"$description"''
+. ${PROJECT_DIR}/scripts/release-desktop.sh $1
 if [[ $? -ne 0 ]]; then
     exit 1
 fi
@@ -184,7 +184,7 @@ nvm use ${NODEJS_VERSION}
 echo "----------------------------------"
 echo "- Push git android project..."
 echo "----------------------------------"
-. ${PROJECT_DIR}/scripts/release-android-sources.sh $2  ''"$description"''
+. ${PROJECT_DIR}/scripts/release-android-sources.sh $2
 
 echo "**********************************"
 echo "* Build release succeed !"
diff --git a/www/js/config.js b/www/js/config.js
index 392100803..d7d7dfb18 100644
--- a/www/js/config.js
+++ b/www/js/config.js
@@ -38,8 +38,8 @@ angular.module("cesium.config", [])
 	},
 	"feed": {
 		"jsonFeed": {
-			"fr-FR": "https://g1.duniter.fr/feed-fr.json",
-			"en": "https://g1.duniter.fr/feed-en.json"
+			"fr-FR": "https://raw.githubusercontent.com/duniter/cesium/master/www/feed-fr.json",
+			"en": "https://raw.githubusercontent.com/duniter/cesium/master/www/feed-en.json"
 		},
 		"maxContentLength": 650
 	},
@@ -102,4 +102,4 @@ angular.module("cesium.config", [])
 	"newIssueUrl": "https://git.duniter.org/clients/cesium-grp/cesium/issues/new"
 })
 
-;
\ No newline at end of file
+;
diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js
index aca8492f6..c3b9c6957 100644
--- a/www/js/controllers/app-controllers.js
+++ b/www/js/controllers/app-controllers.js
@@ -511,7 +511,8 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $
 }
 
 
-function HomeController($scope, $state, $timeout, $ionicHistory, $translate, $http, UIUtils, csConfig, csPlatform, csCurrency, csSettings) {
+function HomeController($scope, $state, $timeout, $ionicHistory, $translate, $http, UIUtils,
+                        csConfig, csCache, csPlatform, csCurrency, csSettings) {
   'ngInject';
 
   $scope.loading = true;
@@ -574,7 +575,7 @@ function HomeController($scope, $state, $timeout, $ionicHistory, $translate, $ht
     var now = Date.now();
     console.debug("[home] Loading feeds from {0}...".format(feedUrl));
 
-    $http.get(feedUrl, {responseType: 'json'})
+    $http.get(feedUrl, {responseType: 'json', cache: csCache.get(null, csCache.constants.LONG)})
       .success(function(feed) {
         console.debug('[home] Feeds loaded in {0}ms'.format(Date.now()-now));
         if (!feed || !feed.items || !feed.items.length) return // skip if empty
-- 
GitLab