From 8b1d208a72d09c00f170aacf95b4092f4af1f9b4 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 25 Jun 2021 19:50:29 +1000 Subject: [PATCH] Fix maps not loading in safari --- src/helpers/shared.js | 3 +++ src/workers/DatabaseWorker.js | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/helpers/shared.js b/src/helpers/shared.js index 5940429..b45ce17 100644 --- a/src/helpers/shared.js +++ b/src/helpers/shared.js @@ -75,6 +75,9 @@ export function groupBy(array, key) { } export const isMacLike = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform); +export const isSafari = /^((?!chrome|android).)*safari/i.test( + navigator.userAgent +); export function shuffle(array) { let temp = [...array]; diff --git a/src/workers/DatabaseWorker.js b/src/workers/DatabaseWorker.js index 8b53785..7003e93 100644 --- a/src/workers/DatabaseWorker.js +++ b/src/workers/DatabaseWorker.js @@ -8,6 +8,7 @@ import { encode, decode } from "@msgpack/msgpack"; import { getDatabase } from "../database"; import blobToBuffer from "../helpers/blobToBuffer"; +import { isSafari } from "../helpers/shared"; // Worker to load large amounts of database data on a separate thread let service = { @@ -45,6 +46,10 @@ let service = { * @param {string} table */ async putData(data, table) { + if (isSafari) { + // Safari is unable to put data into indexedb and have useLiveQuery update + return false; + } try { let db = getDatabase({}); const decoded = decode(data);