aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/favorite.js
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2016-12-14 13:19:40 +0100
committerNoah Loomans <noahloomans@gmail.com>2016-12-14 13:19:40 +0100
commitd90eb26e864a4d6be73986c727b8c14b4e215f8d (patch)
treea7b061ae92e2941c29693b0284f2953b4d54e9ec /public/javascripts/favorite.js
parentd67c1945b7d737d3293ea9fff95ec7f30a8f47de (diff)
add compatibility old version localstorrage
Diffstat (limited to 'public/javascripts/favorite.js')
-rw-r--r--public/javascripts/favorite.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/public/javascripts/favorite.js b/public/javascripts/favorite.js
index f10d954..8f48dc5 100644
--- a/public/javascripts/favorite.js
+++ b/public/javascripts/favorite.js
@@ -9,13 +9,18 @@ self._nodes = {
}
self.get = function () {
- const localStorageUser = JSON.parse(window.localStorage.getItem('fav'))
- if (localStorageUser == null) return
-
- const correctedUser = USERS.filter(user =>
- user.type === localStorageUser.type &&
- user.value === localStorageUser.value)[0]
- return correctedUser
+ try {
+ const localStorageUser = JSON.parse(window.localStorage.getItem('fav'))
+ if (localStorageUser == null) return
+
+ const correctedUser = USERS.filter(user =>
+ user.type === localStorageUser.type &&
+ user.value === localStorageUser.value)[0]
+ return correctedUser
+ } catch (e) {
+ self.delete()
+ return
+ }
}
self.set = function (user) {