Skip to content

Commit 8b787a6

Browse files
committed
added saving provider type to localStorage
1 parent b0ea7d4 commit 8b787a6

File tree

6 files changed

+368
-350
lines changed

6 files changed

+368
-350
lines changed

.prettierrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"trailingComma": "es5",
3-
"arrowParens": "always"
3+
"arrowParens": "always",
4+
"printWidth": 100
45
}

src/components/Map.vue

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<template>
2-
<div
3-
:class="{ inactive: store.isColored }"
4-
class="mapcontainer"
5-
id="map"
6-
></div>
2+
<div :class="{ inactive: store.isColored }" class="mapcontainer" id="map"></div>
73
<Footer
84
:currentProvider="provider"
95
:canHistory="historyready"
@@ -25,16 +21,10 @@
2521
<script>
2622
import { useStore } from "@/store";
2723
import Footer from "../components/footer/Footer.vue";
28-
import config from "../config";
29-
import {
30-
drawuser,
31-
init,
32-
removeMap,
33-
setTheme,
34-
setview,
35-
} from "../utils/map/instance";
24+
import { drawuser, init, removeMap, setTheme, setview } from "../utils/map/instance";
3625
import { init as initMarkers } from "../utils/map/marker";
3726
import { init as initWind } from "../utils/map/wind";
27+
import { getTypeProvider } from "../utils/utils";
3828
3929
export default {
4030
emits: ["city", "clickMarker", "close"],
@@ -44,9 +34,7 @@ export default {
4434
return {
4535
store: useStore(),
4636
locale: localStorage.getItem("locale") || this.$i18n.locale || "en",
47-
theme: window?.matchMedia("(prefers-color-scheme: light)").matches
48-
? "light"
49-
: "dark",
37+
theme: window?.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark",
5038
userposition: null,
5139
geoavailable: false,
5240
};
@@ -63,7 +51,7 @@ export default {
6351
return this.store.mapposition.lng;
6452
},
6553
provider() {
66-
return this.$route.params.provider || config.DEFAUL_TYPE_PROVIDER;
54+
return getTypeProvider();
6755
},
6856
},
6957
@@ -87,7 +75,7 @@ export default {
8775
const options = {
8876
name: "main",
8977
params: {
90-
provider: this.provider || config.DEFAUL_TYPE_PROVIDER,
78+
provider: getTypeProvider(),
9179
type: this.$route.params.type || "pm10",
9280
zoom: zoom,
9381
lat: lat,
@@ -97,7 +85,6 @@ export default {
9785
};
9886
9987
if (this.$router.currentRoute.value.name === "main") {
100-
console.log(options);
10188
/* added here check for current route is map (main), as it caused problems with other pages */
10289
if (type === "reload") {
10390
this.$router.push(options).catch((e) => {
@@ -128,16 +115,9 @@ export default {
128115
if ("geolocation" in navigator) {
129116
navigator.geolocation.getCurrentPosition(
130117
(position) => {
131-
this.userposition = [
132-
position.coords.latitude,
133-
position.coords.longitude,
134-
];
118+
this.userposition = [position.coords.latitude, position.coords.longitude];
135119
/* setting for the app globally user's geo position and zoom 20 for better view */
136-
this.store.setmapposition(
137-
this.userposition[0],
138-
this.userposition[1],
139-
20
140-
);
120+
this.store.setmapposition(this.userposition[0], this.userposition[1], 20);
141121
this.geoavailable = true;
142122
resolve();
143123
},

src/components/measures/Measures.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<script>
1010
import { useStore } from "@/store";
1111
import measurements from "../../measurements";
12+
import { getTypeProvider } from "../../utils/utils";
1213
1314
export default {
1415
props: ["current"],
@@ -44,7 +45,7 @@ export default {
4445
await this.$router.push({
4546
name: "main",
4647
params: {
47-
provider: this.$route.params.provider || "realtime",
48+
provider: getTypeProvider(),
4849
type: this.type,
4950
zoom: this.$route.params.zoom,
5051
lat: this.$route.params.lat,

0 commit comments

Comments
 (0)