idealista-enhancer/src/LocationStorage.js
Jorge Bolois c9bb903cf4 Using own server to dont kill github.
Some improvements over enlarge images.
2023-02-25 12:04:00 +01:00

43 lines
872 B
JavaScript

import Log from "./Log.js";
export default class LocationStorage {
static KEY = 'midefos-idealista-location-storage';
static get storage() {
return window.localStorage;
}
static get data() {
if (!this._data) {
this._init();
}
return JSON.parse(this._data);
}
static get _data() {
return this.storage.getItem(this.KEY);
}
static get(name) {
const locations = this.data;
return locations[name];
}
static save(location) {
const locations = this.data;
locations[location.name] = location;
this._save(locations);
}
static _init() {
Log.debug(`Init location storage`);
this._save({});
}
static _save(data) {
const json = JSON.stringify(data);
this.storage.setItem(this.KEY, json);
}
}