diff --git a/src/constants.js b/src/constants.js
index be04fc8..9b5e215 100644
--- a/src/constants.js
+++ b/src/constants.js
@@ -73,6 +73,7 @@ if (process.env.MAPTILER_API_KEY) {
};
}
export const DEFAULT_TILE_SERVER = 'cartodb-voyager';
+export const DEFAULT_TILE_CACHING_DURATION = -1;
export const GEOCODING_API_ENDPOINT = 'https://api-adresse.data.gouv.fr/search/';
diff --git a/src/i18n/en.json b/src/i18n/en.json
index ed1c749..592bbe0 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -118,10 +118,13 @@
"customTileServer": "Custom tile server",
"customTileServerURL": "Custom tile server URL",
"customTileServerURLHint": "For example: http://tile.thunderforest.com/cycle/{z}/{x}/{y}.png",
+ "defaultDuration": "Default duration",
"defaultOrientationMode": "Default orientation mode",
"fixedNorth": "Fixed (North up)",
"locale": "Language",
+ "noCaching": "No caching",
"skipOnboarding": "Skip onboarding",
+ "tileCachingDuration": "Cache map tiles for",
"tileServer": "Map tiles server"
},
"shareMapViewModal": {
diff --git a/src/store/mutations.js b/src/store/mutations.js
index d252d13..a07749a 100644
--- a/src/store/mutations.js
+++ b/src/store/mutations.js
@@ -2,7 +2,12 @@ import Vue from 'vue';
import { messages, getBrowserLocales } from '@/i18n';
import { storageAvailable } from '@/tools';
-import { DEFAULT_TILE_SERVER, TILE_SERVERS, VERSION } from '@/constants';
+import {
+ DEFAULT_TILE_CACHING_DURATION,
+ DEFAULT_TILE_SERVER,
+ TILE_SERVERS,
+ VERSION,
+} from '@/constants';
import * as types from './mutations-types';
function loadDataFromStorage(name) {
@@ -50,6 +55,7 @@ let hasPreventSuspendPermission = null;
let hasVibratePermission = null;
let shouldAutorotateMap = null;
let skipOnboarding = null;
+let tileCachingDuration = null;
let tileServer = null;
if (storageAvailable('localStorage')) {
handleMigrations();
@@ -67,6 +73,11 @@ if (storageAvailable('localStorage')) {
tileServer = null;
}
+ tileCachingDuration = loadDataFromStorage('tileCachingDuration');
+ if (tileCachingDuration !== null && !Number.isInteger(tileCachingDuration)) {
+ tileCachingDuration = null;
+ }
+
locale = loadDataFromStorage('locale');
if (!(locale in messages)) {
locale = null;
@@ -123,6 +134,9 @@ export const initialState = {
),
shouldAutorotateMap: shouldAutorotateMap !== null ? shouldAutorotateMap : false,
skipOnboarding: skipOnboarding || false,
+ tileCachingDuration: (
+ tileCachingDuration !== null ? tileCachingDuration : DEFAULT_TILE_CACHING_DURATION
+ ),
tileServer: tileServer || DEFAULT_TILE_SERVER,
},
};
diff --git a/src/views/Settings.vue b/src/views/Settings.vue
index be33701..63f182c 100644
--- a/src/views/Settings.vue
+++ b/src/views/Settings.vue
@@ -27,6 +27,15 @@
required
>
+
+
import { TILE_SERVERS } from '@/constants';
import { AVAILABLE_LOCALES } from '@/i18n';
+import { capitalize } from '@/tools';
import PermissionsSwitches from '@/components/PermissionsSwitches.vue';
@@ -102,6 +112,34 @@ export default {
this.$store.dispatch('unmarkIntroAsSeen');
},
},
+ tileCachingDuration: {
+ get() {
+ return this.$store.state.settings.tileCachingDuration;
+ },
+ set(tileCachingDuration) {
+ this.$store.dispatch('setSetting', { setting: 'tileCachingDuration', value: tileCachingDuration });
+ },
+ },
+ tileCachingDurationOptions() {
+ return [
+ {
+ duration: 0,
+ name: this.$i18n.t('settings.noCaching'),
+ },
+ {
+ duration: -1,
+ name: this.$i18n.t('settings.defaultDuration'),
+ },
+ {
+ duration: 3600 * 24,
+ name: capitalize(this.$i18n.tc('relativeDate.day', 1, { count: 1 })),
+ },
+ {
+ duration: 3600 * 24 * 7,
+ name: capitalize(this.$i18n.tc('relativeDate.day', 7, { count: 7 })),
+ },
+ ];
+ },
tileServer: {
get() {
const tileServerStore = this.$store.state.settings.tileServer;
@@ -130,6 +168,7 @@ export default {
name: AVAILABLE_LOCALES[iso].name,
}));
i18nItems.sort((a, b) => a.iso > b.iso);
+
return {
i18nItems,
orientationModes: [