Skip to content

Commit

Permalink
ZoneMinder#857 flush cache when switching servers
Browse files Browse the repository at this point in the history
  • Loading branch information
pliablepixels committed Oct 31, 2019
1 parent d6a0a69 commit 140b1ef
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 10 deletions.
8 changes: 4 additions & 4 deletions config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget android-packageName="com.pliablepixels.zmninja_pro" id="com.pliablepixels.zmninja_pro" ios-CFBundleIdentifier="com.pliablepixels.zmninja-pro" version="1.3.079" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget android-packageName="com.pliablepixels.zmninja_pro" id="com.pliablepixels.zmninja_pro" ios-CFBundleIdentifier="com.pliablepixels.zmninja-pro" version="1.3.080" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>zmNinja</name>
<description>
High performance ZoneMinder client
Expand Down Expand Up @@ -176,10 +176,10 @@
<plugin name="cordova-plugin-photo-library" spec="https://github.com/pliablepixels/cordova-plugin-photo-library">
<variable name="PHOTO_LIBRARY_USAGE_DESCRIPTION" value=" " />
</plugin>
<plugin name="cordova-plugin-ionic-webview" spec="https://github.com/pliablepixels/cordova-plugin-ionic-webview.git">
<variable name="ANDROID_SUPPORT_ANNOTATIONS_VERSION" value="27.+" />
</plugin>
<plugin name="cordova-plugin-media-pp-fork" spec="^1.0.2-dev" />
<engine name="ios" spec="4.5.5" />
<engine name="android" spec="8.0.0" />
<plugin name="cordova-plugin-ionic-webview" spec="https://github.com/pliablepixels/cordova-plugin-ionic-webview.git">
<variable name="ANDROID_SUPPORT_ANNOTATIONS_VERSION" value="27.+" />
</plugin>
</widget>
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -191,4 +191,4 @@
]
}
}
}
}
12 changes: 12 additions & 0 deletions www/js/LoginCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
13 changes: 12 additions & 1 deletion www/js/MenuController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
3 changes: 2 additions & 1 deletion www/js/NVR.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');})
Expand Down

0 comments on commit 140b1ef

Please sign in to comment.