From b4102f3cfd582434d6a0d3b5eaaff622317f5c08 Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Tue, 15 Sep 2020 13:27:59 +0200 Subject: [PATCH] Add try/cath for JSON.parse --- app/assets/javascripts/sitewide/atwho_res.js.erb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/sitewide/atwho_res.js.erb b/app/assets/javascripts/sitewide/atwho_res.js.erb index ab9a4a53c..f3d874b45 100644 --- a/app/assets/javascripts/sitewide/atwho_res.js.erb +++ b/app/assets/javascripts/sitewide/atwho_res.js.erb @@ -104,7 +104,7 @@ var SmartAnnotation = (function() { } $.getJSON(filterType.dataUrl, params, function(data) { - localStorage.setItem('smart_annotation_state_per_team/' + data.team, JSON.stringify({ + localStorage.setItem('scinote-smart-annotation-state-per-team-' + data.team, JSON.stringify({ tag: filterType.tag, repository: data.repository })); @@ -171,12 +171,14 @@ var SmartAnnotation = (function() { if ($currentAtWho.find('.tab-pane.active').length == 0) { let filterType = DEFAULT_SEARCH_FILTER.tag; let teamId = $currentAtWho.find('.atwho-header-res').data('team-id'); - let remeberedState = localStorage.getItem('smart_annotation_state_per_team/' + teamId); + let remeberedState = localStorage.getItem('scinote-smart-annotation-state-per-team-' + teamId); if (remeberedState) { - remeberedState = JSON.parse(remeberedState); - filterType = remeberedState.tag; - $currentAtWho.find(`.repository-object[data-object-id=${remeberedState.repository}]`) - .addClass('btn-primary'); + try { + remeberedState = JSON.parse(remeberedState); + filterType = remeberedState.tag; + $currentAtWho.find(`.repository-object[data-object-id=${remeberedState.repository}]`) + .addClass('btn-primary'); + } catch {} } $currentAtWho.find(`.${filterType}`).click(); }