mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-08-02 00:51:47 +00:00
Do not fail when sessionStorage is not available.
Fixes https://github.com/PeWu/topola-webtrees/issues/1
This commit is contained in:
@@ -36,9 +36,13 @@ export async function loadFromUrl(
|
|||||||
url: string,
|
url: string,
|
||||||
handleCors: boolean,
|
handleCors: boolean,
|
||||||
): Promise<TopolaData> {
|
): Promise<TopolaData> {
|
||||||
const cachedData = sessionStorage.getItem(url);
|
try {
|
||||||
if (cachedData) {
|
const cachedData = sessionStorage.getItem(url);
|
||||||
return JSON.parse(cachedData);
|
if (cachedData) {
|
||||||
|
return JSON.parse(cachedData);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Failed to load data from session storage: ' + e);
|
||||||
}
|
}
|
||||||
const urlToFetch = handleCors
|
const urlToFetch = handleCors
|
||||||
? 'https://cors-anywhere.herokuapp.com/' + url
|
? 'https://cors-anywhere.herokuapp.com/' + url
|
||||||
@@ -58,9 +62,13 @@ export async function loadGedcom(
|
|||||||
gedcom?: string,
|
gedcom?: string,
|
||||||
images?: Map<string, string>,
|
images?: Map<string, string>,
|
||||||
): Promise<TopolaData> {
|
): Promise<TopolaData> {
|
||||||
const cachedData = sessionStorage.getItem(hash);
|
try {
|
||||||
if (cachedData) {
|
const cachedData = sessionStorage.getItem(hash);
|
||||||
return JSON.parse(cachedData);
|
if (cachedData) {
|
||||||
|
return JSON.parse(cachedData);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Failed to load data from session storage: ' + e);
|
||||||
}
|
}
|
||||||
if (!gedcom) {
|
if (!gedcom) {
|
||||||
throw new Error('Error loading data. Please upload your file again.');
|
throw new Error('Error loading data. Please upload your file again.');
|
||||||
|
|||||||
Reference in New Issue
Block a user