Add try/cath for JSON.parse

This commit is contained in:
aignatov-bio 2020-09-15 13:27:59 +02:00
parent 9cb26a1cb9
commit b4102f3cfd

View file

@ -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();
}