From 140b1ef1a7b110178aebe17334353fa803d2ede7 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Thu, 31 Oct 2019 14:20:01 -0400 Subject: #857 flush cache when switching servers --- config.xml | 8 ++++---- package.json | 8 ++++---- www/js/LoginCtrl.js | 12 ++++++++++++ www/js/MenuController.js | 13 ++++++++++++- www/js/NVR.js | 3 ++- 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/config.xml b/config.xml index d16ab4fc..1b6c7f38 100644 --- a/config.xml +++ b/config.xml @@ -1,5 +1,5 @@ - + zmNinja High performance ZoneMinder client @@ -176,10 +176,10 @@ - - - + + + diff --git a/package.json b/package.json index 93306d8e..90e9bcf2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "zmninjapro", "description": "Home security mobile app for ZoneMinder", - "version": "1.3.079", + "version":"1.3.080", "displayName": "zmNinja", "author": "Pliable Pixels", "license": "custom see LICENSE.md", @@ -58,10 +58,10 @@ "cordova-plugin-photo-library": { "PHOTO_LIBRARY_USAGE_DESCRIPTION": "Save monitor photos to albums" }, + "cordova-plugin-media-pp-fork": {}, "cordova-plugin-ionic-webview": { "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+" - }, - "cordova-plugin-media-pp-fork": {} + } } }, "dependencies": { @@ -191,4 +191,4 @@ ] } } -} \ No newline at end of file +} diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js index cd6861a8..11474f2d 100644 --- a/www/js/LoginCtrl.js +++ b/www/js/LoginCtrl.js @@ -594,6 +594,18 @@ function mobilePinConfig () { function saveItems(showalert) { + NVR.flushAPICache() + .then (function() { + _saveItems(showalert); + }) + .catch (function(err) { + NVR.debug ('Error clearing cache:'+JSON.stringify(err)); + _saveItems(showalert); + }); + + } + function _saveItems(showalert) { + //console.log ("*********** SAVE ITEMS CALLED "); //console.log('Saving login'); diff --git a/www/js/MenuController.js b/www/js/MenuController.js index 92aca6da..781fb21e 100644 --- a/www/js/MenuController.js +++ b/www/js/MenuController.js @@ -384,7 +384,18 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io } if (NVR.getLogin().serverName != $scope.newServer.val) - switchToServer($scope.newServer.val); + { + NVR.flushAPICache() + .then (function() { + switchToServer($scope.newServer.val); + }) + .catch (function(err) { + NVR.debug ('Error clearing cache:'+JSON.stringify(err)); + switchToServer($scope.newServer.val); + }); + } + + //$rootScope.$broadcast('server-changed'); diff --git a/www/js/NVR.js b/www/js/NVR.js index eb3ba08e..0d1a9bd2 100644 --- a/www/js/NVR.js +++ b/www/js/NVR.js @@ -21,7 +21,7 @@ angular.module('zmApp.controllers') DO NOT TOUCH zmAppVersion It is changed by sync_version.sh */ - var zmAppVersion = "1.3.079"; + var zmAppVersion = "1.3.080"; var zmAPIVersion = null; var isBackground = false; var justResumed = false; @@ -349,6 +349,7 @@ angular.module('zmApp.controllers') } function delete_all_caches() { + debug ('CACHE: Flushing all network API caches...'); return localforage.removeItem('cached_monitors') .then ( function () {return localforage.removeItem('cached_api_version');}) .then ( function () {return localforage.removeItem('cached_multi_servers');}) -- cgit v1.2.3