diff --git a/www/js/config/dynamicConfig.ts b/www/js/config/dynamicConfig.ts
index f88255d4c..7994391a4 100644
--- a/www/js/config/dynamicConfig.ts
+++ b/www/js/config/dynamicConfig.ts
@@ -2,6 +2,7 @@ import i18next from "i18next";
import { displayError, logDebug, logWarn } from "../plugin/logger";
import { getAngularService } from "../angular-react-helper";
import { fetchUrlCached } from "../commHelper";
+import { storageClear, storageGet, storageSet } from "../plugin/storage";
export const CONFIG_PHONE_UI="config/app_ui_config";
export const CONFIG_PHONE_UI_KVSTORE ="CONFIG_PHONE_UI";
@@ -174,7 +175,6 @@ function extractSubgroup(token, config) {
* @returns {boolean} boolean representing whether the config was updated or not
*/
function loadNewConfig(newToken, existingVersion = null) {
- const KVStore = getAngularService('KVStore');
const newStudyLabel = extractStudyName(newToken);
return readConfigFromServer(newStudyLabel).then((downloadedConfig) => {
if (downloadedConfig.version == existingVersion) {
@@ -190,7 +190,7 @@ function loadNewConfig(newToken, existingVersion = null) {
}
const storeConfigPromise = window['cordova'].plugins.BEMUserCache.putRWDocument(
CONFIG_PHONE_UI, toSaveConfig);
- const storeInKVStorePromise = KVStore.set(CONFIG_PHONE_UI_KVSTORE, toSaveConfig);
+ const storeInKVStorePromise = storageSet(CONFIG_PHONE_UI_KVSTORE, toSaveConfig);
// loaded new config, so it is both ready and changed
return Promise.all([storeConfigPromise, storeInKVStorePromise]).then(
([result, kvStoreResult]) => {
@@ -220,17 +220,13 @@ export function initByUser(urlComponents) {
}
export function resetDataAndRefresh() {
- const KVStore = getAngularService('KVStore');
- const resetNativePromise = window['cordova'].plugins.BEMUserCache.putRWDocument(CONFIG_PHONE_UI, {});
- const resetKVStorePromise = KVStore.clearAll();
- return Promise.all([resetNativePromise, resetKVStorePromise])
- .then(() => window.location.reload());
+ // const resetNativePromise = window['cordova'].plugins.BEMUserCache.putRWDocument(CONFIG_PHONE_UI, {});
+ storageClear({ local: true, native: true }).then(() => window.location.reload());
}
export function getConfig() {
if (storedConfig) return Promise.resolve(storedConfig);
- const KVStore = getAngularService('KVStore');
- return KVStore.get(CONFIG_PHONE_UI_KVSTORE).then((config) => {
+ return storageGet(CONFIG_PHONE_UI_KVSTORE).then((config) => {
if (config) {
storedConfig = config;
return config;
diff --git a/www/js/control/ProfileSettings.jsx b/www/js/control/ProfileSettings.jsx
index 8035c9462..566c100c1 100644
--- a/www/js/control/ProfileSettings.jsx
+++ b/www/js/control/ProfileSettings.jsx
@@ -22,6 +22,7 @@ import ControlCollectionHelper, {getHelperCollectionSettings, getState, isMedium
import { resetDataAndRefresh } from "../config/dynamicConfig";
import { AppContext } from "../App";
import { shareQR } from "../components/QrCode";
+import { storageClear } from "../plugin/storage";
//any pure functions can go outside
const ProfileSettings = () => {
@@ -35,7 +36,6 @@ const ProfileSettings = () => {
const CarbonDatasetHelper = getAngularService('CarbonDatasetHelper');
const UploadHelper = getAngularService('UploadHelper');
const EmailHelper = getAngularService('EmailHelper');
- const KVStore = getAngularService('KVStore');
const NotificationScheduler = getAngularService('NotificationScheduler');
const ControlHelper = getAngularService('ControlHelper');
const ClientStats = getAngularService('ClientStats');
@@ -387,15 +387,15 @@ const ProfileSettings = () => {
style={settingStyles.dialog(colors.elevation.level3)}>
{t('general-settings.clear-data')}
-